Skip to content

Commit

Permalink
Use POLICY value rather than cmake version to decide setting runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
philipnbbc committed Oct 9, 2023
1 parent 2810e55 commit e8c34ec
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 18 deletions.
19 changes: 13 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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$<$<CONFIG:Debug>:Debug>DLL")
elseif(BMX_SET_MSVC_RUNTIME STREQUAL "MT")
Expand Down Expand Up @@ -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
Expand Down
19 changes: 13 additions & 6 deletions deps/libMXF/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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$<$<CONFIG:Debug>:Debug>DLL")
elseif(LIBMXF_SET_MSVC_RUNTIME STREQUAL "MT")
Expand Down Expand Up @@ -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
Expand Down
19 changes: 13 additions & 6 deletions deps/libMXFpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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++
Expand All @@ -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$<$<CONFIG:Debug>:Debug>DLL")
elseif(LIBMXFPP_SET_MSVC_RUNTIME STREQUAL "MT")
Expand All @@ -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
Expand Down

0 comments on commit e8c34ec

Please sign in to comment.