Forwarding current compiler to ExternalProject

时光毁灭记忆、已成空白 提交于 2019-12-08 01:03:35

问题


I was trying to use ExternalProject module:

ExternalProject_Add( googlebenchmark
                 GIT_REPOSITORY "https://github.com/google/benchmark.git"
                 TLS_VERIFY ON
                 CMAKE_CACHE_DEFAULT_ARGS -DBENCHMARK_ENABLE_TESTING:BOOL=OFF
                 SOURCE_DIR "${CMAKE_BINARY_DIR}/third_party/gbenchmark"
                 INSTALL_DIR "${CMAKE_BINARY_DIR}/third_party" )`

And there is an issue I've come up with: this module for some reason doesn't forward compiler, used in (parent) cmake, as well as CMAKE_BUILD_TYPE.

I've tried to use CMAKE_CACHE_DEFAULT_ARGS to set CMAKE_CXX_COMPILER directly, but it didn't quiet worked out.

Is there a decent explanation for this behaviour? Is there a proper (cmake-ish) way to forward currently used compiler/build configuration to ExternalProject?


回答1:


To forward the compiler use the ExternalProject argument CMAKE_CACHE_ARGS, i.e.:

ExternalProject_Add( googlebenchmark
    ...
    CMAKE_CACHE_ARGS 
       "-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}"
       "-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}"
)


来源:https://stackoverflow.com/questions/32744788/forwarding-current-compiler-to-externalproject

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!