@@ -27,18 +27,16 @@ include("cmake/utils.cmake")
27
27
# The flags that can be used for the main and host compilers should be moved to
28
28
# the macros to avoid code duplication and ensure consistency.
29
29
macro (sdl_unix_common_ccxx_flags var)
30
- test_compiler_and_add_flag("-fPIC" ${var} )
31
- test_compiler_and_add_flag("-Wformat" ${var} )
32
- test_compiler_and_add_flag("-Wformat-security" ${var} )
30
+ append (${var} "-fPIC -Wformat -Wformat-security" )
33
31
endmacro ()
34
32
35
33
macro (sdl_gnu_common_ccxx_flags var gnu_version)
36
34
if (${gnu_version} VERSION_LESS 4.9)
37
- test_compiler_and_add_flag( "-fstack-protector-all" ${var} )
35
+ append ( ${var} "-fstack-protector-all" )
38
36
else ()
39
- test_compiler_and_add_flag( "-fstack-protector-strong" ${var} )
37
+ append ( ${var} "-fstack-protector-strong" )
40
38
if (NOT (${gnu_version} VERSION_LESS 8.0) AND (DNNL_TARGET_ARCH STREQUAL "X64" ))
41
- test_compiler_and_add_flag( "-fcf-protection=full" ${var} )
39
+ append ( ${var} "-fcf-protection=full" )
42
40
endif ()
43
41
endif ()
44
42
endmacro ()
@@ -50,7 +48,7 @@ endmacro()
50
48
# this warning on, let's use it too. Applicable for the library sources
51
49
# and interfaces only (tests currently rely on that fact heavily)
52
50
macro (sdl_gnu_src_ccxx_flags var)
53
- test_compiler_and_add_flag( "-Wmissing-field-initializers" ${var} )
51
+ append ( ${var} "-Wmissing-field-initializers" )
54
52
endmacro ()
55
53
56
54
macro (sdl_gnu_example_ccxx_flags var)
@@ -64,7 +62,7 @@ set(ONEDNN_SDL_LINKER_FLAGS)
64
62
if (UNIX )
65
63
sdl_unix_common_ccxx_flags(ONEDNN_SDL_COMPILER_FLAGS)
66
64
if (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL "RELEASE" )
67
- test_compiler_and_add_flag( "-D_FORTIFY_SOURCE=2" ONEDNN_SDL_COMPILER_FLAGS )
65
+ append (ONEDNN_SDL_COMPILER_FLAGS "-D_FORTIFY_SOURCE=2" )
68
66
endif ()
69
67
if ("${CMAKE_CXX_COMPILER_ID} " STREQUAL "GNU" )
70
68
sdl_gnu_common_ccxx_flags(ONEDNN_SDL_COMPILER_FLAGS CMAKE_CXX_COMPILER_VERSION)
@@ -74,10 +72,10 @@ if(UNIX)
74
72
get_filename_component (CXX_CMD_NAME ${CMAKE_CXX_COMPILER} NAME )
75
73
# Fujitsu CXX compiler does not support "-fstack-protector-all".
76
74
if (NOT CXX_CMD_NAME STREQUAL "FCC" )
77
- test_compiler_and_add_flag( "-fstack-protector-all" ONEDNN_SDL_COMPILER_FLAGS )
75
+ append (ONEDNN_SDL_COMPILER_FLAGS "-fstack-protector-all" )
78
76
endif ()
79
77
elseif ("${CMAKE_CXX_COMPILER_ID} " STREQUAL "Intel" )
80
- test_compiler_and_add_flag( "-fstack-protector" ONEDNN_SDL_COMPILER_FLAGS )
78
+ append (ONEDNN_SDL_COMPILER_FLAGS "-fstack-protector" )
81
79
endif ()
82
80
if (APPLE )
83
81
append (ONEDNN_SDL_LINKER_FLAGS "-Wl,-bind_at_load" )
@@ -88,29 +86,20 @@ if(UNIX)
88
86
endif ()
89
87
elseif (WIN32 )
90
88
if ("${CMAKE_CXX_COMPILER_ID} " STREQUAL "MSVC" )
91
- test_compiler_and_add_flag("/GS" ONEDNN_SDL_COMPILER_FLAGS)
92
- test_compiler_and_add_flag("/Gy" ONEDNN_SDL_COMPILER_FLAGS)
93
- test_compiler_and_add_flag("/guard:cf" ONEDNN_SDL_COMPILER_FLAGS)
94
- test_compiler_and_add_flag("/DYNAMICBASE" ONEDNN_SDL_COMPILER_FLAGS)
95
- test_compiler_and_add_flag("/sdl" ONEDNN_SDL_COMPILER_FLAGS)
89
+ append (ONEDNN_SDL_COMPILER_FLAGS "/GS /Gy /guard:cf /DYNAMICBASE /sdl" )
96
90
append (ONEDNN_SDL_LINKER_FLAGS "/NXCOMPAT /LTCG" )
97
91
elseif (CMAKE_BASE_NAME STREQUAL "icx" )
98
- test_compiler_and_add_flag("/GS" ONEDNN_SDL_COMPILER_FLAGS)
99
- test_compiler_and_add_flag("/Gy" ONEDNN_SDL_COMPILER_FLAGS)
100
- test_compiler_and_add_flag("/guard:cf" ONEDNN_SDL_COMPILER_FLAGS)
101
- test_compiler_and_add_flag("/Wformat" ONEDNN_SDL_COMPILER_FLAGS)
102
- test_compiler_and_add_flag("/Wformat-security" ONEDNN_SDL_COMPILER_FLAGS)
92
+ append (ONEDNN_SDL_COMPILER_FLAGS "/GS /Gy /guard:cf /Wformat /Wformat-security" )
103
93
append (ONEDNN_SDL_LINKER_FLAGS "/link /NXCOMPAT" )
104
94
elseif ("${CMAKE_CXX_COMPILER_ID} " STREQUAL "Clang" )
105
- test_compiler_and_add_flag("-Wformat" ONEDNN_SDL_COMPILER_FLAGS)
106
- test_compiler_and_add_flag("-Wformat-security" ONEDNN_SDL_COMPILER_FLAGS)
95
+ append (ONEDNN_SDL_COMPILER_FLAGS "-Wformat -Wformat-security" )
107
96
if (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL "RELEASE" )
108
- test_compiler_and_add_flag( "-D_FORTIFY_SOURCE=2" ONEDNN_SDL_COMPILER_FLAGS )
97
+ append (ONEDNN_SDL_COMPILER_FLAGS "-D_FORTIFY_SOURCE=2" )
109
98
endif ()
110
99
get_filename_component (CXX_CMD_NAME ${CMAKE_CXX_COMPILER} NAME )
111
100
# Fujitsu CXX compiler does not support "-fstack-protector-all".
112
101
if (NOT CXX_CMD_NAME STREQUAL "FCC" )
113
- test_compiler_and_add_flag( "-fstack-protector-all" ONEDNN_SDL_COMPILER_FLAGS )
102
+ append (ONEDNN_SDL_COMPILER_FLAGS "-fstack-protector-all" )
114
103
endif ()
115
104
append (ONEDNN_SDL_LINKER_FLAGS "-Xlinker /NXCOMPAT -Xlinker /LTCG" )
116
105
endif ()
0 commit comments