diff options
author | Riccardo Spagni <ric@spagni.net> | 2018-02-16 14:20:46 +0100 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2018-02-16 14:20:46 +0100 |
commit | 172b7824d1d0c37867e49a2b6167f9bcf3a365ea (patch) | |
tree | a5e2a1d0bf5cc041cf064d8731ea490f1df51204 /CMakeLists.txt | |
parent | Merge pull request #3187 (diff) | |
parent | cmake: add -DHAVE_ defines to the command line (diff) | |
download | monero-172b7824d1d0c37867e49a2b6167f9bcf3a365ea.tar.xz |
Merge pull request #3195
9017084a cmake: add -DHAVE_ defines to the command line (moneromooo-monero)
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 730a0f875..f0be28845 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,7 @@ include(CheckCCompilerFlag) include(CheckCXXCompilerFlag) include(CheckLinkerFlag) include(CheckLibraryExists) +include(CheckFunctionExists) if (IOS) INCLUDE(CmakeLists_IOS.txt) @@ -80,6 +81,22 @@ function (add_linker_flag_if_supported flag var) endif() endfunction() +function (add_definition_if_function_found function var) + string(REPLACE "-" "_" supported ${function}_function) + check_function_exists(${function} ${supported}) + if(${${supported}}) + add_definitions("-D${var}") + endif() +endfunction() + +function (add_definition_if_library_exists library function header var) + string(REPLACE "-" "_" supported ${function}_library) + check_library_exists(${library} ${function} ${header} ${supported}) + if(${${supported}}) + add_definitions("-D${var}") + endif() +endfunction() + if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE) message(STATUS "Setting default build type: ${CMAKE_BUILD_TYPE}") @@ -395,6 +412,10 @@ if(STATIC AND NOT IOS) endif() endif() +add_definition_if_library_exists(c memset_s "string.h" HAVE_MEMSET_S) +add_definition_if_library_exists(c explicit_bzero "strings.h" HAVE_EXPLICIT_BZERO) +add_definition_if_function_found(strptime HAVE_STRPTIME) + add_definitions(-DAUTO_INITIALIZE_EASYLOGGINGPP) # Generate header for embedded translations @@ -867,10 +888,3 @@ option(INSTALL_VENDORED_LIBUNBOUND "Install libunbound binary built from source CHECK_C_COMPILER_FLAG(-std=c11 HAVE_C11) - -include(CheckLibraryExists) -include(CheckFunctionExists) - -check_library_exists(c memset_s "string.h" HAVE_MEMSET_S) -check_library_exists(c explicit_bzero "strings.h" HAVE_EXPLICIT_BZERO) -check_function_exists(strptime HAVE_STRPTIME) |