From 28b29179f4bb0e4ed36d366dcc98df00e6112944 Mon Sep 17 00:00:00 2001 From: psychocrypt Date: Sun, 30 Apr 2017 19:54:23 +0200 Subject: [PATCH 1/2] always build feature complete - throw an error if a compile dependancy is not fullfilled - add options to disable hard compile dependancies --- CMakeLists.txt | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index acf4093..7a25a6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,10 +56,15 @@ set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT}) # Find microhttpd ################################################################################ +option(MICROHTTPD_REQUIRED "Enable or disable the requirement of microhttp (http deamon)" ON) find_library(MHTD NAMES microhttpd) if("${MHTD}" STREQUAL "MHTD-NOTFOUND") - message(STATUS "microhttpd NOT found: disable http server") - add_definitions("-DCONF_NO_HTTPD") + if(MICROHTTPD_REQUIRED) + message(FATAL_ERROR "microhttpd NOT found: use `-DMICROHTTPD_REQUIRED=OFF` to build without http deamon support") + else() + message(STATUS "microhttpd NOT found: disable http server") + add_definitions("-DCONF_NO_HTTPD") + endif() else() set(LIBS ${LIBS} ${MHTD}) endif() @@ -68,11 +73,19 @@ endif() # Find OpenSSL ############################################################################### +option(OpenSSL_REQUIRED "Enable or disable the requirement of OpenSSL" ON) find_package(OpenSSL) -include_directories(${OPENSSL_INCLUDE_DIR}) -set(LIBS ${LIBS} ${OPENSSL_LIBRARIES}) -if(NOT OPENSSL_FOUND) - add_definitions("-DCONF_NO_TLS") +if(OPENSSL_FOUND) + include_directories(${OPENSSL_INCLUDE_DIR}) + set(LIBS ${LIBS} ${OPENSSL_LIBRARIES}) +else() + if(OpenSSL_REQUIRED) + message(FATAL_ERROR "OpenSSL NOT found: use `-DOpenSSL_REQUIRED=OFF` to build without SSL support") + else() + if(NOT OPENSSL_FOUND) + add_definitions("-DCONF_NO_TLS") + endif() + endif() endif() ################################################################################ From 85f2b67df0d6d23ccf17ea6eb7827ab6afb79be0 Mon Sep 17 00:00:00 2001 From: psychocrypt Date: Mon, 1 May 2017 21:11:22 +0200 Subject: [PATCH 2/2] allow to fully disable OpenSSL and microhttpd - rename option `*_REQUIRED` to `*_ENABLE` - allow to disable the dependency OpenSSL and microhttpd --- CMakeLists.txt | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a25a6f..46606b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,36 +56,33 @@ set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT}) # Find microhttpd ################################################################################ -option(MICROHTTPD_REQUIRED "Enable or disable the requirement of microhttp (http deamon)" ON) -find_library(MHTD NAMES microhttpd) -if("${MHTD}" STREQUAL "MHTD-NOTFOUND") - if(MICROHTTPD_REQUIRED) - message(FATAL_ERROR "microhttpd NOT found: use `-DMICROHTTPD_REQUIRED=OFF` to build without http deamon support") +option(MICROHTTPD_ENABLE "Enable or disable the requirement of microhttp (http deamon)" ON) +if(MICROHTTPD_ENABLE) + find_library(MHTD NAMES microhttpd) + if("${MHTD}" STREQUAL "MHTD-NOTFOUND") + message(FATAL_ERROR "microhttpd NOT found: use `-DMICROHTTPD_ENABLE=OFF` to build without http deamon support") else() - message(STATUS "microhttpd NOT found: disable http server") - add_definitions("-DCONF_NO_HTTPD") + set(LIBS ${LIBS} ${MHTD}) endif() else() - set(LIBS ${LIBS} ${MHTD}) + add_definitions("-DCONF_NO_HTTPD") endif() ############################################################################### # Find OpenSSL ############################################################################### -option(OpenSSL_REQUIRED "Enable or disable the requirement of OpenSSL" ON) -find_package(OpenSSL) -if(OPENSSL_FOUND) - include_directories(${OPENSSL_INCLUDE_DIR}) - set(LIBS ${LIBS} ${OPENSSL_LIBRARIES}) -else() - if(OpenSSL_REQUIRED) - message(FATAL_ERROR "OpenSSL NOT found: use `-DOpenSSL_REQUIRED=OFF` to build without SSL support") +option(OpenSSL_ENABLE "Enable or disable the requirement of OpenSSL" ON) +if(OpenSSL_ENABLE) + find_package(OpenSSL) + if(OPENSSL_FOUND) + include_directories(${OPENSSL_INCLUDE_DIR}) + set(LIBS ${LIBS} ${OPENSSL_LIBRARIES}) else() - if(NOT OPENSSL_FOUND) - add_definitions("-DCONF_NO_TLS") - endif() + message(FATAL_ERROR "OpenSSL NOT found: use `-DOpenSSL_ENABLE=OFF` to build without SSL support") endif() +else() + add_definitions("-DCONF_NO_TLS") endif() ################################################################################