-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()
+include(ExternalProject)
-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)
+ 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()
- 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()
+ 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}
+ )
-include(ExternalProject)
+ ExternalProject_Get_Property(host-tools INSTALL_DIR)
-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})
+ 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()