将当前编译器转发到ExternalProject [英] Forwarding current compiler to ExternalProject
问题描述
我尝试使用 ExternalProject 模组:
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" )`
还有一个问题,我想出了:
这个模块由于某种原因不转发编译器,用于(parent)cmake以及CMAKE_BUILD_TYPE。
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.
我试图使用CMAKE_CACHE_DEFAULT_ARGS直接设置CMAKE_CXX_COMPILER,但它没有安静的工作。
I've tried to use CMAKE_CACHE_DEFAULT_ARGS to set CMAKE_CXX_COMPILER directly, but it didn't quiet worked out.
这个行为有正确的解释吗?
是否有正确的(cmake-ish)方式将当前使用的编译器/构建配置转发给ExternalProject?
Is there a decent explanation for this behaviour? Is there a proper (cmake-ish) way to forward currently used compiler/build configuration to ExternalProject?
推荐答案
要转发编译器,请使用 ExternalProject
参数 CMAKE_CACHE_ARGS
,即:
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}"
)
这篇关于将当前编译器转发到ExternalProject的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!