mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 13:27:45 -07:00
cmake: Move check_and_add_flag to a separate file
Also make it add flags to both C and C++ when appropriate
This commit is contained in:
parent
eed64bb0fe
commit
08b73b8a77
@ -72,7 +72,13 @@ endif()
|
||||
# TODO: Add DSPSpy
|
||||
option(DSPTOOL "Build dsptool" OFF)
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMakeTests)
|
||||
list(APPEND CMAKE_MODULE_PATH
|
||||
${CMAKE_SOURCE_DIR}/CMakeTests
|
||||
)
|
||||
|
||||
# Support functions
|
||||
include(CheckAndAddFlag)
|
||||
|
||||
# Libraries to link
|
||||
set(LIBS)
|
||||
|
||||
@ -198,13 +204,6 @@ else()
|
||||
message(FATAL_ERROR "You're building on an unsupported platform. Enable generic build if you really want a JIT-less binary.")
|
||||
endif()
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
macro(check_and_add_flag var flag)
|
||||
CHECK_CXX_COMPILER_FLAG(${flag} FLAG_${var})
|
||||
if(FLAG_${var})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Enforce minimum GCC version
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
|
||||
|
14
CMakeTests/CheckAndAddFlag.cmake
Normal file
14
CMakeTests/CheckAndAddFlag.cmake
Normal file
@ -0,0 +1,14 @@
|
||||
include(CheckCCompilerFlag)
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
macro(check_and_add_flag var flag)
|
||||
check_c_compiler_flag(${flag} FLAG_C_${var})
|
||||
if(FLAG_C_${var})
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
|
||||
endif()
|
||||
|
||||
check_cxx_compiler_flag(${flag} FLAG_CXX_${var})
|
||||
if(FLAG_CXX_${var})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
|
||||
endif()
|
||||
endmacro()
|
Loading…
Reference in New Issue
Block a user