问题
I have a cmake project that uses an external project using CMake's ExternalProject_Add feature. Is there a way to set policy and property on the external project?
I would like following policy and property that is set in my project to be forwarded also to external project so that static multi-threaded windows runtime libraries are used instead of dynamic ones.
cmake_policy(SET CMP0091 NEW)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
回答1:
You can simply add those settings to the CMAKE_ARGS
variable of the ExternalProject_Add
command, e.g.
ExternalProject_Add(<you_name_it>
...
CMAKE_ARGS
-DCMAKE_POLICY_DEFAULT_CMP0091:STRING=NEW
-DCMAKE_MSVC_RUNTIME_LIBRARY:STRING=MultiThreaded$<$<CONFIG:Debug>:Debug>
...
)
来源:https://stackoverflow.com/questions/60398627/how-do-i-set-cmake-policy-and-property-on-an-external-project-added-using-extern