From 9580702a9bb2ddc7f85af572304d1e3f634e41cc Mon Sep 17 00:00:00 2001 From: Alovchin91 <8490695+Alovchin91@users.noreply.github.com> Date: Wed, 21 Aug 2024 10:35:10 +0200 Subject: [PATCH] Fix static CRT compilation Use CMake 3.28 for compatibility with MSVC 17.10 LTS --- CMakeLists.txt | 2 +- cmake/msix_options.cmake | 8 +------- lib/CMakeLists.txt | 2 +- lib/xerces/CMakeLists.txt | 2 +- sample/BundleSample/CMakeLists.txt | 2 +- sample/CMakeLists.txt | 2 +- sample/ExtractContentsSample/CMakeLists.txt | 2 +- sample/OverrideLanguageSample/CMakeLists.txt | 2 +- sample/OverrideStreamSample/CMakeLists.txt | 2 +- sample/PackSample/CMakeLists.txt | 2 +- src/CMakeLists.txt | 2 +- src/makemsix/CMakeLists.txt | 2 +- src/msix/CMakeLists.txt | 9 +-------- src/test/CMakeLists.txt | 2 +- src/test/mobile/AndroidBVT/app/CMakeLists.txt | 2 +- src/test/msixtest/CMakeLists.txt | 2 +- 16 files changed, 16 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a7dabd68..35849745a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2017 Microsoft. All rights reserved. # See LICENSE file in the project root for full license information. -cmake_minimum_required(VERSION 3.29.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.0 FATAL_ERROR) project(msix-sdk) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) diff --git a/cmake/msix_options.cmake b/cmake/msix_options.cmake index 4e80da1da..0de87262e 100644 --- a/cmake/msix_options.cmake +++ b/cmake/msix_options.cmake @@ -31,13 +31,7 @@ if(USE_STATIC_MSVC) if(NOT WIN32) message(FATAL_ERROR "-DUSE_STATIC_MSVC=on can only be used for Windows") endif() - # By default these flags have /MD set. Modified it to use /MT instead. - foreach(buildType RELEASE MINSIZEREL RELWITHDEBINFO) - set(cxxFlag "CMAKE_CXX_FLAGS_${buildType}") - string(REPLACE "/MD" "/MT" ${cxxFlag} "${${cxxFlag}}") - endforeach() - set(cxxFlagDebug "CMAKE_CXX_FLAGS_DEBUG") - string(REPLACE "/MDd" "/MTd" ${cxxFlagDebug} "${${cxxFlagDebug}}") + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif() # Set xml parser if not set diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 900af3c76..4cefdcca0 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,7 +1,7 @@ # MSIX\lib # Copyright (C) 2017 Microsoft. All rights reserved. # See LICENSE file in the project root for full license information. -cmake_minimum_required(VERSION 3.29.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.0 FATAL_ERROR) add_custom_target(LIBS) diff --git a/lib/xerces/CMakeLists.txt b/lib/xerces/CMakeLists.txt index 8be6dff10..de5ce5e4f 100644 --- a/lib/xerces/CMakeLists.txt +++ b/lib/xerces/CMakeLists.txt @@ -19,7 +19,7 @@ # Run "cmake" to generate the build files for your platform -cmake_minimum_required(VERSION 3.29.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.0 FATAL_ERROR) # Use new variable expansion policy. if (POLICY CMP0053) diff --git a/sample/BundleSample/CMakeLists.txt b/sample/BundleSample/CMakeLists.txt index 17dfb8e82..cba9e22d2 100644 --- a/sample/BundleSample/CMakeLists.txt +++ b/sample/BundleSample/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2017 Microsoft. All rights reserved. # See LICENSE file in the project root for full license information. -cmake_minimum_required(VERSION 3.29.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.0 FATAL_ERROR) project (BundleSample) if(WIN32) diff --git a/sample/CMakeLists.txt b/sample/CMakeLists.txt index 8985a2f98..632a3ee8b 100644 --- a/sample/CMakeLists.txt +++ b/sample/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2017 Microsoft. All rights reserved. # See LICENSE file in the project root for full license information. -cmake_minimum_required(VERSION 3.29.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.0 FATAL_ERROR) # For windows copy the library to the msix and samples directory if(WIN32) diff --git a/sample/ExtractContentsSample/CMakeLists.txt b/sample/ExtractContentsSample/CMakeLists.txt index 522bfcabd..7865d3817 100644 --- a/sample/ExtractContentsSample/CMakeLists.txt +++ b/sample/ExtractContentsSample/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2017 Microsoft. All rights reserved. # See LICENSE file in the project root for full license information. -cmake_minimum_required(VERSION 3.29.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.0 FATAL_ERROR) project (ExtractContentsSample) if(WIN32) diff --git a/sample/OverrideLanguageSample/CMakeLists.txt b/sample/OverrideLanguageSample/CMakeLists.txt index 886dd8358..cb994dbcf 100644 --- a/sample/OverrideLanguageSample/CMakeLists.txt +++ b/sample/OverrideLanguageSample/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2017 Microsoft. All rights reserved. # See LICENSE file in the project root for full license information. -cmake_minimum_required(VERSION 3.29.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.0 FATAL_ERROR) project (OverrideLanguageSample) if(WIN32) diff --git a/sample/OverrideStreamSample/CMakeLists.txt b/sample/OverrideStreamSample/CMakeLists.txt index 92db66ace..394940b98 100644 --- a/sample/OverrideStreamSample/CMakeLists.txt +++ b/sample/OverrideStreamSample/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2017 Microsoft. All rights reserved. # See LICENSE file in the project root for full license information. -cmake_minimum_required(VERSION 3.29.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.0 FATAL_ERROR) project (OverrideStreamSample) if(WIN32) diff --git a/sample/PackSample/CMakeLists.txt b/sample/PackSample/CMakeLists.txt index c8217d576..9a0fe60d5 100644 --- a/sample/PackSample/CMakeLists.txt +++ b/sample/PackSample/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Microsoft. All rights reserved. # See LICENSE file in the project root for full license information. -cmake_minimum_required(VERSION 3.29.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.0 FATAL_ERROR) project (PackSample) if(WIN32) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index da4c47ac8..086fad732 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,7 +2,7 @@ # Copyright (C) 2017 Microsoft. All rights reserved. # See LICENSE file in the project root for full license information. -cmake_minimum_required(VERSION 3.29.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.0 FATAL_ERROR) add_subdirectory(msix) add_subdirectory(makemsix) diff --git a/src/makemsix/CMakeLists.txt b/src/makemsix/CMakeLists.txt index cc68cc7fd..769831350 100644 --- a/src/makemsix/CMakeLists.txt +++ b/src/makemsix/CMakeLists.txt @@ -2,7 +2,7 @@ # Copyright (C) 2017 Microsoft. All rights reserved. # See LICENSE file in the project root for full license information. -cmake_minimum_required(VERSION 3.29.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.0 FATAL_ERROR) project (makemsix) if(MSIX_PACK) diff --git a/src/msix/CMakeLists.txt b/src/msix/CMakeLists.txt index 6ed53241a..8cae29cad 100644 --- a/src/msix/CMakeLists.txt +++ b/src/msix/CMakeLists.txt @@ -2,7 +2,7 @@ # Copyright (C) 2017 Microsoft. All rights reserved. # See LICENSE file in the project root for full license information. -cmake_minimum_required(VERSION 3.29.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.0 FATAL_ERROR) project(msix) @@ -271,13 +271,6 @@ if(WIN32) string(REPLACE ";" " " DELAYFLAGS "${DELAYFLAGS}") set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS "${DELAYFLAGS} /LTCG") set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS " /DEF:${CMAKE_CURRENT_BINARY_DIR}/windowsexports.def") - if(USE_STATIC_MSVC) - if(CMAKE_BUILD_TYPE MATCHES Debug) - set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS " /NODEFAULTLIB:MSVCRTD") - else() - set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS " /NODEFAULTLIB:MSVCRT") - endif() - endif() target_link_libraries(${PROJECT_NAME} PRIVATE bcrypt crypt32 wintrust runtimeobject.lib delayimp.lib) endif() diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index f5b2c397f..da5b7af41 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -2,7 +2,7 @@ # Copyright (C) 2017 Microsoft. All rights reserved. # See LICENSE file in the project root for full license information. -cmake_minimum_required(VERSION 3.29.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.0 FATAL_ERROR) set(MSIX_TEST_OUTPUT_DIRECTORY "${MSIX_BINARY_ROOT}/msixtest") diff --git a/src/test/mobile/AndroidBVT/app/CMakeLists.txt b/src/test/mobile/AndroidBVT/app/CMakeLists.txt index 00c9de367..c325ff28a 100644 --- a/src/test/mobile/AndroidBVT/app/CMakeLists.txt +++ b/src/test/mobile/AndroidBVT/app/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2017 Microsoft. All rights reserved. # See LICENSE file in the project root for full license information. -cmake_minimum_required(VERSION 3.29.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.0 FATAL_ERROR) include_directories( ${include_directories} diff --git a/src/test/msixtest/CMakeLists.txt b/src/test/msixtest/CMakeLists.txt index 8cd0cd5d8..8385d5a6e 100644 --- a/src/test/msixtest/CMakeLists.txt +++ b/src/test/msixtest/CMakeLists.txt @@ -2,7 +2,7 @@ # Copyright (C) 2019 Microsoft. All rights reserved. # See LICENSE file in the project root for full license information. -cmake_minimum_required(VERSION 3.29.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.0 FATAL_ERROR) project (msixtest) if(WIN32)