-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simplify cmake compiler version detection
- Loading branch information
1 parent
033955b
commit 543aea2
Showing
5 changed files
with
25 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
cmake_minimum_required(VERSION 3.13) | ||
|
||
cmake_policy(SET CMP0028 NEW) # Double colon in target name means ALIAS or IMPORTED target. | ||
cmake_policy(SET CMP0048 NEW) # The ``project()`` command manages VERSION variables. | ||
|
@@ -46,42 +46,13 @@ if(USE_CCACHE) | |
endif() | ||
endif() | ||
|
||
# TODO: check that 'decltype' compiles | ||
# TODO: check that 'constexpr' compiles | ||
if(NOT Vc_COMPILER_IS_MSVC) # MSVC doesn't provide a switch to turn C++11 on/off AFAIK | ||
AddCompilerFlag("-std=c++14" CXX_RESULT _ok CXX_FLAGS CMAKE_CXX_FLAGS) | ||
if(NOT _ok) | ||
AddCompilerFlag("-std=c++1y" CXX_RESULT _ok CXX_FLAGS CMAKE_CXX_FLAGS) | ||
if(NOT _ok) | ||
AddCompilerFlag("-std=c++11" CXX_RESULT _ok CXX_FLAGS CMAKE_CXX_FLAGS) | ||
if(NOT _ok) | ||
AddCompilerFlag("-std=c++0x" CXX_RESULT _ok CXX_FLAGS CMAKE_CXX_FLAGS) | ||
if(NOT _ok) | ||
message(FATAL_ERROR "Vc 1.x requires C++11, better even C++14. It seems this is not available. If this was incorrectly determined please notify [email protected]") | ||
endif() | ||
endif() | ||
endif() | ||
endif() | ||
elseif(MSVC_VERSION LESS 1900) | ||
message(FATAL_ERROR "Vc 1.x requires at least Visual Studio 2015.") | ||
endif() | ||
|
||
if(Vc_COMPILER_IS_GCC) | ||
if(Vc_GCC_VERSION VERSION_GREATER "5.0.0" AND Vc_GCC_VERSION VERSION_LESS "6.0.0") | ||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "5.0.0" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0.0") | ||
UserWarning("GCC 5 goes into an endless loop comiling example_scaling_scalar. Therefore, this target is disabled.") | ||
list(APPEND disabled_targets | ||
example_scaling_scalar | ||
) | ||
list(APPEND disabled_targets example_scaling_scalar) | ||
endif() | ||
elseif(Vc_COMPILER_IS_MSVC) | ||
if(MSVC_VERSION LESS 1700) | ||
# MSVC before 2012 has a broken std::vector::resize implementation. STL + Vc code will probably not compile. | ||
# UserWarning in VcMacros.cmake | ||
list(APPEND disabled_targets | ||
stlcontainer_sse | ||
stlcontainer_avx | ||
) | ||
endif() | ||
# Disable warning "C++ exception specification ignored except to indicate a function is not __declspec(nothrow)" | ||
# MSVC emits the warning for the _UnitTest_Compare desctructor which needs the throw declaration so that it doesn't std::terminate | ||
AddCompilerFlag("/wd4290") | ||
|
@@ -97,10 +68,6 @@ if(Vc_COMPILER_IS_INTEL) | |
AddCompilerFlag("-fp-model source") | ||
endif() | ||
|
||
if(CMAKE_BUILD_TYPE STREQUAL "" AND NOT CMAKE_CXX_FLAGS MATCHES "-O[123]") | ||
message(STATUS "WARNING! It seems you are compiling without optimization. Please set CMAKE_BUILD_TYPE.") | ||
endif(CMAKE_BUILD_TYPE STREQUAL "" AND NOT CMAKE_CXX_FLAGS MATCHES "-O[123]") | ||
|
||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}) # ${CMAKE_CURRENT_SOURCE_DIR}/include) | ||
|
||
add_custom_target(other VERBATIM) | ||
|
@@ -129,6 +96,7 @@ else() | |
list(APPEND _srcs src/support_dummy.cpp) | ||
endif() | ||
add_library(Vc STATIC ${_srcs}) | ||
target_compile_features(Vc PUBLIC cxx_std_11) | ||
set_property(TARGET Vc APPEND PROPERTY COMPILE_OPTIONS ${libvc_compile_flags}) | ||
add_target_property(Vc LABELS "other") | ||
if(XCODE) | ||
|
@@ -245,12 +213,12 @@ configure_file(${PROJECT_SOURCE_DIR}/CTestCustom.cmake ${PROJECT_BINARY_DIR}/CTe | |
if(BUILD_TESTING) | ||
add_custom_target(build_tests ALL VERBATIM) | ||
add_subdirectory(tests) | ||
endif(BUILD_TESTING) | ||
endif() | ||
|
||
set(BUILD_EXAMPLES FALSE CACHE BOOL "Build examples.") | ||
if(BUILD_EXAMPLES) | ||
add_subdirectory(examples) | ||
endif(BUILD_EXAMPLES) | ||
endif() | ||
|
||
# Hide Vc_IMPL as it is only meant for users of Vc | ||
mark_as_advanced(Vc_IMPL) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters