diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a559e1cba..430994a252 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,26 +1,7 @@ -cmake_minimum_required(VERSION 3.1.0) - -# for link time optimization, remove if cmake version is >= 3.9 -if(POLICY CMP0069) # LTO - cmake_policy(SET CMP0069 NEW) -endif() - -# for position-independent executable, remove if cmake version is >= 3.14 -if(POLICY CMP0083) - cmake_policy(SET CMP0083 NEW) -endif() - -# to link with freetype library -if(POLICY CMP0079) - cmake_policy(SET CMP0079 NEW) -endif() - -# don't add /W3 flag by default for MSVC -if(POLICY CMP0092) - cmake_policy(SET CMP0092 NEW) -endif() +cmake_minimum_required(VERSION 3.16.0) # set the timestamps of extracted contents to the time of extraction +# remove if cmake version is >= 3.24 if(POLICY CMP0135) cmake_policy(SET CMP0135 NEW) endif() @@ -585,20 +566,16 @@ if (NOT WIN32 AND NOT APPLE) endif() if(OPENMW_LTO_BUILD) - if(NOT CMAKE_VERSION VERSION_LESS 3.9) - include(CheckIPOSupported) - check_ipo_supported(RESULT HAVE_IPO OUTPUT HAVE_IPO_OUTPUT) - if(HAVE_IPO) - message(STATUS "LTO enabled for Release configuration.") - set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE) - else() - message(WARNING "Requested option OPENMW_LTO_BUILD not supported by this compiler: ${HAVE_IPO_OUTPUT}") - if(MSVC) - message(STATUS "Note: Flags used to be set manually for this setting with MSVC. We now rely on CMake for this. Upgrade CMake to at least 3.13 to re-enable this setting.") - endif() - endif() + include(CheckIPOSupported) + check_ipo_supported(RESULT HAVE_IPO OUTPUT HAVE_IPO_OUTPUT) + if(HAVE_IPO) + message(STATUS "LTO enabled for Release configuration.") + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE) else() - message(WARNING "Requested option OPENMW_LTO_BUILD not supported by this cmake version: ${CMAKE_VERSION}. Upgrade CMake to at least 3.9 to enable support for certain compilers. Newer CMake versions support more compilers.") + message(WARNING "Requested option OPENMW_LTO_BUILD not supported by this compiler: ${HAVE_IPO_OUTPUT}") + if(MSVC) + message(STATUS "Note: Flags used to be set manually for this setting with MSVC. We now rely on CMake for this. Upgrade CMake to at least 3.13 to re-enable this setting.") + endif() endif() endif() diff --git a/apps/benchmarks/detournavigator/CMakeLists.txt b/apps/benchmarks/detournavigator/CMakeLists.txt index 198cf2bd3c..2b3a6abe51 100644 --- a/apps/benchmarks/detournavigator/CMakeLists.txt +++ b/apps/benchmarks/detournavigator/CMakeLists.txt @@ -5,7 +5,7 @@ if (UNIX AND NOT APPLE) target_link_libraries(openmw_detournavigator_navmeshtilescache_benchmark ${CMAKE_THREAD_LIBS_INIT}) endif() -if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) +if (MSVC) target_precompile_headers(openmw_detournavigator_navmeshtilescache_benchmark PRIVATE ) endif() diff --git a/apps/benchmarks/esm/CMakeLists.txt b/apps/benchmarks/esm/CMakeLists.txt index e7ecfff41b..74870ceda1 100644 --- a/apps/benchmarks/esm/CMakeLists.txt +++ b/apps/benchmarks/esm/CMakeLists.txt @@ -5,7 +5,7 @@ if (UNIX AND NOT APPLE) target_link_libraries(openmw_esm_refid_benchmark ${CMAKE_THREAD_LIBS_INIT}) endif() -if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) +if (MSVC) target_precompile_headers(openmw_esm_refid_benchmark PRIVATE ) endif() diff --git a/apps/benchmarks/settings/CMakeLists.txt b/apps/benchmarks/settings/CMakeLists.txt index 8e3bd7375d..ccdd51eeac 100644 --- a/apps/benchmarks/settings/CMakeLists.txt +++ b/apps/benchmarks/settings/CMakeLists.txt @@ -8,7 +8,7 @@ if (UNIX AND NOT APPLE) target_link_libraries(openmw_settings_access_benchmark ${CMAKE_THREAD_LIBS_INIT}) endif() -if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) +if (MSVC) target_precompile_headers(openmw_settings_access_benchmark PRIVATE ) endif() diff --git a/apps/bsatool/CMakeLists.txt b/apps/bsatool/CMakeLists.txt index 0ee6d8472a..a567499ac6 100644 --- a/apps/bsatool/CMakeLists.txt +++ b/apps/bsatool/CMakeLists.txt @@ -18,7 +18,7 @@ if (BUILD_WITH_CODE_COVERAGE) target_link_libraries(bsatool gcov) endif() -if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) +if (MSVC) target_precompile_headers(bsatool PRIVATE diff --git a/apps/bulletobjecttool/CMakeLists.txt b/apps/bulletobjecttool/CMakeLists.txt index 924f66301c..6e6e1cdbb3 100644 --- a/apps/bulletobjecttool/CMakeLists.txt +++ b/apps/bulletobjecttool/CMakeLists.txt @@ -19,7 +19,7 @@ if (WIN32) install(TARGETS openmw-bulletobjecttool RUNTIME DESTINATION ".") endif() -if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) +if (MSVC) target_precompile_headers(openmw-bulletobjecttool PRIVATE diff --git a/apps/esmtool/CMakeLists.txt b/apps/esmtool/CMakeLists.txt index ad95b2b8e5..6f7fa1a993 100644 --- a/apps/esmtool/CMakeLists.txt +++ b/apps/esmtool/CMakeLists.txt @@ -25,7 +25,7 @@ if (BUILD_WITH_CODE_COVERAGE) target_link_libraries(esmtool gcov) endif() -if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) +if (MSVC) target_precompile_headers(esmtool PRIVATE diff --git a/apps/essimporter/CMakeLists.txt b/apps/essimporter/CMakeLists.txt index 3928d88e8f..c6c98791e3 100644 --- a/apps/essimporter/CMakeLists.txt +++ b/apps/essimporter/CMakeLists.txt @@ -47,7 +47,7 @@ if (WIN32) INSTALL(TARGETS openmw-essimporter RUNTIME DESTINATION ".") endif(WIN32) -if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) +if (MSVC) target_precompile_headers(openmw-essimporter PRIVATE diff --git a/apps/launcher/CMakeLists.txt b/apps/launcher/CMakeLists.txt index fe27dfc498..87cee06e5d 100644 --- a/apps/launcher/CMakeLists.txt +++ b/apps/launcher/CMakeLists.txt @@ -93,7 +93,7 @@ if(USE_QT) set_property(TARGET openmw-launcher PROPERTY AUTOMOC ON) endif(USE_QT) -if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) +if (MSVC) target_precompile_headers(openmw-launcher PRIVATE diff --git a/apps/mwiniimporter/CMakeLists.txt b/apps/mwiniimporter/CMakeLists.txt index c2329941c0..704393cd0d 100644 --- a/apps/mwiniimporter/CMakeLists.txt +++ b/apps/mwiniimporter/CMakeLists.txt @@ -33,7 +33,7 @@ if (BUILD_WITH_CODE_COVERAGE) target_link_libraries(openmw-iniimporter gcov) endif() -if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) +if (MSVC) target_precompile_headers(openmw-iniimporter PRIVATE diff --git a/apps/navmeshtool/CMakeLists.txt b/apps/navmeshtool/CMakeLists.txt index 09d7af3b23..9abd8dc283 100644 --- a/apps/navmeshtool/CMakeLists.txt +++ b/apps/navmeshtool/CMakeLists.txt @@ -21,7 +21,7 @@ if (WIN32) install(TARGETS openmw-navmeshtool RUNTIME DESTINATION ".") endif() -if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) +if (MSVC) target_precompile_headers(openmw-navmeshtool PRIVATE diff --git a/apps/niftest/CMakeLists.txt b/apps/niftest/CMakeLists.txt index 5ca21c10c7..f112e087e3 100644 --- a/apps/niftest/CMakeLists.txt +++ b/apps/niftest/CMakeLists.txt @@ -17,6 +17,6 @@ if (BUILD_WITH_CODE_COVERAGE) target_link_libraries(niftest gcov) endif() -if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) +if (MSVC) target_precompile_headers(niftest PRIVATE ) endif() diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 83f8cea168..20bd62d145 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -290,7 +290,7 @@ if (BUILD_WITH_CODE_COVERAGE) target_link_libraries(openmw-cs-lib gcov) endif() -if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) +if (MSVC) target_precompile_headers(openmw-cs-lib PRIVATE diff --git a/apps/opencs_tests/CMakeLists.txt b/apps/opencs_tests/CMakeLists.txt index 5d76dc2032..2b7309f8b9 100644 --- a/apps/opencs_tests/CMakeLists.txt +++ b/apps/opencs_tests/CMakeLists.txt @@ -26,7 +26,7 @@ if (BUILD_WITH_CODE_COVERAGE) target_link_libraries(openmw-cs-tests PRIVATE gcov) endif() -if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) +if (MSVC) target_precompile_headers(openmw-cs-tests PRIVATE ) diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 967ed11aad..44561446df 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -156,7 +156,7 @@ target_link_libraries(openmw components ) -if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) +if (MSVC) target_precompile_headers(openmw PRIVATE diff --git a/apps/openmw_test_suite/CMakeLists.txt b/apps/openmw_test_suite/CMakeLists.txt index 9f4df61368..eb9c0be15d 100644 --- a/apps/openmw_test_suite/CMakeLists.txt +++ b/apps/openmw_test_suite/CMakeLists.txt @@ -118,7 +118,7 @@ target_compile_definitions(openmw_test_suite PRIVATE OPENMW_DATA_DIR=u8"${CMAKE_CURRENT_BINARY_DIR}/data" OPENMW_PROJECT_SOURCE_DIR=u8"${PROJECT_SOURCE_DIR}") -if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) +if (MSVC) target_precompile_headers(openmw_test_suite PRIVATE diff --git a/cmake/OpenMWMacros.cmake b/cmake/OpenMWMacros.cmake index 991125526d..0561fcefd7 100644 --- a/cmake/OpenMWMacros.cmake +++ b/cmake/OpenMWMacros.cmake @@ -132,21 +132,16 @@ macro (openmw_add_executable target) add_executable(${target} ${OMW_ADD_EXE_WIN32_VALUE} ${OMW_ADD_EXE_MACOSX_BUNDLE_VALUE} ${OMW_ADD_EXE_EXCLUDE_FROM_ALL_VALUE} ${OMW_ADD_EXE_UNPARSED_ARGUMENTS}) if (MSVC) - if (CMAKE_VERSION VERSION_GREATER 3.8 OR CMAKE_VERSION VERSION_EQUAL 3.8) - set_target_properties(${target} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "$") - endif (CMAKE_VERSION VERSION_GREATER 3.8 OR CMAKE_VERSION VERSION_EQUAL 3.8) + set_target_properties(${target} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "$") endif (MSVC) endmacro (openmw_add_executable) macro (get_generator_is_multi_config VALUE) + # TODO: make git version getter less dumb so everywhere that calls this macro can just call the function this calls instead if (DEFINED generator_is_multi_config_var) set(${VALUE} ${generator_is_multi_config_var}) else (DEFINED generator_is_multi_config_var) - if (CMAKE_VERSION VERSION_GREATER 3.9 OR CMAKE_VERSION VERSION_EQUAL 3.9) - get_cmake_property(${VALUE} GENERATOR_IS_MULTI_CONFIG) - else (CMAKE_VERSION VERSION_GREATER 3.9 OR CMAKE_VERSION VERSION_EQUAL 3.9) - list(LENGTH CMAKE_CONFIGURATION_TYPES ${VALUE}) - endif (CMAKE_VERSION VERSION_GREATER 3.9 OR CMAKE_VERSION VERSION_EQUAL 3.9) + get_cmake_property(${VALUE} GENERATOR_IS_MULTI_CONFIG) endif (DEFINED generator_is_multi_config_var) endmacro (get_generator_is_multi_config) diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index f64f41b198..cb3b74dc8b 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -614,7 +614,7 @@ if(USE_QT) set_property(TARGET components_qt PROPERTY AUTOMOC ON) endif(USE_QT) -if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) +if (MSVC) target_precompile_headers(components PUBLIC diff --git a/extern/Base64/CMakeLists.txt b/extern/Base64/CMakeLists.txt index 4430d7648e..94992a22b5 100644 --- a/extern/Base64/CMakeLists.txt +++ b/extern/Base64/CMakeLists.txt @@ -1,6 +1,6 @@ add_library(Base64 INTERFACE) target_include_directories(Base64 INTERFACE .) -if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) +if (MSVC) target_precompile_headers(Base64 INTERFACE ) endif() diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index 33908c8caf..f3da3c4b25 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -18,7 +18,6 @@ macro(FetchContent_MakeAvailableExcludeFromAll) endmacro() if(NOT OPENMW_USE_SYSTEM_BULLET) - cmake_minimum_required(VERSION 3.11) # for FetchContent set(BUILD_BULLET3 OFF CACHE BOOL "") set(BUILD_EXTRAS OFF CACHE BOOL "") @@ -63,7 +62,6 @@ if(NOT OPENMW_USE_SYSTEM_BULLET) endif() if(NOT OPENMW_USE_SYSTEM_MYGUI) - cmake_minimum_required(VERSION 3.11) # for FetchContent set(MYGUI_RENDERSYSTEM 4 CACHE STRING "") set(MYGUI_DISABLE_PLUGINS TRUE CACHE BOOL "") @@ -95,7 +93,6 @@ if(NOT OPENMW_USE_SYSTEM_MYGUI) endif() if(NOT OPENMW_USE_SYSTEM_OSG) - cmake_minimum_required(VERSION 3.11) # for FetchContent set(BUILD_OSG_APPLICATIONS OFF CACHE BOOL "") set(BUILD_OSG_DEPRECATED_SERIALIZERS OFF CACHE BOOL "") @@ -213,7 +210,6 @@ endif() add_subdirectory(smhasher) if (BUILD_BENCHMARKS AND NOT OPENMW_USE_SYSTEM_BENCHMARK) - cmake_minimum_required(VERSION 3.11) set(BENCHMARK_ENABLE_TESTING OFF) set(BENCHMARK_ENABLE_INSTALL OFF) @@ -243,7 +239,7 @@ if (NOT OPENMW_USE_SYSTEM_YAML_CPP) ) FetchContent_MakeAvailableExcludeFromAll(yaml-cpp) - if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) + if (MSVC) target_precompile_headers(yaml-cpp PRIVATE ) endif() endif() @@ -304,7 +300,6 @@ if (NOT OPENMW_USE_SYSTEM_ICU) endif() if ((BUILD_UNITTESTS OR BUILD_OPENCS_TESTS) AND NOT OPENMW_USE_SYSTEM_GOOGLETEST) - cmake_minimum_required(VERSION 3.11) include(FetchContent) FetchContent_Declare(googletest diff --git a/extern/oics/CMakeLists.txt b/extern/oics/CMakeLists.txt index 585df5dd41..1b9fea9217 100644 --- a/extern/oics/CMakeLists.txt +++ b/extern/oics/CMakeLists.txt @@ -20,6 +20,6 @@ else() target_link_libraries(oics local_tinyxml) endif() -if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) +if (MSVC) target_precompile_headers(oics PUBLIC ) endif() diff --git a/extern/osg-ffmpeg-videoplayer/CMakeLists.txt b/extern/osg-ffmpeg-videoplayer/CMakeLists.txt index 1bbe672d78..7e2712f19b 100644 --- a/extern/osg-ffmpeg-videoplayer/CMakeLists.txt +++ b/extern/osg-ffmpeg-videoplayer/CMakeLists.txt @@ -17,7 +17,7 @@ target_link_libraries(${OSG_FFMPEG_VIDEOPLAYER_LIBRARY} ${OSG_LIBRARIES}) link_directories(${CMAKE_CURRENT_BINARY_DIR}) -if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) +if (MSVC) target_precompile_headers(${OSG_FFMPEG_VIDEOPLAYER_LIBRARY} PUBLIC