Add a "IGNORE_MINIMAL_COMPILER_VERSION" option to the CMakeLists.txt file
Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
parent
27c8b642d6
commit
b96b487882
|
@ -33,6 +33,7 @@ set(CMAKE_CXX_FLAGS_RELEASE "-Os")
|
||||||
set(MINIMAL_GNU "11.0")
|
set(MINIMAL_GNU "11.0")
|
||||||
set(MINIMAL_CLANG "14.0.1")
|
set(MINIMAL_CLANG "14.0.1")
|
||||||
set(MINIMAL_MSVC "19.30")
|
set(MINIMAL_MSVC "19.30")
|
||||||
|
option(IGNORE_MINIMAL_COMPILER_VERSION "Whether or not to ignore the minimal compiler versions")
|
||||||
set(IS_GNU (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU))
|
set(IS_GNU (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU))
|
||||||
set(IS_CLANG (${CMAKE_CXX_COMPILER_ID} STREQUAL Clang))
|
set(IS_CLANG (${CMAKE_CXX_COMPILER_ID} STREQUAL Clang))
|
||||||
|
|
||||||
|
@ -78,7 +79,7 @@ include(CheckIPOSupported)
|
||||||
check_ipo_supported(RESULT CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE LANGUAGES CXX)
|
check_ipo_supported(RESULT CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE LANGUAGES CXX)
|
||||||
|
|
||||||
if (${IS_GNU})
|
if (${IS_GNU})
|
||||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${MINIMAL_GNU})
|
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${MINIMAL_GNU} AND NOT ${IGNORE_MINIMAL_COMPILER_VERSION})
|
||||||
message(FATAL_ERROR "G++ ${MINIMAL_GNU} or higher is required.")
|
message(FATAL_ERROR "G++ ${MINIMAL_GNU} or higher is required.")
|
||||||
endif()
|
endif()
|
||||||
if (Threads_FOUND)
|
if (Threads_FOUND)
|
||||||
|
@ -89,7 +90,7 @@ if (${IS_GNU})
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "-fwhole-program ${CMAKE_CXX_FLAGS_RELEASE}")
|
set(CMAKE_CXX_FLAGS_RELEASE "-fwhole-program ${CMAKE_CXX_FLAGS_RELEASE}")
|
||||||
endif()
|
endif()
|
||||||
elseif(${IS_CLANG})
|
elseif(${IS_CLANG})
|
||||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${MINIMAL_CLANG})
|
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${MINIMAL_CLANG} AND NOT ${IGNORE_MINIMAL_COMPILER_VERSION})
|
||||||
message(FATAL_ERROR "Clang ${MINIMAL_CLANG} or higher is required.")
|
message(FATAL_ERROR "Clang ${MINIMAL_CLANG} or higher is required.")
|
||||||
endif()
|
endif()
|
||||||
if (${CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE} OR MINGW) # CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE is false on llvm-mingw toolchains even though it is supported
|
if (${CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE} OR MINGW) # CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE is false on llvm-mingw toolchains even though it is supported
|
||||||
|
@ -100,7 +101,7 @@ elseif(${IS_CLANG})
|
||||||
endif()
|
endif()
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fstrict-vtable-pointers")
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fstrict-vtable-pointers")
|
||||||
elseif(MSVC)
|
elseif(MSVC)
|
||||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${MINIMAL_MSVC})
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${MINIMAL_MSVC} AND NOT ${IGNORE_MINIMAL_COMPILER_VERSION})
|
||||||
message(FATAL_ERROR "MSVC ${MINIMAL_MSVC} or higher is required")
|
message(FATAL_ERROR "MSVC ${MINIMAL_MSVC} or higher is required")
|
||||||
endif()
|
endif()
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR /W3 /Zc:__cplusplus /Zc:preprocessor /Zc:throwingNew /Zc:inline")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR /W3 /Zc:__cplusplus /Zc:preprocessor /Zc:throwingNew /Zc:inline")
|
||||||
|
|
Loading…
Reference in New Issue