mirror of https://github.com/OpenRCT2/OpenRCT2.git
Add convenience functions to CMakeLists.txt
The helper functions allow setting compiler flags only if compiler supports them.
This commit is contained in:
parent
88ccfad303
commit
c70639302c
|
@ -60,8 +60,44 @@ execute_process(
|
||||||
)
|
)
|
||||||
add_definitions(-DOPENRCT2_COMMIT_SHA1_SHORT="${OPENRCT2_COMMIT_SHA1_SHORT}")
|
add_definitions(-DOPENRCT2_COMMIT_SHA1_SHORT="${OPENRCT2_COMMIT_SHA1_SHORT}")
|
||||||
|
|
||||||
|
# Convenience functions to set compiler flags only if available
|
||||||
|
include(CheckCCompilerFlag)
|
||||||
|
include(CheckCXXCompilerFlag)
|
||||||
|
|
||||||
|
function(ADD_CHECK_C_COMPILER_FLAG
|
||||||
|
_CFLAGS
|
||||||
|
_CACHE_VAR
|
||||||
|
_FLAG
|
||||||
|
)
|
||||||
|
|
||||||
|
CHECK_C_COMPILER_FLAG("${_FLAG}" "${_CACHE_VAR}")
|
||||||
|
if(${_CACHE_VAR})
|
||||||
|
# message(STATUS "Using CFLAG: ${_FLAG}")
|
||||||
|
set(${_CFLAGS} "${${_CFLAGS}} ${_FLAG}" PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
message(STATUS "Unsupported CFLAG: ${_FLAG}")
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(ADD_CHECK_CXX_COMPILER_FLAG
|
||||||
|
_CXXFLAGS
|
||||||
|
_CACHE_VAR
|
||||||
|
_FLAG
|
||||||
|
)
|
||||||
|
|
||||||
|
CHECK_CXX_COMPILER_FLAG("${_FLAG}" "${_CACHE_VAR}")
|
||||||
|
if(${_CACHE_VAR})
|
||||||
|
# message(STATUS "Using CXXFLAG: ${_FLAG}")
|
||||||
|
set(${_CXXFLAGS} "${${_CXXFLAGS}} ${_FLAG}" PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
message(STATUS "Unsupported CXXFLAG: ${_FLAG}")
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# pkg-config
|
||||||
INCLUDE(FindPkgConfig)
|
INCLUDE(FindPkgConfig)
|
||||||
|
|
||||||
|
# Needed for linking with non-broken OpenSSL on Apple platforms
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/opt/openssl/lib/pkgconfig")
|
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/opt/openssl/lib/pkgconfig")
|
||||||
endif (APPLE)
|
endif (APPLE)
|
||||||
|
|
Loading…
Reference in New Issue