|
@@ -19,6 +19,13 @@ macro(SDL_DetectCompiler)
|
|
|
endif()
|
|
|
endmacro()
|
|
|
|
|
|
+function(sdl_target_compile_option_all_languages TARGET OPTION)
|
|
|
+ target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:${OPTION}>")
|
|
|
+ if(CMAKE_OBJC_COMPILER)
|
|
|
+ target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:OBJC>:${OPTION}>")
|
|
|
+ endif()
|
|
|
+endfunction()
|
|
|
+
|
|
|
function(SDL_AddCommonCompilerFlags TARGET)
|
|
|
option(SDL_WERROR "Enable -Werror" OFF)
|
|
|
|
|
@@ -41,20 +48,20 @@ function(SDL_AddCommonCompilerFlags TARGET)
|
|
|
if(MSVC_CLANG)
|
|
|
target_compile_options(${TARGET} PRIVATE "/W3")
|
|
|
elseif(HAVE_GCC_WALL)
|
|
|
- target_compile_options(${TARGET} PRIVATE "-Wall")
|
|
|
+ sdl_target_compile_option_all_languages(${TARGET} "-Wall")
|
|
|
if(HAIKU)
|
|
|
- target_compile_options(${TARGET} PRIVATE "-Wno-multichar")
|
|
|
+ sdl_target_compile_option_all_languages(${TARGET} "-Wno-multichar")
|
|
|
endif()
|
|
|
endif()
|
|
|
|
|
|
check_c_compiler_flag(-Wundef HAVE_GCC_WUNDEF)
|
|
|
if(HAVE_GCC_WUNDEF)
|
|
|
- target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:-Wundef>")
|
|
|
+ sdl_target_compile_option_all_languages(${TARGET} "-Wundef")
|
|
|
endif()
|
|
|
|
|
|
check_c_compiler_flag(-fno-strict-aliasing HAVE_GCC_NO_STRICT_ALIASING)
|
|
|
if(HAVE_GCC_NO_STRICT_ALIASING)
|
|
|
- target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:-fno-strict-aliasing>")
|
|
|
+ sdl_target_compile_option_all_languages(${TARGET} "-fno-strict-aliasing")
|
|
|
endif()
|
|
|
|
|
|
check_c_compiler_flag(-Wdocumentation HAVE_GCC_WDOCUMENTATION)
|
|
@@ -62,10 +69,10 @@ function(SDL_AddCommonCompilerFlags TARGET)
|
|
|
if(SDL_WERROR)
|
|
|
check_c_compiler_flag(-Werror=documentation HAVE_GCC_WERROR_DOCUMENTATION)
|
|
|
if(HAVE_GCC_WERROR_DOCUMENTATION)
|
|
|
- target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:-Werror=documentation>")
|
|
|
+ sdl_target_compile_option_all_languages(${TARGET} "-Werror=documentation")
|
|
|
endif()
|
|
|
endif()
|
|
|
- target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:-Wdocumentation>")
|
|
|
+ sdl_target_compile_option_all_languages(${TARGET} "-Wdocumentation")
|
|
|
endif()
|
|
|
|
|
|
check_c_compiler_flag(-Wdocumentation-unknown-command HAVE_GCC_WDOCUMENTATION_UNKNOWN_COMMAND)
|
|
@@ -73,30 +80,30 @@ function(SDL_AddCommonCompilerFlags TARGET)
|
|
|
if(SDL_WERROR)
|
|
|
check_c_compiler_flag(-Werror=documentation-unknown-command HAVE_GCC_WERROR_DOCUMENTATION_UNKNOWN_COMMAND)
|
|
|
if(HAVE_GCC_WERROR_DOCUMENTATION_UNKNOWN_COMMAND)
|
|
|
- target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:-Werror=documentation-unknown-command>")
|
|
|
+ sdl_target_compile_option_all_languages(${TARGET} "-Werror=documentation-unknown-command")
|
|
|
endif()
|
|
|
endif()
|
|
|
- target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:-Wdocumentation-unknown-command>")
|
|
|
+ sdl_target_compile_option_all_languages(${TARGET} "-Wdocumentation-unknown-command")
|
|
|
endif()
|
|
|
|
|
|
check_c_compiler_flag(-fcomment-block-commands=threadsafety HAVE_GCC_COMMENT_BLOCK_COMMANDS)
|
|
|
if(HAVE_GCC_COMMENT_BLOCK_COMMANDS)
|
|
|
- target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:-fcomment-block-commands=threadsafety>")
|
|
|
+ sdl_target_compile_option_all_languages(${TARGET} "-fcomment-block-commands=threadsafety")
|
|
|
else()
|
|
|
check_c_compiler_flag(/clang:-fcomment-block-commands=threadsafety HAVE_CLANG_COMMENT_BLOCK_COMMANDS)
|
|
|
if(HAVE_CLANG_COMMENT_BLOCK_COMMANDS)
|
|
|
- target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:/clang:-fcomment-block-commands=threadsafety>")
|
|
|
+ sdl_target_compile_option_all_languages(${TARGET} "/clang:-fcomment-block-commands=threadsafety")
|
|
|
endif()
|
|
|
endif()
|
|
|
|
|
|
check_c_compiler_flag(-Wshadow HAVE_GCC_WSHADOW)
|
|
|
if(HAVE_GCC_WSHADOW)
|
|
|
- target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:-Wshadow>")
|
|
|
+ sdl_target_compile_option_all_languages(${TARGET} "-Wshadow")
|
|
|
endif()
|
|
|
|
|
|
check_c_compiler_flag(-Wunused-local-typedefs HAVE_GCC_WUNUSED_LOCAL_TYPEDEFS)
|
|
|
if(HAVE_GCC_WUNUSED_LOCAL_TYPEDEFS)
|
|
|
- target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:-Wno-unused-local-typedefs>")
|
|
|
+ sdl_target_compile_option_all_languages(${TARGET} "-Wno-unused-local-typedefs")
|
|
|
endif()
|
|
|
endif()
|
|
|
|
|
@@ -109,7 +116,7 @@ function(SDL_AddCommonCompilerFlags TARGET)
|
|
|
elseif(USE_GCC OR USE_CLANG OR USE_INTELCC OR USE_QNX)
|
|
|
check_c_compiler_flag(-Werror HAVE_WERROR)
|
|
|
if(HAVE_WERROR)
|
|
|
- target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:-Werror>")
|
|
|
+ sdl_target_compile_option_all_languages(${TARGET} "-Werror")
|
|
|
endif()
|
|
|
endif()
|
|
|
endif()
|
|
@@ -117,12 +124,12 @@ function(SDL_AddCommonCompilerFlags TARGET)
|
|
|
if(USE_CLANG)
|
|
|
check_c_compiler_flag("-fcolor-diagnostics" COMPILER_SUPPORTS_FCOLOR_DIAGNOSTICS)
|
|
|
if(COMPILER_SUPPORTS_FCOLOR_DIAGNOSTICS)
|
|
|
- target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:-fcolor-diagnostics>")
|
|
|
+ sdl_target_compile_option_all_languages(${TARGET} "-fcolor-diagnostics")
|
|
|
endif()
|
|
|
else()
|
|
|
check_c_compiler_flag("-fdiagnostics-color=always" COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS)
|
|
|
if(COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS)
|
|
|
- target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:-fdiagnostics-color=always>")
|
|
|
+ sdl_target_compile_option_all_languages(${TARGET} "-fdiagnostics-color=always")
|
|
|
endif()
|
|
|
endif()
|
|
|
endfunction()
|