set(CMAKE_POSITION_INDEPENDENT_CODE OFF)
#set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
-if(NOT DEFINED NEW_STYLE_BUILD)
- set(NEW_STYLE_BUILD TRUE)
-endif()
-
if(NOT ARCH)
set(ARCH i386)
endif()
# include(sdk/cmake/bison-flex.cmake)
if(NOT CMAKE_CROSSCOMPILING)
-
- if(NEW_STYLE_BUILD)
- set(TOOLS_FOLDER ${CMAKE_CURRENT_BINARY_DIR})
- endif()
-
+ set(TOOLS_FOLDER ${CMAKE_CURRENT_BINARY_DIR})
add_definitions(-DTARGET_${ARCH})
if(MSVC)
add_subdirectory(sdk/tools)
add_subdirectory(sdk/lib)
- if(NOT NEW_STYLE_BUILD)
- if(NOT MSVC)
- export(TARGETS bin2c widl gendib cabman fatten hpp isohybrid mkhive mkisofs obj2bin spec2def geninc rsym mkshelllink utf16le xml2sdb FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
- else()
- export(TARGETS bin2c widl gendib cabman fatten hpp isohybrid mkhive mkisofs obj2bin spec2def geninc mkshelllink utf16le xml2sdb FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
- endif()
+ set(NATIVE_TARGETS bin2c widl gendib cabman fatten hpp isohybrid mkhive mkisofs obj2bin spec2def geninc mkshelllink utf16le xml2sdb)
+ if(NOT MSVC)
+ list(APPEND NATIVE_TARGETS rsym)
endif()
+ export(TARGETS ${NATIVE_TARGETS} FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
+ configure_file(sdk/cmake/host-tools.in ${CMAKE_BINARY_DIR}/TargetList.cmake)
+
else()
+ # Add host tools target
+ include(sdk/cmake/host-tools.cmake)
+ setup_host_tools()
+
# We don't need CMake importlib handling.
unset(CMAKE_IMPORT_LIBRARY_SUFFIX)
- if(NEW_STYLE_BUILD)
- include(sdk/cmake/host-tools.cmake)
- endif()
-
# Print build type
message("-- Build Type: ${CMAKE_BUILD_TYPE}")
#useful stuff!
include(CMakeParseArguments)
- if(NOT NEW_STYLE_BUILD)
- if(NOT DEFINED REACTOS_BUILD_TOOLS_DIR)
- set(REACTOS_BUILD_TOOLS_DIR ${REACTOS_SOURCE_DIR}/build)
- endif()
- set(IMPORT_EXECUTABLES "${REACTOS_BUILD_TOOLS_DIR}/ImportExecutables.cmake" CACHE FILEPATH "Host executables")
- include(${IMPORT_EXECUTABLES})
- endif()
-
if(DBG)
add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE)
else()
goto quit
)
-REM Special case %1 = arm_hosttools %2 = vcvarsall.bat %3 = %CMAKE_GENERATOR%
-if /I "%1" == "arm_hosttools" (
- echo Configuring x86 host tools for ARM cross build
-
- REM This launches %VSINSTALLDIR%VS\vcvarsall.bat
- call %2 x86
-
- REM Configure host tools for x86.
- cmake -G %3 -A Win32 -DARCH:STRING=i386 %~dp0
- exit
-)
-
REM Get the source root directory
set REACTOS_SOURCE_DIR=%~dp0
goto quit
)
-set NEW_STYLE_BUILD=1
set USE_CLANG_CL=0
REM Parse command line parameters
:repeat
- if /I "%1" == "-DNEW_STYLE_BUILD" (
- set NEW_STYLE_BUILD=%2
- ) else if "%BUILD_ENVIRONMENT%" == "MinGW" (
+ if "%BUILD_ENVIRONMENT%" == "MinGW" (
if /I "%1" == "Codeblocks" (
set CMAKE_GENERATOR="CodeBlocks - MinGW Makefiles"
) else if /I "%1" == "Eclipse" (
goto quit
)
-if "%NEW_STYLE_BUILD%"=="0" (
-
- if not exist host-tools (
- mkdir host-tools
- )
-
- if not exist reactos (
- mkdir reactos
- )
-
- echo Preparing host tools...
- cd host-tools
- if EXIST CMakeCache.txt (
- del CMakeCache.txt /q
- )
-
- set REACTOS_BUILD_TOOLS_DIR=!CD!
-
- REM Use x86 for ARM host tools
- if "%ARCH%" == "arm" (
- REM Launch new script instance for x86 host tools configuration
- start "Preparing host tools for ARM cross build..." /I /B /WAIT %~dp0configure.cmd arm_hosttools "%VSINSTALLDIR%VC\vcvarsall.bat" %CMAKE_GENERATOR%
- ) else (
- cmake -G %CMAKE_GENERATOR% %CMAKE_ARCH% -DARCH:STRING=%ARCH% "%REACTOS_SOURCE_DIR%"
- )
-
- cd..
-
-)
-
echo Preparing reactos...
-if "%NEW_STYLE_BUILD%"=="0" (
- cd reactos
-)
-
if EXIST CMakeCache.txt (
del CMakeCache.txt /q
- del host-tools\CMakeCache.txt /q
)
-if "%NEW_STYLE_BUILD%"=="0" (
- set BUILD_TOOLS_FLAG=-DREACTOS_BUILD_TOOLS_DIR:PATH="%REACTOS_BUILD_TOOLS_DIR%"
-)
if "%BUILD_ENVIRONMENT%" == "MinGW" (
cmake -G %CMAKE_GENERATOR% -DENABLE_CCACHE:BOOL=0 -DCMAKE_TOOLCHAIN_FILE:FILEPATH=%MINGW_TOOCHAIN_FILE% -DARCH:STRING=%ARCH% %BUILD_TOOLS_FLAG% %* "%REACTOS_SOURCE_DIR%"
cmake -G %CMAKE_GENERATOR% %CMAKE_ARCH% -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-msvc.cmake -DARCH:STRING=%ARCH% %BUILD_TOOLS_FLAG% -DRUNTIME_CHECKS:BOOL=%VS_RUNTIME_CHECKS% %* "%REACTOS_SOURCE_DIR%"
)
-if "%NEW_STYLE_BUILD%"=="0" (
- cd..
-)
-
if %ERRORLEVEL% NEQ 0 (
goto quit
)
ARCH=$ROS_ARCH
REACTOS_SOURCE_DIR=$(cd `dirname $0` && pwd)
REACTOS_OUTPUT_PATH=output-$BUILD_ENVIRONMENT-$ARCH
-USE_NEW_STYLE=1
usage() {
echo Invalid parameter given.
makefiles|Makefiles)
CMAKE_GENERATOR="Unix Makefiles"
;;
- with-host-tools)
- USE_NEW_STYLE=0
- ;;
*)
usage
esac
cd "$REACTOS_OUTPUT_PATH"
fi
-#EXTRA_ARGS=""
-if [ $USE_NEW_STYLE -eq 0 ]; then
- mkdir -p host-tools
- mkdir -p reactos
- echo Preparing host tools...
- cd host-tools
- rm -f CMakeCache.txt
-
- REACTOS_BUILD_TOOLS_DIR="$PWD"
- cmake -G "$CMAKE_GENERATOR" -DARCH:STRING=$ARCH $ROS_CMAKEOPTS -DNEW_STYLE_BUILD:BOOL=0 "$REACTOS_SOURCE_DIR"
-
- EXTRA_ARGS="$EXTRA_ARGS -DREACTOS_BUILD_TOOLS_DIR:PATH=$REACTOS_BUILD_TOOLS_DIR"
-
- cd ..
-fi
-
echo Preparing reactos...
-
-if [ $USE_NEW_STYLE -eq 0 ]; then
- cd reactos
-fi
-
rm -f CMakeCache.txt host-tools/CMakeCache.txt
-cmake -G "$CMAKE_GENERATOR" -DENABLE_CCACHE:BOOL=0 -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-gcc.cmake -DARCH:STRING=$ARCH -DNEW_STYLE_BUILD:BOOL=$USE_NEW_STYLE $EXTRA_ARGS $ROS_CMAKEOPTS "$REACTOS_SOURCE_DIR"
+cmake -G "$CMAKE_GENERATOR" -DENABLE_CCACHE:BOOL=0 -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-gcc.cmake -DARCH:STRING=$ARCH $EXTRA_ARGS $ROS_CMAKEOPTS "$REACTOS_SOURCE_DIR"
echo Configure script complete! Enter directories and execute appropriate build commands \(ex: ninja, make, makex, etc...\).
set(CMAKE_RC_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> ${CMAKE_C_FLAGS} <CMAKE_SHARED_LIBRARY_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
else()
# Normal rsym build
- if(NEW_STYLE_BUILD)
- string(TOUPPER ${CMAKE_BUILD_TYPE} _build_type)
- get_target_property(RSYM native-rsym IMPORTED_LOCATION_${_build_type})
- else()
- get_target_property(RSYM native-rsym IMPORTED_LOCATION_NOCONFIG)
- endif()
+ get_target_property(RSYM native-rsym IMPORTED_LOCATION_NOCONFIG)
set(CMAKE_C_LINK_EXECUTABLE
"<CMAKE_C_COMPILER> ${CMAKE_C_FLAGS} <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>"
-if(CMAKE_HOST_WIN32)
- set(native_suffix ".exe")
-endif()
-
-string(TOUPPER ${CMAKE_BUILD_TYPE} _build_type)
-
-# List of host tools
-list(APPEND host_tools_list bin2c hpp widl gendib cabman fatten isohybrid mkhive mkisofs obj2bin spec2def geninc mkshelllink utf16le xml2sdb)
-if(NOT MSVC)
- list(APPEND host_tools_list rsym)
-endif()
-
-foreach(_host_tool ${host_tools_list})
- if(MSVC_IDE)
- get_filename_component(_tool_location "${CMAKE_CURRENT_BINARY_DIR}/host-tools/${CMAKE_BUILD_TYPE}/${_host_tool}${native_suffix}" ABSOLUTE)
- else()
- get_filename_component(_tool_location "${CMAKE_CURRENT_BINARY_DIR}/host-tools/${_host_tool}${native_suffix}" ABSOLUTE)
+function(setup_host_tools)
+ file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/host-tools)
+
+ message(STATUS "Configuring host tools...")
+ # cmake sets CC and CXX when those languages are enabled
+ # so we need to clear them here
+ execute_process(COMMAND
+ ${CMAKE_COMMAND}
+ -E env --unset=CC --unset=CXX
+ ${CMAKE_COMMAND}
+ -G "${CMAKE_GENERATOR}"
+ -DARCH:STRING=${ARCH}
+ ${USE_CLANG_CL_ARG}
+ ${REACTOS_SOURCE_DIR}
+ WORKING_DIRECTORY ${REACTOS_BINARY_DIR}/host-tools
+ RESULT_VARIABLE _host_config_result
+ OUTPUT_VARIABLE _host_config_log
+ ERROR_VARIABLE _host_config_log)
+
+ # Show cmake output only if host-tools breaks
+ if(NOT _host_config_result EQUAL 0)
+ message("\nHost tools log:")
+ message("${_host_config_log}")
+ message(FATAL_ERROR "Failed to configure host tools")
endif()
- list(APPEND tools_binaries ${_tool_location})
- add_executable(native-${_host_tool} IMPORTED)
- set_property(TARGET native-${_host_tool} PROPERTY IMPORTED_LOCATION_${_build_type} ${_tool_location})
- add_dependencies(native-${_host_tool} host-tools)
-endforeach()
-
-if(USE_CLANG_CL)
- # FIXME: Fix host tools build with clang
- #set(USE_CLANG_CL_ARG "-DCMAKE_C_COMPILER=clang-cl;-DCMAKE_CXX_COMPILER=clang-cl")
-endif()
-
-include(ExternalProject)
-
-ExternalProject_Add(host-tools
- SOURCE_DIR ${REACTOS_SOURCE_DIR}
- BINARY_DIR ${REACTOS_BINARY_DIR}/host-tools
- STAMP_DIR ${REACTOS_BINARY_DIR}/host-tools/stamps
- BUILD_ALWAYS 1
- PREFIX host-tools
- EXCLUDE_FROM_ALL 1
- CMAKE_ARGS "-DNEW_STYLE_BUILD=1;-DARCH:STRING=${ARCH};${USE_CLANG_CL_ARG}"
- INSTALL_COMMAND ""
- BUILD_BYPRODUCTS ${tools_binaries})
+
+ set_property(SOURCE host_tools PROPERTY SYMBOLIC 1)
+
+ # Make a host-tools target so it'll be built when needed
+ # custom target + symbolic output prevents cmake from running
+ # the command multiple times per build
+ add_custom_command(
+ COMMAND ${CMAKE_COMMAND} --build ${REACTOS_BINARY_DIR}/host-tools
+ OUTPUT host_tools)
+ add_custom_target(build-host-tools ALL DEPENDS host_tools)
+
+ include(${REACTOS_BINARY_DIR}/host-tools/ImportExecutables.cmake)
+ include(${REACTOS_BINARY_DIR}/host-tools/TargetList.cmake)
+
+ foreach(_target ${NATIVE_TARGETS})
+ add_dependencies(native-${_target} build-host-tools)
+ endforeach()
+
+endfunction()
--- /dev/null
+set(NATIVE_TARGETS @NATIVE_TARGETS@)
function(add_host_tool _tool)
add_executable(${_tool} ${ARGN})
- if(NEW_STYLE_BUILD)
- set_target_properties(${_tool} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${TOOLS_FOLDER})
- endif()
+ set_target_properties(${_tool} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${TOOLS_FOLDER})
endfunction()
#add_executable(pefixup pefixup.c)