2015-09-06 16:44:30 +00:00
|
|
|
|
2019-02-13 10:06:49 +00:00
|
|
|
function(configure_host_tools HOST_TOOLS_DIR)
|
|
|
|
file(MAKE_DIRECTORY ${HOST_TOOLS_DIR})
|
2018-10-01 11:07:44 +00:00
|
|
|
|
|
|
|
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}
|
2019-02-13 10:06:49 +00:00
|
|
|
WORKING_DIRECTORY ${HOST_TOOLS_DIR}
|
2018-10-01 11:07:44 +00:00
|
|
|
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")
|
2015-09-06 16:44:30 +00:00
|
|
|
endif()
|
2018-10-01 11:07:44 +00:00
|
|
|
|
|
|
|
set_property(SOURCE host_tools PROPERTY SYMBOLIC 1)
|
|
|
|
|
2020-06-06 20:57:11 +00:00
|
|
|
include(${HOST_TOOLS_DIR}/ImportExecutables.cmake)
|
|
|
|
include(${HOST_TOOLS_DIR}/TargetList.cmake)
|
|
|
|
|
|
|
|
foreach(_target ${NATIVE_TARGETS})
|
|
|
|
get_target_property(_target_location native-${_target} LOCATION)
|
|
|
|
list(APPEND _target_locations ${_target_location})
|
|
|
|
endforeach()
|
|
|
|
|
2018-10-01 11:07:44 +00:00
|
|
|
# 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
|
2020-07-05 15:11:28 +00:00
|
|
|
# Specify the --config option, so the Release/Debug setting from the IDE can be used
|
2018-10-01 11:07:44 +00:00
|
|
|
add_custom_command(
|
2020-07-05 15:11:28 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} --build ${HOST_TOOLS_DIR} --config $<CONFIG>
|
2020-06-06 20:57:11 +00:00
|
|
|
OUTPUT host_tools
|
|
|
|
BYPRODUCTS ${_target_locations})
|
2018-10-01 11:07:44 +00:00
|
|
|
add_custom_target(build-host-tools ALL DEPENDS host_tools)
|
|
|
|
|
|
|
|
foreach(_target ${NATIVE_TARGETS})
|
|
|
|
add_dependencies(native-${_target} build-host-tools)
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
endfunction()
|
2019-02-13 10:06:49 +00:00
|
|
|
|
|
|
|
function(setup_host_tools)
|
|
|
|
if(WITH_HOST_TOOLS)
|
|
|
|
# Use pre-built tools, required for cross compiling with msvc
|
|
|
|
# as only one target architecture is available at a time
|
2019-02-15 01:33:13 +00:00
|
|
|
find_path(HOST_TOOLS_DIR
|
|
|
|
NAMES ImportExecutables.cmake
|
|
|
|
HINTS ${WITH_HOST_TOOLS} ${REACTOS_SOURCE_DIR}/${WITH_HOST_TOOLS}
|
|
|
|
NO_CMAKE_PATH
|
|
|
|
NO_CMAKE_ENVIRONMENT_PATH)
|
|
|
|
message(STATUS "Using prebuilt host tools: ${HOST_TOOLS_DIR}")
|
2019-02-13 10:06:49 +00:00
|
|
|
include(${HOST_TOOLS_DIR}/ImportExecutables.cmake)
|
|
|
|
else()
|
|
|
|
# Build host-tools. Changes to tool sources will rebuild targets
|
|
|
|
# using that tool
|
|
|
|
set(HOST_TOOLS_DIR ${REACTOS_BINARY_DIR}/host-tools)
|
|
|
|
configure_host_tools(${HOST_TOOLS_DIR})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
endfunction()
|