2 function(configure_host_tools HOST_TOOLS_DIR)
3 file(MAKE_DIRECTORY ${HOST_TOOLS_DIR})
5 message(STATUS "Configuring host tools...")
6 # cmake sets CC and CXX when those languages are enabled
7 # so we need to clear them here
8 execute_process(COMMAND
10 -E env --unset=CC --unset=CXX
12 -G "${CMAKE_GENERATOR}"
16 WORKING_DIRECTORY ${HOST_TOOLS_DIR}
17 RESULT_VARIABLE _host_config_result
18 OUTPUT_VARIABLE _host_config_log
19 ERROR_VARIABLE _host_config_log)
21 # Show cmake output only if host-tools breaks
22 if(NOT _host_config_result EQUAL 0)
23 message("\nHost tools log:")
24 message("${_host_config_log}")
25 message(FATAL_ERROR "Failed to configure host tools")
28 set_property(SOURCE host_tools PROPERTY SYMBOLIC 1)
30 include(${HOST_TOOLS_DIR}/ImportExecutables.cmake)
31 include(${HOST_TOOLS_DIR}/TargetList.cmake)
33 foreach(_target ${NATIVE_TARGETS})
34 get_target_property(_target_location native-${_target} LOCATION)
35 list(APPEND _target_locations ${_target_location})
38 # Make a host-tools target so it'll be built when needed
39 # custom target + symbolic output prevents cmake from running
40 # the command multiple times per build
41 # Specify the --config option, so the Release/Debug setting from the IDE can be used
43 COMMAND ${CMAKE_COMMAND} --build ${HOST_TOOLS_DIR} --config $<CONFIG>
45 BYPRODUCTS ${_target_locations})
46 add_custom_target(build-host-tools ALL DEPENDS host_tools)
48 foreach(_target ${NATIVE_TARGETS})
49 add_dependencies(native-${_target} build-host-tools)
54 function(setup_host_tools)
56 # Use pre-built tools, required for cross compiling with msvc
57 # as only one target architecture is available at a time
58 find_path(HOST_TOOLS_DIR
59 NAMES ImportExecutables.cmake
60 HINTS ${WITH_HOST_TOOLS} ${REACTOS_SOURCE_DIR}/${WITH_HOST_TOOLS}
62 NO_CMAKE_ENVIRONMENT_PATH)
63 message(STATUS "Using prebuilt host tools: ${HOST_TOOLS_DIR}")
64 include(${HOST_TOOLS_DIR}/ImportExecutables.cmake)
66 # Build host-tools. Changes to tool sources will rebuild targets
68 set(HOST_TOOLS_DIR ${REACTOS_BINARY_DIR}/host-tools)
69 configure_host_tools(${HOST_TOOLS_DIR})