diff --git a/CMakeLists.txt b/CMakeLists.txt index b462c1c7b7a..6a93449495c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,16 +13,6 @@ else() set(RECONFIGURE_MESSAGE_LEVEL WARNING) endif() -# Setup NATIVE_BUILD_TARGETS list for further native build -# when cross-compiling and host architecture differs from target architecture. -# Add target to the list: -# add_native_target (...) -set_property (GLOBAL PROPERTY NATIVE_BUILD_TARGETS) -function (add_native_target) - get_property (tmp GLOBAL PROPERTY NATIVE_BUILD_TARGETS) - set_property (GLOBAL PROPERTY NATIVE_BUILD_TARGETS "${tmp}" "${ARGV}") -endfunction (add_native_target) - include (cmake/arch.cmake) include (cmake/target.cmake) include (cmake/tools.cmake) @@ -564,6 +554,16 @@ macro (clickhouse_add_executable target) endif() endmacro() +# With cross-compiling, all targets are built for the target platform which usually different from the host +# platform. This is problematic if a build artifact X (e.g. a file or an executable) is generated by running +# another executable Y previously produced in the build. This is solved by compiling and running Y for/on +# the host platform. Add target to the list: +# add_native_target( ...) +set_property (GLOBAL PROPERTY NATIVE_BUILD_TARGETS) +function (add_native_target) + set_property (GLOBAL APPEND PROPERTY NATIVE_BUILD_TARGETS ${ARGV}) +endfunction (add_native_target) + set(ConfigIncludePath ${CMAKE_CURRENT_BINARY_DIR}/includes/configs CACHE INTERNAL "Path to generated configuration files.") include_directories(${ConfigIncludePath}) @@ -582,10 +582,10 @@ include (cmake/sanitize_target_link_libraries.cmake) # Build native targets if necessary get_property(NATIVE_BUILD_TARGETS GLOBAL PROPERTY NATIVE_BUILD_TARGETS) if (NATIVE_BUILD_TARGETS - AND NOT( - CMAKE_HOST_SYSTEM_NAME STREQUAL CMAKE_SYSTEM_NAME + AND NOT( + CMAKE_HOST_SYSTEM_NAME STREQUAL CMAKE_SYSTEM_NAME AND CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL CMAKE_SYSTEM_PROCESSOR - ) + ) ) message (STATUS "Building native targets...") @@ -597,9 +597,6 @@ if (NATIVE_BUILD_TARGETS execute_process( COMMAND ${CMAKE_COMMAND} - "-G${CMAKE_GENERATOR}" - "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" - "-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}" "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" ${CMAKE_SOURCE_DIR}