Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only emit MSVC_RUNTIME_LIBRARY in the root project #150

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions src/cmake_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,6 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
if (is_root_project) {
cmd("cmake_minimum_required")("VERSION", project.cmake_version).endl();

// clang-format on
if (!project.allow_in_tree) {
// clang-format off
cmd("if")("CMAKE_SOURCE_DIR", "STREQUAL", "CMAKE_BINARY_DIR");
Expand All @@ -740,6 +739,11 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
// clang-format on
}

if (project.project_msvc_runtime != parser::msvc_last) {
comment("Enable support for MSVC_RUNTIME_LIBRARY");
cmd("cmake_policy")("SET", "CMP0091", "NEW").endl();
}

cmd("set")("CMKR_ROOT_PROJECT", "OFF");
// clang-format off
cmd("if")("CMAKE_CURRENT_SOURCE_DIR", "STREQUAL", "CMAKE_SOURCE_DIR");
Expand All @@ -758,15 +762,9 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {

comment("Create a configure-time dependency on cmake.toml to improve IDE support");
cmd("configure_file")("cmake.toml", "cmake.toml", "COPYONLY");
cmd("endif")().endl();
// clang-format on

if (project.project_msvc_runtime != parser::msvc_last) {
comment("Enable support for MSVC_RUNTIME_LIBRARY");
cmd("cmake_policy")("SET", "CMP0091", "NEW");

// clang-format off
cmd("if")("NOT", "DEFINED", "CMAKE_MSVC_RUNTIME_LIBRARY");
if (project.project_msvc_runtime != parser::msvc_last) {
cmd("if")("NOT", "DEFINED", "CMAKE_MSVC_RUNTIME_LIBRARY");
switch (project.project_msvc_runtime) {
case parser::msvc_dynamic:
cmd("set")("CMAKE_MSVC_RUNTIME_LIBRARY", "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL");
Expand All @@ -777,9 +775,10 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
default:
break;
}
cmd("endif")().endl();
// clang-format on
}
cmd("endif")().endl();
}
cmd("endif")().endl();
// clang-format on

fs::path cmkr_include(project.cmkr_include);
if (!project.cmkr_include.empty() && !fs::exists(cmkr_include) && cmkr_include.is_relative()) {
Expand Down
Loading