-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)
+include(ExternalProject)
- # 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")
+function(setup_host_tools)
+ list(APPEND HOST_TOOLS bin2c widl gendib cabman fatten hpp isohybrid mkhive mkisofs obj2bin spec2def geninc mkshelllink utf16le xml2sdb)
+ if(NOT MSVC)
+ list(APPEND HOST_TOOLS rsym pefixup)
+ endif()
+ list(TRANSFORM HOST_TOOLS PREPEND "${REACTOS_BINARY_DIR}/host-tools/bin/" OUTPUT_VARIABLE HOST_TOOLS_OUTPUT)
+ if (CMAKE_HOST_WIN32)
+ list(TRANSFORM HOST_TOOLS_OUTPUT APPEND ".exe")
+ set(HOST_EXE_SUFFIX ".exe")
endif()
- 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)
+ ExternalProject_Add(host-tools
+ SOURCE_DIR ${REACTOS_SOURCE_DIR}
+ PREFIX ${REACTOS_BINARY_DIR}/host-tools
+ INSTALL_DIR ${REACTOS_BINARY_DIR}/host-tools
+ CMAKE_ARGS -UCMAKE_TOOLCHAIN_FILE -DARCH:STRING=${ARCH} -DCMAKE_INSTALL_PREFIX=${REACTOS_BINARY_DIR}/host-tools
+ BUILD_ALWAYS TRUE
+ BUILD_BYPRODUCTS ${HOST_TOOLS_OUTPUT}
+ )
+
+ ExternalProject_Get_Property(host-tools INSTALL_DIR)
+
+ foreach(_tool ${HOST_TOOLS})
+ add_executable(native-${_tool} IMPORTED)
+ set_target_properties(native-${_tool} PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/bin/${_tool}${HOST_EXE_SUFFIX})
+ add_dependencies(native-${_tool} host-tools)
endforeach()
-
endfunction()