From 02ad182b48174a4711b0c9dc7a35f5a71fe0dd1b Mon Sep 17 00:00:00 2001 From: Jason Dellaluce Date: Fri, 23 Feb 2024 08:44:58 +0000 Subject: [PATCH] fix(cmake): solve windows compilation issues Co-authored-by: Roberto Scolaro Signed-off-by: Jason Dellaluce --- CMakeLists.txt | 5 +++++ cmake/modules/CompilerFlags.cmake | 1 + 2 files changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index bcfb1470..ee8ba7a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,11 @@ option(MUSL_OPTIMIZED_BUILD "Enable if you want a musl optimized build" OFF) option(BUILD_FALCO_UNIT_TESTS "Build falco unit tests" OFF) if(WIN32) + if(POLICY CMP0091) + # Needed for CMAKE_MSVC_RUNTIME_LIBRARY + # https://cmake.org/cmake/help/latest/policy/CMP0091.html + cmake_policy(SET CMP0091 NEW) + endif() set(CPACK_GENERATOR "NSIS") # this needs NSIS installed, and available elseif (APPLE) set(CPACK_GENERATOR "DragNDrop") diff --git a/cmake/modules/CompilerFlags.cmake b/cmake/modules/CompilerFlags.cmake index 0926827a..c0993bd1 100644 --- a/cmake/modules/CompilerFlags.cmake +++ b/cmake/modules/CompilerFlags.cmake @@ -74,6 +74,7 @@ if(NOT MSVC) else() # MSVC set(MINIMAL_BUILD ON) + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") # The WIN32_LEAN_AND_MEAN define avoids possible macro pollution # when a libsinsp consumer includes the windows.h header.