diff options
author | Michael Hirsch, Ph.D <scivision@users.noreply.github.com> | 2020-03-08 01:56:57 (GMT) |
---|---|---|
committer | Michael Hirsch <scivision@users.noreply.github.com> | 2020-04-06 06:38:13 (GMT) |
commit | 418d59b8a6054ce9ef1a28c07c41d3a0bb386836 (patch) | |
tree | 93ed6821ed596accd5114b3ece35f2256e26dc31 /CMakeLists.txt | |
parent | 8900fa55b56ba1e2f83b3f3ba2a1b336c97e5dc3 (diff) | |
download | Ninja-418d59b8a6054ce9ef1a28c07c41d3a0bb386836.zip Ninja-418d59b8a6054ce9ef1a28c07c41d3a0bb386836.tar.gz Ninja-418d59b8a6054ce9ef1a28c07c41d3a0bb386836.tar.bz2 |
only apply optional flags when compiler works
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f5a588c..007c662 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.15) project(ninja) +# --- optional link-time optimization if(CMAKE_BUILD_TYPE MATCHES "Release") include(CheckIPOSupported) check_ipo_supported(RESULT lto_supported OUTPUT error) @@ -13,13 +14,23 @@ if(CMAKE_BUILD_TYPE MATCHES "Release") endif() endif() +# --- compiler flags if(MSVC) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") string(APPEND CMAKE_CXX_FLAGS " /W4 /GR- /Zc:__cplusplus") else() - string(APPEND CMAKE_CXX_FLAGS " -Wno-deprecated -fdiagnostics-color") + include(CheckCXXCompilerFlag) + check_cxx_compiler_flag(-Wno-deprecated flag_no_deprecated) + if(flag_no_deprecated) + string(APPEND CMAKE_CXX_FLAGS " -Wno-deprecated") + endif() + check_cxx_compiler_flag(-fdiagnostics-color flag_color_diag) + if(flag_color_diag) + string(APPEND CMAKE_CXX_FLAGS " -fdiagnostics-color") + endif() endif() +# --- optional re2c find_program(RE2C re2c) if(RE2C) # the depfile parser and ninja lexers are generated using re2c. |