Skip to content

Commit 262fb02

Browse files
committed
revert: build: add check_cxx_compiler_flag for SDL flags
This reverts commit e3782e8.
1 parent 4d962e7 commit 262fb02

File tree

2 files changed

+13
-38
lines changed

2 files changed

+13
-38
lines changed

cmake/SDL.cmake

+13-24
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,16 @@ include("cmake/utils.cmake")
2727
# The flags that can be used for the main and host compilers should be moved to
2828
# the macros to avoid code duplication and ensure consistency.
2929
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")
3331
endmacro()
3432

3533
macro(sdl_gnu_common_ccxx_flags var gnu_version)
3634
if(${gnu_version} VERSION_LESS 4.9)
37-
test_compiler_and_add_flag("-fstack-protector-all" ${var})
35+
append(${var} "-fstack-protector-all")
3836
else()
39-
test_compiler_and_add_flag("-fstack-protector-strong" ${var})
37+
append(${var} "-fstack-protector-strong")
4038
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")
4240
endif()
4341
endif()
4442
endmacro()
@@ -50,7 +48,7 @@ endmacro()
5048
# this warning on, let's use it too. Applicable for the library sources
5149
# and interfaces only (tests currently rely on that fact heavily)
5250
macro(sdl_gnu_src_ccxx_flags var)
53-
test_compiler_and_add_flag("-Wmissing-field-initializers" ${var})
51+
append(${var} "-Wmissing-field-initializers")
5452
endmacro()
5553

5654
macro(sdl_gnu_example_ccxx_flags var)
@@ -64,7 +62,7 @@ set(ONEDNN_SDL_LINKER_FLAGS)
6462
if(UNIX)
6563
sdl_unix_common_ccxx_flags(ONEDNN_SDL_COMPILER_FLAGS)
6664
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")
6866
endif()
6967
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
7068
sdl_gnu_common_ccxx_flags(ONEDNN_SDL_COMPILER_FLAGS CMAKE_CXX_COMPILER_VERSION)
@@ -74,10 +72,10 @@ if(UNIX)
7472
get_filename_component(CXX_CMD_NAME ${CMAKE_CXX_COMPILER} NAME)
7573
# Fujitsu CXX compiler does not support "-fstack-protector-all".
7674
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")
7876
endif()
7977
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")
8179
endif()
8280
if(APPLE)
8381
append(ONEDNN_SDL_LINKER_FLAGS "-Wl,-bind_at_load")
@@ -88,29 +86,20 @@ if(UNIX)
8886
endif()
8987
elseif(WIN32)
9088
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")
9690
append(ONEDNN_SDL_LINKER_FLAGS "/NXCOMPAT /LTCG")
9791
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")
10393
append(ONEDNN_SDL_LINKER_FLAGS "/link /NXCOMPAT")
10494
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")
10796
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")
10998
endif()
11099
get_filename_component(CXX_CMD_NAME ${CMAKE_CXX_COMPILER} NAME)
111100
# Fujitsu CXX compiler does not support "-fstack-protector-all".
112101
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")
114103
endif()
115104
append(ONEDNN_SDL_LINKER_FLAGS "-Xlinker /NXCOMPAT -Xlinker /LTCG")
116105
endif()

cmake/utils.cmake

-14
Original file line numberDiff line numberDiff line change
@@ -174,17 +174,3 @@ function(find_libm var)
174174
find_library(${var} m REQUIRED)
175175
endif()
176176
endfunction()
177-
178-
include(CheckCXXCompilerFlag)
179-
macro(test_compiler_and_add_flag flag var)
180-
set(CMAKE_REQUIRED_QUIET 1)
181-
unset(COMPILER_SUPPORTS_FLAG CACHE)
182-
183-
if(NOT test_compiler_flag_nowarn)
184-
append(CMAKE_REQUIRED_FLAGS "${CMAKE_CCXX_NOWARN_FLAGS}")
185-
set(test_compiler_flag_nowarn true)
186-
endif()
187-
188-
check_cxx_compiler_flag("${flag}" COMPILER_SUPPORTS_FLAG)
189-
append_if(COMPILER_SUPPORTS_FLAG ${var} ${flag})
190-
endmacro()

0 commit comments

Comments
 (0)