Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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>")
like image 234
harish Avatar asked Oct 15 '25 08:10

harish


1 Answers

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>
           ...
)
like image 159
vre Avatar answered Oct 18 '25 03:10

vre