How do I set CMake policy and property on an external project added using ExternalProject_Add

谁都会走 提交于 2020-12-13 03:21:44

问题


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

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