diff --git a/CMakeLists.txt b/CMakeLists.txt index 709188b4..006a4bc4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,15 @@ cmake_minimum_required(VERSION 3.12 FATAL_ERROR) -if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.15.0) - # Set policy CMP0091 to new to allow use of CMAKE_MSVC_RUNTIME_LIBRARY - cmake_policy(SET CMP0091 NEW) +# Set the policy CMP0091 to new to allow use of CMAKE_MSVC_RUNTIME_LIBRARY, +# unless it has already been set +if(POLICY CMP0091) + cmake_policy(GET CMP0091 CMP0091_value) + if(NOT CMP0091_value) + cmake_policy(SET CMP0091 NEW) + cmake_policy(GET CMP0091 CMP0091_value) + endif() +else() + set(CMP0091_value OLD) endif() project(bmx @@ -14,7 +21,7 @@ project(bmx include("${CMAKE_CURRENT_LIST_DIR}/cmake/options.cmake") -if(MSVC AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.15.0) +if(MSVC AND CMP0091_value STREQUAL NEW) if(BMX_SET_MSVC_RUNTIME STREQUAL "MD") set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") elseif(BMX_SET_MSVC_RUNTIME STREQUAL "MT") @@ -48,8 +55,8 @@ if(MSVC) add_compile_options(/W3 /EHsc) add_definitions(-D_CRT_SECURE_NO_WARNINGS) - if(CMAKE_VERSION VERSION_LESS 3.15.0 AND NOT BMX_SET_MSVC_RUNTIME STREQUAL "default") - # cmake version < 3.15: Update compiler flags to use a particular runtime + if(CMP0091_value STREQUAL OLD AND NOT BMX_SET_MSVC_RUNTIME STREQUAL "default") + # Update compiler flags to use a particular runtime macro(update_msvc_runtime_flags flags) if(BMX_SET_MSVC_RUNTIME STREQUAL "MD") # Use MultiThreadedDLL runtime diff --git a/deps/libMXF/CMakeLists.txt b/deps/libMXF/CMakeLists.txt index 09be2aea..90555d97 100644 --- a/deps/libMXF/CMakeLists.txt +++ b/deps/libMXF/CMakeLists.txt @@ -1,8 +1,15 @@ cmake_minimum_required(VERSION 3.12 FATAL_ERROR) -if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.15.0) - # Set policy CMP0091 to new to allow use of CMAKE_MSVC_RUNTIME_LIBRARY - cmake_policy(SET CMP0091 NEW) +# Set the policy CMP0091 to new to allow use of CMAKE_MSVC_RUNTIME_LIBRARY, +# unless it has already been set +if(POLICY CMP0091) + cmake_policy(GET CMP0091 CMP0091_value) + if(NOT CMP0091_value) + cmake_policy(SET CMP0091 NEW) + cmake_policy(GET CMP0091 CMP0091_value) + endif() +else() + set(CMP0091_value OLD) endif() project(libMXF @@ -14,7 +21,7 @@ project(libMXF include("${CMAKE_CURRENT_LIST_DIR}/cmake/options.cmake") -if(MSVC AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.15.0) +if(MSVC AND CMP0091_value STREQUAL NEW) if(LIBMXF_SET_MSVC_RUNTIME STREQUAL "MD") set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") elseif(LIBMXF_SET_MSVC_RUNTIME STREQUAL "MT") @@ -48,8 +55,8 @@ if(MSVC) add_compile_options(/W3) add_definitions(-D_CRT_SECURE_NO_WARNINGS) - if(CMAKE_VERSION VERSION_LESS 3.15.0 AND NOT LIBMXF_SET_MSVC_RUNTIME STREQUAL "default") - # cmake version < 3.15: Update compiler flags to use a particular runtime + if(CMP0091_value STREQUAL OLD AND NOT LIBMXF_SET_MSVC_RUNTIME STREQUAL default) + # Update compiler flags to use a particular runtime macro(update_msvc_runtime_flags flags) if(LIBMXF_SET_MSVC_RUNTIME STREQUAL "MD") # Use MultiThreadedDLL runtime diff --git a/deps/libMXFpp/CMakeLists.txt b/deps/libMXFpp/CMakeLists.txt index 2bc13115..bef4e519 100644 --- a/deps/libMXFpp/CMakeLists.txt +++ b/deps/libMXFpp/CMakeLists.txt @@ -1,8 +1,15 @@ cmake_minimum_required(VERSION 3.12 FATAL_ERROR) -if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.15.0) - # Set policy CMP0091 to new to allow use of CMAKE_MSVC_RUNTIME_LIBRARY - cmake_policy(SET CMP0091 NEW) +# Set the policy CMP0091 to new to allow use of CMAKE_MSVC_RUNTIME_LIBRARY, +# unless it has already been set +if(POLICY CMP0091) + cmake_policy(GET CMP0091 CMP0091_value) + if(NOT CMP0091_value) + cmake_policy(SET CMP0091 NEW) + cmake_policy(GET CMP0091 CMP0091_value) + endif() +else() + set(CMP0091_value OLD) endif() project(libMXF++ @@ -14,7 +21,7 @@ project(libMXF++ include("${CMAKE_CURRENT_LIST_DIR}/cmake/options.cmake") -if(MSVC AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.15.0) +if(MSVC AND CMP0091_value STREQUAL NEW) if(LIBMXFPP_SET_MSVC_RUNTIME STREQUAL "MD") set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") elseif(LIBMXFPP_SET_MSVC_RUNTIME STREQUAL "MT") @@ -33,8 +40,8 @@ if(MSVC) add_compile_options(/W3 /EHsc) add_definitions(-D_CRT_SECURE_NO_WARNINGS) - if(CMAKE_VERSION VERSION_LESS 3.15.0 AND NOT LIBMXFPP_SET_MSVC_RUNTIME STREQUAL "default") - # cmake version < 3.15: Update compiler flags to use a particular runtime + if(CMP0091_value STREQUAL OLD AND NOT LIBMXFPP_SET_MSVC_RUNTIME STREQUAL "default") + # Update compiler flags to use a particular runtime macro(update_msvc_runtime_flags flags) if(LIBMXFPP_SET_MSVC_RUNTIME STREQUAL "MD") # Use MultiThreadedDLL runtime