@@ -26,30 +26,16 @@ option(BUILD_SHARED_LIBS "Build shared library and only the shared library if \"
26
26
# Basic set
27
27
set (LTM_C_FLAGS -Wall -Wsign-compare -Wextra -Wshadow)
28
28
set (LTM_C_FLAGS ${LTM_C_FLAGS} -Wdeclaration-after-statement -Wbad-function-cast -Wcast-align)
29
- set (LTM_C_FLAGS ${LTM_C_FLAGS} -Wstrict-prototypes -Wpointer-arith)
29
+ set (LTM_C_FLAGS ${LTM_C_FLAGS} -Wstrict-prototypes -Wpointer-arith -Wsystem-headers )
30
30
31
- # Do we run the sanitizer?
32
- if (DEFINED ENV{SANITIZER})
33
- set (LTM_C_FLAGS ${LTM_C_FLAGS} -fsanitize=undefined -fno-sanitize-recover=all -fno-sanitize=float-divide-by-zero)
34
- endif ()
35
-
36
- if (DEFINED ENV{CONV_WARNINGS})
37
- set (LTM_C_FLAGS ${LTM_C_FLAGS} -std=c89 -Wconversion -Wsign-conversion)
38
- if ($ENV{CONV_WARNINGS} EQUAL "strict" )
39
- set (LTM_C_FLAGS ${LTM_C_FLAGS} -Wc++-compat)
40
- endif ()
41
- else ()
42
- set (LTM_C_FLAGS ${LTM_C_FLAGS} -Wsystem-headers)
43
- endif ()
44
-
45
- if (DEFINED ENV{COMPILE_DEBUG})
31
+ if (COMPILE_DEBUG)
46
32
set (LTM_C_FLAGS ${LTM_C_FLAGS} -g3)
47
33
endif ()
48
34
49
- if (DEFINED ENV{ COMPILE_SIZE} )
35
+ if (COMPILE_SIZE)
50
36
set (LTM_C_FLAGS ${LTM_C_FLAGS} -Os)
51
37
else ()
52
- if (NOT DEFINED ENV{ IGNORE_SPEED} )
38
+ if (NOT IGNORE_SPEED)
53
39
set (LTM_C_FLAGS ${LTM_C_FLAGS} -O3 -funroll-loops)
54
40
#x86 optimizations [should be valid for any GCC install though]
55
41
set (LTM_C_FLAGS ${LTM_C_FLAGS} -fomit-frame-pointer)
@@ -67,33 +53,28 @@ endif()
67
53
68
54
# What compiler do we have and what are their...uhm... peculiarities
69
55
# TODO: is the check for a C++ compiler necessary?
70
- if ( ( CMAKE_C_COMPILER_ID MATCHES "(C|c?)lang" ) OR (CMAKE_CXX_COMPILER_ID MATCHES "(C|c?)lang" ) )
56
+ if (CMAKE_C_COMPILER_ID MATCHES "(C|c?)lang" )
71
57
set (LTM_C_FLAGS ${LTM_C_FLAGS} -Wno-typedef-redefinition -Wno-tautological-compare -Wno-builtin-requires-header)
72
58
endif ()
73
-
74
- if ( (CMAKE_C_COMPILER_ID MATCHES "mingw" ) OR (CMAKE_CXX_COMPILER_ID MATCHES "mingw" ))
59
+ if (CMAKE_C_COMPILER MATCHES "mingw" )
75
60
set (LTM_C_FLAGS ${LTM_C_FLAGS} -Wno-shadow)
76
61
endif ()
77
62
78
- if (DEFINED ENV{PLATFORM})
79
- if ($ENV{PLATFORM} MATCHES "Darwin" )
80
- set (LTM_C_FLAGS ${LTM_C_FLAGS} -Wno-nullability-completeness)
81
- endif ()
82
- if ($ENV{PLATFORM} MATCHES "CYGWIN" )
83
- set (LTM_C_FLAGS ${LTM_C_FLAGS} -no -undefined)
84
- endif ()
63
+ if (CMAKE_SYSTEM_NAME MATCHES "Darwin" )
64
+ set (LTM_C_FLAGS ${LTM_C_FLAGS} -Wno-nullability-completeness)
65
+ endif ()
66
+ if (CMAKE_SYSTEM_NAME MATCHES "CYGWIN" )
67
+ set (LTM_C_FLAGS ${LTM_C_FLAGS} -no -undefined)
85
68
endif ()
86
69
87
70
# TODO: coverage (lgcov)
88
71
89
72
# If the user set the environment variables at generate-time, append them
90
73
# in order to allow overriding our defaults.
91
- if (DEFINED ENV{LTM_CFLAGS})
92
- set (LTM_C_FLAGS ${LTM_C_FLAGS} $ENV{LTM_CFLAGS} )
93
- endif ()
94
- if (DEFINED ENV{LTM_LDFLAGS})
95
- set (LTM_LD_FLAGS ${LTM_LD_FLAGS} $ENV{LTM_LDFLAGS} )
96
- endif ()
74
+ # ${LTM_CFLAGS} means the user passed it via sth like:
75
+ # $ cmake -DLTM_CFLAGS="foo"
76
+ set (LTM_C_FLAGS ${LTM_C_FLAGS} ${LTM_CFLAGS} )
77
+ set (LTM_LD_FLAGS ${LTM_LD_FLAGS} ${LTM_LDFLAGS} )
97
78
98
79
#-----------------------------------------------------------------------------
99
80
# library target
0 commit comments