-
Notifications
You must be signed in to change notification settings - Fork 18
/
save_flags.cmake
46 lines (37 loc) · 1.35 KB
/
save_flags.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
#.rst:
#
# Take care of updating the cache for fresh configurations.
#
# Variables modified (provided the corresponding language is enabled)::
#
# DEFAULT_Fortran_FLAGS_SET
# DEFAULT_C_FLAGS_SET
# DEFAULT_CXX_FLAGS_SET
macro(save_compiler_flags lang)
if (NOT DEFINED DEFAULT_${lang}_FLAGS_SET)
mark_as_advanced(DEFAULT_${lang}_FLAGS_SET)
set (DEFAULT_${lang}_FLAGS_SET ON
CACHE INTERNAL
"Flag that the default ${lang} compiler flags have been set.")
set(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}"
CACHE STRING
"Flags used by the compiler during all builds." FORCE)
set(CMAKE_${lang}_FLAGS_DEBUG "${CMAKE_${lang}_FLAGS_DEBUG}"
CACHE STRING
"Flags used by the compiler during debug builds." FORCE)
set(CMAKE_${lang}_FLAGS_RELEASE "${CMAKE_${lang}_FLAGS_RELEASE}"
CACHE STRING
"Flags used by the compiler during release builds." FORCE)
endif()
endmacro()
if(DEFINED CMAKE_Fortran_COMPILER_ID)
save_compiler_flags(Fortran)
endif()
if(DEFINED CMAKE_C_COMPILER_ID)
save_compiler_flags(C)
endif()
if(DEFINED CMAKE_CXX_COMPILER_ID)
save_compiler_flags(CXX)
endif()