xref: /reactos/sdk/cmake/host-tools.cmake (revision 8a92b556)
1
2include(ExternalProject)
3
4function(setup_host_tools)
5    list(APPEND HOST_TOOLS bin2c widl gendib cabman fatten hpp isohybrid mkhive mkisofs obj2bin spec2def geninc mkshelllink utf16le xml2sdb)
6    if(NOT MSVC)
7        list(APPEND HOST_TOOLS rsym pefixup)
8    endif()
9    list(TRANSFORM HOST_TOOLS PREPEND "${REACTOS_BINARY_DIR}/host-tools/bin/" OUTPUT_VARIABLE HOST_TOOLS_OUTPUT)
10    if (CMAKE_HOST_WIN32)
11        list(TRANSFORM HOST_TOOLS_OUTPUT APPEND ".exe")
12        set(HOST_EXE_SUFFIX ".exe")
13    endif()
14
15    ExternalProject_Add(host-tools
16        SOURCE_DIR ${REACTOS_SOURCE_DIR}
17        PREFIX ${REACTOS_BINARY_DIR}/host-tools
18        BINARY_DIR ${REACTOS_BINARY_DIR}/host-tools/bin
19        CMAKE_ARGS -UCMAKE_TOOLCHAIN_FILE -DARCH:STRING=${ARCH} -DCMAKE_INSTALL_PREFIX=${REACTOS_BINARY_DIR}/host-tools -DTOOLS_FOLDER=${REACTOS_BINARY_DIR}/host-tools/bin
20        BUILD_ALWAYS TRUE
21        INSTALL_COMMAND ${CMAKE_COMMAND} -E true
22        BUILD_BYPRODUCTS ${HOST_TOOLS_OUTPUT}
23    )
24
25    ExternalProject_Get_Property(host-tools INSTALL_DIR)
26
27    foreach(_tool ${HOST_TOOLS})
28        add_executable(native-${_tool} IMPORTED)
29        set_target_properties(native-${_tool} PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/bin/${_tool}${HOST_EXE_SUFFIX})
30        add_dependencies(native-${_tool} host-tools ${INSTALL_DIR}/bin/${_tool}${HOST_EXE_SUFFIX})
31    endforeach()
32endfunction()
33