From 35ab1f40e2ae470c29a1ccf1be8560b0c1197c27 Mon Sep 17 00:00:00 2001 From: Dane Walton Date: Wed, 27 Jan 2021 13:12:22 -0800 Subject: [PATCH 1/9] wrap CMP0091 in MSVC check --- CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 72686f06d4..8eeccd48c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,9 +44,12 @@ if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET) set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "") endif() -# Use the static runtime libraries when building statically for consistency with vcpkg's -# arch-windows-static triplets: -cmake_policy(SET CMP0091 NEW) # https://cmake.org/cmake/help/v3.15/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html +if(MSVC) + # Use the static runtime libraries when building statically for consistency with vcpkg's + # arch-windows-static triplets: + cmake_policy(SET CMP0091 NEW) # https://cmake.org/cmake/help/v3.15/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html +endif() + if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif() From f010e24e88c68aa71686a3e608bc77ba1ed6ccc6 Mon Sep 17 00:00:00 2001 From: Dane Walton Date: Wed, 27 Jan 2021 13:37:21 -0800 Subject: [PATCH 2/9] the if check may need the lib addition --- CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8eeccd48c2..7b08d7a19d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,11 +48,10 @@ if(MSVC) # Use the static runtime libraries when building statically for consistency with vcpkg's # arch-windows-static triplets: cmake_policy(SET CMP0091 NEW) # https://cmake.org/cmake/help/v3.15/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html -endif() - -if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) + if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif() +endif() project(az LANGUAGES C) enable_testing () From 4bc2db0b8a9cfafa29aaa313540841f781f9c4f1 Mon Sep 17 00:00:00 2001 From: Dane Walton Date: Wed, 27 Jan 2021 13:37:49 -0800 Subject: [PATCH 3/9] formatting --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b08d7a19d..e1e1d63984 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,8 +49,8 @@ if(MSVC) # arch-windows-static triplets: cmake_policy(SET CMP0091 NEW) # https://cmake.org/cmake/help/v3.15/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) - set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") -endif() + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + endif() endif() project(az LANGUAGES C) From 876cc4d300c1ace3021f10d1c0fcb5a439083ae8 Mon Sep 17 00:00:00 2001 From: Dane Walton Date: Wed, 27 Jan 2021 14:29:35 -0800 Subject: [PATCH 4/9] move msvc check to after project --- CMakeLists.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e1e1d63984..f05eb88572 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,18 +44,20 @@ if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET) set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "") endif() + +if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +endif() + +project(az LANGUAGES C) +enable_testing () + if(MSVC) # Use the static runtime libraries when building statically for consistency with vcpkg's # arch-windows-static triplets: cmake_policy(SET CMP0091 NEW) # https://cmake.org/cmake/help/v3.15/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html - if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) - set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - endif() endif() -project(az LANGUAGES C) -enable_testing () - include(eng/cmake/global_compile_options.txt) include(create_map_file) From d65887a8f532b76713a3e58de6f01fe890849c94 Mon Sep 17 00:00:00 2001 From: Dane Walton Date: Wed, 27 Jan 2021 14:30:52 -0800 Subject: [PATCH 5/9] formatting --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f05eb88572..a72fb38587 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,7 +44,6 @@ if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET) set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "") endif() - if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif() From 9411c24db4a494877e43dbfb43115654ecb46c35 Mon Sep 17 00:00:00 2001 From: Dane Walton Date: Wed, 27 Jan 2021 14:45:55 -0800 Subject: [PATCH 6/9] one more time --- CMakeLists.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a72fb38587..b86f17e6fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,10 +44,6 @@ if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET) set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "") endif() -if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) - set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") -endif() - project(az LANGUAGES C) enable_testing () @@ -55,6 +51,9 @@ if(MSVC) # Use the static runtime libraries when building statically for consistency with vcpkg's # arch-windows-static triplets: cmake_policy(SET CMP0091 NEW) # https://cmake.org/cmake/help/v3.15/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html + if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + endif() endif() include(eng/cmake/global_compile_options.txt) From a4bf13d7af5c64569c9857e1785f6190e6105382 Mon Sep 17 00:00:00 2001 From: Dane Walton Date: Wed, 27 Jan 2021 15:00:54 -0800 Subject: [PATCH 7/9] lets try adding WIN32 too --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b86f17e6fd..e58d26ce25 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,7 +47,7 @@ endif() project(az LANGUAGES C) enable_testing () -if(MSVC) +if(MSVC OR WIN32) # Use the static runtime libraries when building statically for consistency with vcpkg's # arch-windows-static triplets: cmake_policy(SET CMP0091 NEW) # https://cmake.org/cmake/help/v3.15/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html From 7e88dbfdd9c703fee583341cfcc19dd447a80db6 Mon Sep 17 00:00:00 2001 From: Dane Walton Date: Wed, 10 Feb 2021 15:24:48 -0800 Subject: [PATCH 8/9] try something here --- eng/cmake/global_compile_options.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/eng/cmake/global_compile_options.txt b/eng/cmake/global_compile_options.txt index 50153041f6..6e9b11dfa5 100644 --- a/eng/cmake/global_compile_options.txt +++ b/eng/cmake/global_compile_options.txt @@ -5,6 +5,12 @@ if(MSVC) endif() add_compile_options(/W4 ${WARNINGS_AS_ERRORS_FLAG} /wd5031 /wd4668 /wd4820 /wd4255 /wd4710 /analyze) + + add_compile_options( + $<$:/MT> #---------| + $<$:/MTd> #---|-- Statically link the runtime libraries + $<$:/MT> #--| + ) elseif(CMAKE_C_COMPILER_ID MATCHES "Clang") if(WARNINGS_AS_ERRORS) set(WARNINGS_AS_ERRORS_FLAG "-Werror") From 0501779a7ce4fbe647191e0bc31769d37b4cac68 Mon Sep 17 00:00:00 2001 From: Dane Walton Date: Wed, 10 Feb 2021 16:43:42 -0800 Subject: [PATCH 9/9] try remove cmake policy --- CMakeLists.txt | 9 --------- 1 file changed, 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e58d26ce25..355667dc65 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,15 +47,6 @@ endif() project(az LANGUAGES C) enable_testing () -if(MSVC OR WIN32) - # Use the static runtime libraries when building statically for consistency with vcpkg's - # arch-windows-static triplets: - cmake_policy(SET CMP0091 NEW) # https://cmake.org/cmake/help/v3.15/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html - if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) - set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - endif() -endif() - include(eng/cmake/global_compile_options.txt) include(create_map_file)