Forwarding current compiler to ExternalProject

2019-06-08 12:47发布

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条回答
Explosion°爆炸
2楼-- · 2019-06-08 13:03

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}"
)
查看更多
登录 后发表回答