Open cjserio opened 2 years ago
Hi,
FYI I think you can already easily tell CMake to build targets either with /MD
or /MT
without doing so much custom CMake coding.
CMake introduced this feature in version 3.15
To use it you must change the cmake_minimum_required(VERSION ...)
at the beginning of CMakeLists.txt.
# if you use any version older than 3.15, then these features will not work !
# you will not even get any warnings or other log messages about it
cmake_minimum_required(VERSION 3.12) # <--- for any version older than 3.15, setting CMAKE_MSVC_RUNTIME_LIBRARY will do nothing
# if you set a minimum version newer than 3.15, then the builtin CMake features for
# switching the MSVC C++ Runtime linking will start working for you
cmake_minimum_required(VERSION 3.15) # <--- you have to set at least 3.15 or any later version here
Then you can either set the global CMake variable CMAKE_MSVC_RUNTIME_LIBRARY
at the beginning of the crashpad CMakeLists.txt
... or, if you want to set this on a per-target basis, you can use set_target_properties()
on specific targets and set the MSVC_RUNTIME_LIBRARY
property individually for each target.
By setting either of those to MultiThreaded$<$<CONFIG:Debug>:Debug>
you will get the static /MT
runtime-linking in Visual Studio/MSBuild ... if you set MultiThreaded$<$<CONFIG:Debug>:Debug>DLL
you will get the dll /MD
runtime-linking.
IMO there is rarely a need to fiddle with low-level compiler flags / compiler options when using CMake (especially on Windows when using MSVC) Modern CMake already has a lot of the common usecases covered :wink:
PS: I tried doing the above in the CMakeLists.txt of this repo, and it worked on the first try.
(I can build both /MD
or /MT
simply by doing what I described above)
@KrzaQ WDYT?
I think I need to educate myself about this before offering an opinion. I expect I'll have the time to look at this next week.
…by using the -DSTATIC_RUNTIME=ON argument passed to the cmake generator command.