Skip to content

Commit

Permalink
CMakeLists: drop CMAKE_MINIMUM_VERSION to 3.6
Browse files Browse the repository at this point in the history
While we do need the compiler to support C++17 features, we can
get by on older GCC using CMake 3.6 and -std=c++-1z with some
other fixes.

CMAKE_CXX_STANDARD can be raised intelligently to 17 based on
whether we detect CMake 3.8 or higher.
  • Loading branch information
qyot27 committed Dec 1, 2021
1 parent 56af721 commit 1d43f4f
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 30 deletions.
19 changes: 16 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# We need CMake 3.8 at least, because we require
# CMAKE_CXX_STANDARD to be set to C++17.
# Visual Studio 2019 is supported from CMake 3.14.1

# Tested generators:
Expand Down Expand Up @@ -42,7 +40,7 @@

# "Visual Studio 16 2019" + LLVM 8.0 (clang) optional platform generator Win32 and x64

CMAKE_MINIMUM_REQUIRED( VERSION 3.8.2 )
CMAKE_MINIMUM_REQUIRED( VERSION 3.6.2 )
# VS2019: 3.14.1
# Intel 2021: 3.20

Expand Down Expand Up @@ -84,9 +82,11 @@ if(NOT HEADERS_ONLY)
set(CMAKE_CXX_STANDARD_LIBRARIES "" CACHE STRING "" FORCE)

# We require C++17 or higher.
if(CMAKE_VERSION VERSION_GREATER 3.7)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_EXTENSIONS FALSE)
endif()

# Detect Intel processors and turn Intel SIMD on or off automatically.
message("-- Detected target processor as: ${CMAKE_SYSTEM_PROCESSOR}")
Expand Down Expand Up @@ -305,6 +305,19 @@ if(NOT HEADERS_ONLY)

ELSE()
# not MS Visual Studio IDE

# CMAKE_CXX_STANDARD doesn't cover the use-case of pre-final C++17 support,
# but I'd assume most setups with a new enough version of CMake to use
# CMAKE_CXX_STANDARD 17 would also be running a version of GCC/Clang new enough
# to not need this. So this will most likely only ever be used by setups running
# older versions of CMake; regardless, it shouldn't be necessary to force a
# CMAKE_VERSION check on this part unless the mere presence of CMAKE_CXX_STANDARD 17
# ends up causing problems for the older compilers here.
if( ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8)) OR
((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5)) )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z" )
endif()

if(ENABLE_INTEL_SIMD)
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2 -DINTEL_INTRINSICS" )
endif()
Expand Down
4 changes: 1 addition & 3 deletions avs_core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# We need CMake 3.8 at least, because we require
# CMAKE_CXX_STANDARD to be set to C++17.
CMAKE_MINIMUM_REQUIRED( VERSION 3.8.2 )
CMAKE_MINIMUM_REQUIRED( VERSION 3.6.2 )

if (WIN32)
set(CoreName "AviSynth")
Expand Down
4 changes: 1 addition & 3 deletions plugins/ConvertStacked/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# We need CMake 3.8 at least, because we require
# CMAKE_CXX_STANDARD to be set to C++17.
CMAKE_MINIMUM_REQUIRED( VERSION 3.8.2 )
CMAKE_MINIMUM_REQUIRED( VERSION 3.6.2 )

set(PluginName "ConvertStacked")
set(ProjectName "Plugin${PluginName}")
Expand Down
4 changes: 1 addition & 3 deletions plugins/DirectShowSource/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# We need CMake 3.8 at least, because we require
# CMAKE_CXX_STANDARD to be set to C++17.
CMAKE_MINIMUM_REQUIRED( VERSION 3.8.2 )
CMAKE_MINIMUM_REQUIRED( VERSION 3.6.2 )

set(PluginName "DirectShowSource")
set(ProjectName "Plugin${PluginName}")
Expand Down
4 changes: 1 addition & 3 deletions plugins/ImageSeq/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# We need CMake 3.8 at least, because we require
# CMAKE_CXX_STANDARD to be set to C++17.
CMAKE_MINIMUM_REQUIRED( VERSION 3.8.2 )
CMAKE_MINIMUM_REQUIRED( VERSION 3.6.2 )

set(PluginName "ImageSeq")
set(ProjectName "Plugin${PluginName}")
Expand Down
4 changes: 1 addition & 3 deletions plugins/Shibatch/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# We need CMake 3.8 at least, because we require
# CMAKE_CXX_STANDARD to be set to C++17.
CMAKE_MINIMUM_REQUIRED( VERSION 3.8.2 )
CMAKE_MINIMUM_REQUIRED( VERSION 3.6.2 )

set(PluginName "Shibatch")
set(ProjectName "Plugin${PluginName}")
Expand Down
4 changes: 1 addition & 3 deletions plugins/TimeStretch/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# We need CMake 3.8 at least, because we require
# CMAKE_CXX_STANDARD to be set to C++17.
CMAKE_MINIMUM_REQUIRED( VERSION 3.8.2 )
CMAKE_MINIMUM_REQUIRED( VERSION 3.6.2 )

set(PluginName "TimeStretch")
set(ProjectName "Plugin${PluginName}")
Expand Down
4 changes: 1 addition & 3 deletions plugins/TimeStretch/SoundTouch/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# We need CMake 3.8 at least, because we require
# CMAKE_CXX_STANDARD to be set to C++17.
CMAKE_MINIMUM_REQUIRED( VERSION 3.8.2 )
CMAKE_MINIMUM_REQUIRED( VERSION 3.6.2 )

# Find all the input files
FILE(GLOB SoundTouch_Sources RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
Expand Down
4 changes: 1 addition & 3 deletions plugins/VDubFilter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# We need CMake 3.8 at least, because we require
# CMAKE_CXX_STANDARD to be set to C++17.
CMAKE_MINIMUM_REQUIRED( VERSION 3.8.2 )
CMAKE_MINIMUM_REQUIRED( VERSION 3.6.2 )

set(PluginName "VDubFilter")
set(ProjectName "Plugin${PluginName}")
Expand Down
4 changes: 1 addition & 3 deletions plugins/VFAPIFilter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# We need CMake 3.8 at least, because we require
# CMAKE_CXX_STANDARD to be set to C++17.
CMAKE_MINIMUM_REQUIRED( VERSION 3.8.2 )
CMAKE_MINIMUM_REQUIRED( VERSION 3.6.2 )

set(PluginName "VFAPIFilter")
set(ProjectName "Plugin${PluginName}")
Expand Down

0 comments on commit 1d43f4f

Please sign in to comment.