From 8b7bba682cdc1ce2ae1e99377f3cc36d06ba58bf Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Fri, 31 Jan 2020 23:24:22 +0100 Subject: [PATCH 1/2] Compatibility with CMake 3.5 --- CMakeLists.txt | 5 ++++- cmake/CheckIPO.cmake | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d61b3229..3bc982a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,10 @@ if(WIN32) cmake_minimum_required (VERSION 3.15) cmake_policy(SET CMP0091 NEW) else() -cmake_minimum_required (VERSION 3.11) +cmake_minimum_required (VERSION 3.5) +if (POLICY CMP0069) + cmake_policy(SET CMP0069 NEW) +endif() endif() project (sfizz VERSION 0.2.0 LANGUAGES CXX C) set(PROJECT_DESCRIPTION "A library to load SFZ description files and use them to render music.") diff --git a/cmake/CheckIPO.cmake b/cmake/CheckIPO.cmake index c86d3c04..5b524df7 100644 --- a/cmake/CheckIPO.cmake +++ b/cmake/CheckIPO.cmake @@ -1,9 +1,21 @@ # Added in CMake 3.9 + +if (CMAKE_VERSION VERSION_LESS 3.9) + message (WARNING "\nIPO checks are only available on CMake 3.9 and later.") + + set(ENABLE_LTO OFF CACHE BOOL "" FORCE) + + function (SFIZZ_ENABLE_LTO_IF_NEEDED TARGET) + endfunction() + + return() +endif() + include (CheckIPOSupported) check_ipo_supported (RESULT result OUTPUT output) if (CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l) - set(ENABLE_LTO OFF) + set(ENABLE_LTO OFF CACHE BOOL "" FORCE) endif() if (result AND ENABLE_LTO AND CMAKE_BUILD_TYPE STREQUAL "Release") @@ -14,7 +26,7 @@ else() else() message (WARNING "\nIPO was disabled or not in a Release build.") endif() - set (ENABLE_LTO OFF) + set(ENABLE_LTO OFF CACHE BOOL "" FORCE) endif() function (SFIZZ_ENABLE_LTO_IF_NEEDED TARGET) From 4be918e50ff22ea669e2aa9a43d863519e3e15cb Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Fri, 31 Jan 2020 23:30:51 +0100 Subject: [PATCH 2/2] Add a forgotten condition with USE_LIBCPP --- cmake/SfizzConfig.cmake | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cmake/SfizzConfig.cmake b/cmake/SfizzConfig.cmake index afa43821..db138080 100644 --- a/cmake/SfizzConfig.cmake +++ b/cmake/SfizzConfig.cmake @@ -43,10 +43,12 @@ endfunction(SFIZZ_LINK_LIBSNDFILE) # If we build with Clang use libc++ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT ANDROID) set(USE_LIBCPP ON CACHE BOOL "Use libc++ with clang") - add_compile_options(-stdlib=libc++) - # Presumably need the above for linking too, maybe other options missing as well - add_link_options(-stdlib=libc++) # New command on CMake master, not in 3.12 release - add_link_options(-lc++abi) # New command on CMake master, not in 3.12 release + if (USE_LIBCPP) + add_compile_options(-stdlib=libc++) + # Presumably need the above for linking too, maybe other options missing as well + add_link_options(-stdlib=libc++) # New command on CMake master, not in 3.12 release + add_link_options(-lc++abi) # New command on CMake master, not in 3.12 release + endif() endif() # Don't show build information when building a different project