I have a project for which I create a static and a dynamic version of the libraries. The tools are linked against the static version so no special DLLs are required to run them on the final system.
I can setup the entire everything to compile with /MD or /MT (and corresponding debug) with a simple set in the root CMakeLists.txt.
For example, to force /MT I can use the following:
set ( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT" )
set ( CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT" )
set ( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_RELEASE} /MTd" )
set ( CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_RELEASE} /MTd" )
However, that means the dynamic libraries get compiled with /MT which is wrong. Is it possible to do the same thing on a per project basis? After all, once the solution is created, I can edit each project and fix the /MD and /MT objects to what I need. Can cmake do that? It would be handy.
I looked at the set_target_properties() but that does not seem to take the CMAKE_C_FLAGS_<type> variables and if I just set a standard set of flags it won't be specific to Debug or Release.
The following does set the property, but I don't seem to have a choice for debug and release options.
set_target_properties( ${PROJECT_NAME} PROPERTIES
COMPILE_FLAGS "/MT"
)
Any solution?