Warning, /acts/Detray/cmake/detray-compiler-options-cpp.cmake is written in an unsupported language. File is not indexed.
0001 # This file is part of the ACTS project.
0002 #
0003 # Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 #
0005 # This Source Code Form is subject to the terms of the Mozilla Public
0006 # License, v. 2.0. If a copy of the MPL was not distributed with this
0007 # file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008
0009 cmake_minimum_required(VERSION 3.21)
0010
0011 # Only set these compiler flags if we are the top level project.
0012 if(PROJECT_IS_TOP_LEVEL)
0013 # Include the helper function(s).
0014 include(detray-functions)
0015
0016 # Turn on the correct setting for the __cplusplus macro with MSVC.
0017 if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
0018 detray_add_flag(CMAKE_CXX_FLAGS "/Zc:__cplusplus")
0019 endif()
0020
0021 # Respect infinity expressions for IntelLLVM
0022 if("${CMAKE_CXX_COMPILER_ID}" MATCHES "IntelLLVM")
0023 detray_add_flag(CMAKE_CXX_FLAGS "-fhonor-infinities")
0024 endif()
0025
0026 if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
0027 detray_add_flag(CMAKE_CXX_FLAGS "-Wshorten-64-to-32")
0028 endif()
0029
0030 # Turn on a number of warnings for the "known compilers".
0031 if(
0032 ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
0033 OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
0034 OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "IntelLLVM")
0035 )
0036 # Basic flags for all build modes.
0037 detray_add_flag(CMAKE_CXX_FLAGS "-Wall")
0038 detray_add_flag(CMAKE_CXX_FLAGS "-Wextra")
0039 detray_add_flag(CMAKE_CXX_FLAGS "-Wshadow")
0040 detray_add_flag(CMAKE_CXX_FLAGS "-Wunused-local-typedefs")
0041 detray_add_flag(CMAKE_CXX_FLAGS "-Wzero-as-null-pointer-constant")
0042 detray_add_flag(CMAKE_CXX_FLAGS "-Wnull-dereference")
0043 detray_add_flag(CMAKE_CXX_FLAGS "-Wold-style-cast")
0044 detray_add_flag(CMAKE_CXX_FLAGS "-pedantic")
0045 # No implicit single to double conversions from floating point literals
0046 detray_add_flag(CMAKE_CXX_FLAGS "-Wconversion")
0047
0048 # Fail on warnings, if asked for that behaviour.
0049 if(DETRAY_FAIL_ON_WARNINGS)
0050 detray_add_flag(CMAKE_CXX_FLAGS "-Werror")
0051 endif()
0052 elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
0053 # Basic flags for all build modes.
0054 string(REGEX REPLACE "/W[0-9]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
0055 detray_add_flag(CMAKE_CXX_FLAGS "/W4")
0056
0057 # Fail on warnings, if asked for that behaviour.
0058 if(DETRAY_FAIL_ON_WARNINGS)
0059 detray_add_flag(CMAKE_CXX_FLAGS "/WX")
0060 endif()
0061 endif()
0062 endif()