diff options
author | John Wiegley <johnw@newartisans.com> | 2012-05-20 14:09:17 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2012-05-20 14:09:17 -0500 |
commit | c2dde97994f3bf507cbb1f211e60f84ac46bb0c0 (patch) | |
tree | 74e05c586d59c22c6af5b8495d3c568cb2ea42e2 /CMakeLists.txt | |
parent | 8faae6663862f186f5628c23f645384e7d30587a (diff) | |
download | fork-ledger-c2dde97994f3bf507cbb1f211e60f84ac46bb0c0.tar.gz fork-ledger-c2dde97994f3bf507cbb1f211e60f84ac46bb0c0.tar.bz2 fork-ledger-c2dde97994f3bf507cbb1f211e60f84ac46bb0c0.zip |
Make library detection more resilient
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 77 |
1 files changed, 46 insertions, 31 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f60dcf7e..bb85dcc9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,25 +62,14 @@ find_package(Boost 1.47.0 include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) -find_package(Gettext) # Used for running tests - -#if(GETTEXT_FOUND) -# set(HAVE_GETTEXT 1) -#else() - set(HAVE_GETTEXT 0) -#endif() - ######################################################################## include(CheckIncludeFiles) - -check_include_files(langinfo.h HAVE_LANGINFO_H) - include(CheckLibraryExists) - -check_library_exists(edit readline "" HAVE_EDIT) - include(CheckFunctionExists) +include(CheckCSourceCompiles) +include(CheckCXXSourceRuns) +include(CMakePushCheckState) check_function_exists(access HAVE_ACCESS) check_function_exists(realpath HAVE_REALPATH) @@ -88,8 +77,6 @@ check_function_exists(getpwuid HAVE_GETPWUID) check_function_exists(getpwnam HAVE_GETPWNAM) check_function_exists(isatty HAVE_ISATTY) -include(CheckCSourceCompiles) - check_c_source_compiles(" #include <sys/types.h> #include <sys/wait.h> @@ -127,9 +114,6 @@ else() set(HAVE_UNIX_PIPES 0) endif() -include(CheckCXXSourceRuns) -include(CMakePushCheckState) - cmake_push_check_state() set(CMAKE_REQUIRED_INCLUDES ${CMAKE_INCLUDE_PATH} ${Boost_INCLUDE_DIRS}) @@ -189,21 +173,52 @@ cmake_pop_check_state() include_directories(${CMAKE_INCLUDE_PATH}) -find_path(GMP_PATH gmp.h) -find_library(GMP_LIB gmp) -include_directories(SYSTEM "${GMP_PATH}") +macro(find_opt_library_and_header _header_var _header _lib_var _lib _have_var) + if(${_header_var}) + find_path(${_header_var} ${_header}) + if(NOT ${_header_var}) + set(${_have_var} 0) + else() + find_library(${_lib_var} ${_lib}) + if(NOT ${_lib_var}) + set(${_have_var} 0) + else() + include_directories(SYSTEM "${${_header_var}}") + endif() + endif() + endif() +endmacro(find_opt_library_and_header _header_var _header _lib_var _lib _have_var) -find_path(MPFR_PATH mpfr.h) -find_library(MPFR_LIB mpfr) -include_directories(SYSTEM "${MPFR_PATH}") +macro(find_req_library_and_header _header_var _header _lib_var _lib) + find_path(${_header_var} ${_header}) + if(NOT ${_header_var}) + message(SEND_ERROR "Could not find ${_header} on your system") + else() + include_directories(SYSTEM "${${_header_var}}") + find_library(${_lib_var} ${_lib}) + if(NOT ${_lib_var}) + message(SEND_ERROR "Could not find library ${_lib} on your system") + endif() + endif() +endmacro(find_req_library_and_header _header_var _header _lib_var _lib) -find_path(EDIT_PATH histedit.h) -find_library(EDIT_LIB edit) -include_directories(SYSTEM "${EDIT_PATH}") +find_req_library_and_header(GMP_PATH gmp.h GMP_LIB gmp) +find_req_library_and_header(MPFR_PATH mpfr.h MPFR_LIB mpfr) + +check_library_exists(edit readline "" HAVE_EDIT) +find_opt_library_and_header(EDIT_PATH histedit.h EDIT_LIB edit HAVE_EDIT) + +find_package(Gettext) # Used for running tests + +#if(GETTEXT_FOUND) +# set(HAVE_GETTEXT 1) +#else() + set(HAVE_GETTEXT 0) +#endif() -find_path(INTL_PATH libintl.h) -find_library(INTL_LIB intl) -include_directories(SYSTEM "${INTL_PATH}") +#find_path(INTL_PATH libintl.h) +#find_library(INTL_LIB intl) +#include_directories(SYSTEM "${INTL_PATH}") ######################################################################## |