From cd8a57ae9b4e7f811d30e1c5b225d36c7a049429 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 3 Nov 2016 13:31:33 -0400 Subject: Add option to build CMake against a system librhash Create a CMAKE_USE_SYSTEM_LIBRHASH option. --- CMakeLists.txt | 22 ++++++++++++++++++---- Utilities/cmThirdParty.h.in | 1 + Utilities/cm_rhash.h | 6 ++++++ bootstrap | 6 ++++-- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 82a34d3..7aa8010 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,7 +104,7 @@ macro(CMAKE_HANDLE_SYSTEM_LIBRARIES) # Allow the user to enable/disable all system utility library options by # defining CMAKE_USE_SYSTEM_LIBRARIES or CMAKE_USE_SYSTEM_LIBRARY_${util}. - set(UTILITIES BZIP2 CURL EXPAT FORM JSONCPP LIBARCHIVE LIBLZMA LIBUV ZLIB) + set(UTILITIES BZIP2 CURL EXPAT FORM JSONCPP LIBARCHIVE LIBLZMA LIBRHASH LIBUV ZLIB) foreach(util ${UTILITIES}) if(NOT DEFINED CMAKE_USE_SYSTEM_LIBRARY_${util} AND DEFINED CMAKE_USE_SYSTEM_LIBRARIES) @@ -144,6 +144,7 @@ macro(CMAKE_HANDLE_SYSTEM_LIBRARIES) "${CMAKE_USE_SYSTEM_LIBRARY_LIBLZMA}" "NOT CMAKE_USE_SYSTEM_LIBARCHIVE" ON) option(CMAKE_USE_SYSTEM_FORM "Use system-installed libform" "${CMAKE_USE_SYSTEM_LIBRARY_FORM}") option(CMAKE_USE_SYSTEM_JSONCPP "Use system-installed jsoncpp" "${CMAKE_USE_SYSTEM_LIBRARY_JSONCPP}") + option(CMAKE_USE_SYSTEM_LIBRHASH "Use system-installed librhash" "${CMAKE_USE_SYSTEM_LIBRARY_LIBRHASH}") option(CMAKE_USE_SYSTEM_LIBUV "Use system-installed libuv" "${CMAKE_USE_SYSTEM_LIBRARY_LIBUV}") # For now use system KWIML only if explicitly requested rather @@ -298,9 +299,22 @@ macro (CMAKE_BUILD_UTILITIES) add_subdirectory(Utilities/KWIML) endif() - set(CMAKE_LIBRHASH_LIBRARIES cmlibrhash) - add_subdirectory(Utilities/cmlibrhash) - CMAKE_SET_TARGET_FOLDER(cmlibrhash "Utilities/3rdParty") + if(CMAKE_USE_SYSTEM_LIBRHASH) + if(NOT CMAKE_VERSION VERSION_LESS 3.0) + find_package(LibRHash) + else() + message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBRHASH requires CMake >= 3.0") + endif() + if(NOT LibRHash_FOUND) + message(FATAL_ERROR + "CMAKE_USE_SYSTEM_LIBRHASH is ON but LibRHash is not found!") + endif() + set(CMAKE_LIBRHASH_LIBRARIES LibRHash::LibRHash) + else() + set(CMAKE_LIBRHASH_LIBRARIES cmlibrhash) + add_subdirectory(Utilities/cmlibrhash) + CMAKE_SET_TARGET_FOLDER(cmlibrhash "Utilities/3rdParty") + endif() #--------------------------------------------------------------------- # Build zlib library for Curl, CMake, and CTest. diff --git a/Utilities/cmThirdParty.h.in b/Utilities/cmThirdParty.h.in index 210e727..a547f0d 100644 --- a/Utilities/cmThirdParty.h.in +++ b/Utilities/cmThirdParty.h.in @@ -13,6 +13,7 @@ #cmakedefine CMAKE_USE_SYSTEM_LIBLZMA #cmakedefine CMAKE_USE_SYSTEM_FORM #cmakedefine CMAKE_USE_SYSTEM_JSONCPP +#cmakedefine CMAKE_USE_SYSTEM_LIBRHASH #cmakedefine CMAKE_USE_SYSTEM_LIBUV #cmakedefine CTEST_USE_XMLRPC diff --git a/Utilities/cm_rhash.h b/Utilities/cm_rhash.h index 23d5409..c793627 100644 --- a/Utilities/cm_rhash.h +++ b/Utilities/cm_rhash.h @@ -3,6 +3,12 @@ #ifndef cm_rhash_h #define cm_rhash_h +/* Use the LibRHash library configured for CMake. */ +#include "cmThirdParty.h" +#ifdef CMAKE_USE_SYSTEM_LIBRHASH +#include +#else #include +#endif #endif diff --git a/bootstrap b/bootstrap index 4ce0dee..d54380a 100755 --- a/bootstrap +++ b/bootstrap @@ -493,6 +493,8 @@ Configuration: --no-system-liblzma use cmake-provided liblzma library (default) --system-libarchive use system-installed libarchive library --no-system-libarchive use cmake-provided libarchive library (default) + --system-librhash use system-installed librhash library + --no-system-librhash use cmake-provided librhash library (default) --qt-gui build the Qt-based GUI (requires Qt >= 4.2) --no-qt-gui do not build the Qt-based GUI (default) @@ -726,10 +728,10 @@ while test $# != 0; do --init=*) cmake_init_file=`cmake_arg "$1"` ;; --system-libs) cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARIES=1" ;; --no-system-libs) cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARIES=0" ;; - --system-bzip2|--system-curl|--system-expat|--system-jsoncpp|--system-libarchive|--system-zlib|--system-liblzma) + --system-bzip2|--system-curl|--system-expat|--system-jsoncpp|--system-libarchive|--system-librhash|--system-zlib|--system-liblzma) lib=`cmake_arg "$1" "--system-"` cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper $lib`=1" ;; - --no-system-bzip2|--no-system-curl|--no-system-expat|--no-system-jsoncpp|--no-system-libarchive|--no-system-zlib|--no-system-liblzma) + --no-system-bzip2|--no-system-curl|--no-system-expat|--no-system-jsoncpp|--no-system-libarchive|--no-system-librhash|--no-system-zlib|--no-system-liblzma) lib=`cmake_arg "$1" "--no-system-"` cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper $lib`=0" ;; --qt-gui) cmake_bootstrap_qt_gui="1" ;; -- cgit v0.12