diff --git a/contrib/protobuf-cmake/CMakeLists.txt b/contrib/protobuf-cmake/CMakeLists.txt index 10ef7df26b1..0ceb72cfbd6 100644 --- a/contrib/protobuf-cmake/CMakeLists.txt +++ b/contrib/protobuf-cmake/CMakeLists.txt @@ -25,40 +25,67 @@ if (CMAKE_CROSSCOMPILING) # Build 'protoc' for host arch set (PROTOC_BUILD_DIR "${protobuf_BINARY_DIR}/build") - add_custom_command ( - OUTPUT ${PROTOC_BUILD_DIR} - COMMAND mkdir -p ${PROTOC_BUILD_DIR}) + if (NOT EXISTS "${PROTOC_BUILD_DIR}/protoc") - add_custom_command ( - OUTPUT "${PROTOC_BUILD_DIR}/CMakeCache.txt" + # This is quite ugly but I cannot make dependencies work propery. - COMMAND ${CMAKE_COMMAND} - -G"${CMAKE_GENERATOR}" - -DCMAKE_MAKE_PROGRAM="${CMAKE_MAKE_PROGRAM}" - -DCMAKE_C_COMPILER="${CMAKE_C_COMPILER}" - -DCMAKE_CXX_COMPILER="${CMAKE_CXX_COMPILER}" - -Dprotobuf_BUILD_TESTS=0 - -Dprotobuf_BUILD_CONFORMANCE=0 - -Dprotobuf_BUILD_EXAMPLES=0 - -Dprotobuf_BUILD_PROTOC_BINARIES=1 - "${protobuf_SOURCE_DIR}/cmake" + execute_process( + COMMAND mkdir -p ${PROTOC_BUILD_DIR} + COMMAND_ECHO STDOUT) - DEPENDS "${PROTOC_BUILD_DIR}" - WORKING_DIRECTORY "${PROTOC_BUILD_DIR}" - COMMENT "Configuring 'protoc' for host architecture.") + execute_process( + COMMAND ${CMAKE_COMMAND} + "-G${CMAKE_GENERATOR}" + "-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}" + "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" + "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" + "-Dprotobuf_BUILD_TESTS=0" + "-Dprotobuf_BUILD_CONFORMANCE=0" + "-Dprotobuf_BUILD_EXAMPLES=0" + "-Dprotobuf_BUILD_PROTOC_BINARIES=1" + "${protobuf_SOURCE_DIR}/cmake" + WORKING_DIRECTORY "${PROTOC_BUILD_DIR}" + COMMAND_ECHO STDOUT) - add_custom_command ( - OUTPUT "${PROTOC_BUILD_DIR}/protoc" - COMMAND ${CMAKE_COMMAND} --build "${PROTOC_BUILD_DIR}" - DEPENDS "${PROTOC_BUILD_DIR}/CMakeCache.txt" - COMMENT "Building 'protoc' for host architecture.") + execute_process( + COMMAND ${CMAKE_COMMAND} --build "${PROTOC_BUILD_DIR}" + COMMAND_ECHO STDOUT) + endif () - #add_custom_target (protoc DEPENDS "${PROTOC_BUILD_DIR}/protoc") - #set_target_properties (protoc PROPERTIES TARGET_FILE "${PROTOC_BUILD_DIR}/protoc") +# add_custom_command ( +# OUTPUT ${PROTOC_BUILD_DIR} +# COMMAND mkdir -p ${PROTOC_BUILD_DIR}) +# +# add_custom_command ( +# OUTPUT "${PROTOC_BUILD_DIR}/CMakeCache.txt" +# +# COMMAND ${CMAKE_COMMAND} +# -G"${CMAKE_GENERATOR}" +# -DCMAKE_MAKE_PROGRAM="${CMAKE_MAKE_PROGRAM}" +# -DCMAKE_C_COMPILER="${CMAKE_C_COMPILER}" +# -DCMAKE_CXX_COMPILER="${CMAKE_CXX_COMPILER}" +# -Dprotobuf_BUILD_TESTS=0 +# -Dprotobuf_BUILD_CONFORMANCE=0 +# -Dprotobuf_BUILD_EXAMPLES=0 +# -Dprotobuf_BUILD_PROTOC_BINARIES=1 +# "${protobuf_SOURCE_DIR}/cmake" +# +# DEPENDS "${PROTOC_BUILD_DIR}" +# WORKING_DIRECTORY "${PROTOC_BUILD_DIR}" +# COMMENT "Configuring 'protoc' for host architecture." +# USES_TERMINAL) +# +# add_custom_command ( +# OUTPUT "${PROTOC_BUILD_DIR}/protoc" +# COMMAND ${CMAKE_COMMAND} --build "${PROTOC_BUILD_DIR}" +# DEPENDS "${PROTOC_BUILD_DIR}/CMakeCache.txt" +# COMMENT "Building 'protoc' for host architecture." +# USES_TERMINAL) +# +# add_custom_target (protoc-host DEPENDS "${PROTOC_BUILD_DIR}/protoc") add_executable(protoc IMPORTED GLOBAL) set_target_properties (protoc PROPERTIES IMPORTED_LOCATION "${PROTOC_BUILD_DIR}/protoc") add_dependencies(protoc "${PROTOC_BUILD_DIR}/protoc") - #add_executable(protobuf::protoc ALIAS protoc) endif ()