Browse Source

[build] CMake support for wolfSSL

(missing HAVE_WOLFSSL_SSL_H without add_definition() suggests that
 there are other definitions that are not being exported for use
 in the build, so lighttpd built with CMake has base features only)
personal/stbuehler/fix-fdevent
Glenn Strauss 3 years ago
parent
commit
78d4ef9e0f
  1. 81
      src/CMakeLists.txt

81
src/CMakeLists.txt

@ -18,6 +18,7 @@ option(WITH_MYSQL "with mysql-support for mod_vhostdb_mysql [default: off]")
option(WITH_PGSQL "with postgres-support for mod_vhostdb_pgsql [default: off]")
option(WITH_DBI "with dbi-support for mod_vhostdb_dbi [default: off]")
option(WITH_OPENSSL "with openssl-support [default: off]")
option(WITH_WOLFSSL "with wolfSSL-support [default: off]")
option(WITH_PCRE "with regex support [default: on]" ON)
option(WITH_WEBDAV_PROPS "with property-support for mod_webdav [default: off]")
option(WITH_WEBDAV_LOCKS "locks in webdav [default: off]")
@ -280,6 +281,8 @@ else()
unset(HAVE_DBI)
endif()
set(CRYPTO_LIBRARY "")
if(WITH_OPENSSL)
if(APPLE)
set(CMAKE_REQUIRED_INCLUDES /opt/local/include)
@ -291,15 +294,72 @@ if(WITH_OPENSSL)
if(HAVE_OPENSSL_SSL_H)
check_library_exists(crypto BIO_f_base64 "" HAVE_LIBCRYPTO)
if(HAVE_LIBCRYPTO)
set(CRYPTO_LIBRARY crypto)
check_library_exists(ssl SSL_new "" HAVE_LIBSSL)
endif()
endif()
else()
unset(HAVE_OPENSSL_SSL_H)
unset(HAVE_LIBCRYPTO)
unset(HAVE_LIBSSL)
endif()
if(WITH_WOLFSSL)
if(NOT ${WITH_WOLFSSL} EQUAL "")
find_path(WOLFSSL_INCLUDE_DIR wolfssl/ssl.h ${WITH_WOLFSSL}/include)
elseif(APPLE)
find_path(WOLFSSL_INCLUDE_DIR wolfssl/ssl.h /opt/local/include)
else()
find_path(WOLFSSL_INCLUDE_DIR wolfssl/ssl.h /usr/local/include)
endif()
if(NOT ${WITH_WOLFSSL} EQUAL "")
find_library(WOLFSSL_LIBRARY
NAMES wolfssl
PATHS ${WITH_WOLFSSL}/lib
)
else()
find_library(WOLFSSL_LIBRARY
NAMES wolfssl
PATHS /usr/local/lib /opt/local/lib /usr/lib
)
endif()
if(WOLFSSL_INCLUDE_DIR AND WOLFSSL_LIBRARY)
set(CMAKE_REQUIRED_INCLUDES ${WOLFSSL_INCLUDE_DIR})
check_include_files(wolfssl/ssl.h HAVE_WOLFSSL_SSL_H)
check_c_source_compiles("
#include <wolfssl/options.h>
#if !defined(HAVE_LIGHTY) && !defined(OPENSSL_ALL)
#error HAVE_LIGHTY macro not defined
#endif
int main() { return 0; }
" CHECK_HAVE_LIGHTY)
if (NOT CHECK_HAVE_LIGHTY)
message(FATAL_ERROR "wolfssl must be built with ./configure --enable-lighty")
endif()
unset(CHECK_HAVE_LIGHTY)
set(CMAKE_REQUIRED_LIBRARIES ${WOLFSSL_LIBRARY})
check_library_exists(${WOLFSSL_LIBRARY} wolfSSL_Init "" HAVE_LIBCRYPTO)
if(HAVE_LIBCRYPTO)
set(CRYPTO_LIBRARY ${WOLFSSL_LIBRARY})
add_definitions(-DHAVE_WOLFSSL_SSL_H)
endif()
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_LIBRARIES)
include_directories(${WOLFSSL_INCLUDE_DIR} ${WOLFSSL_INCLUDE_DIR}/wolfssl)
endif()
unset(WOLFSSL_LIBRARY)
unset(WOLFSSL_INCLUDE_DIR)
else()
unset(HAVE_WOLFSSL_SSL_H)
endif()
if(WITH_OPENSSL AND WITH_WOLFSSL)
message(FATAL_ERROR "lighttpd should not be built with both --with-openssl and --with-wolfssl")
endif()
if(WITH_PCRE)
## if we have pcre-config, use it
xconfig(pcre-config PCRE_INCDIR PCRE_LIBDIR PCRE_LDFLAGS PCRE_CFLAGS)
@ -886,16 +946,21 @@ if(NOT BUILD_STATIC)
endif()
endif()
if(HAVE_LIBSSL AND HAVE_LIBCRYPTO)
target_link_libraries(lighttpd ssl)
target_link_libraries(lighttpd crypto)
if(NOT ${CRYPTO_LIBRARY} EQUAL "")
if(NOT WITH_WOLFSSL)
target_link_libraries(lighttpd ssl)
endif()
target_link_libraries(lighttpd ${CRYPTO_LIBRARY})
add_and_install_library(mod_openssl "mod_openssl.c")
set(L_MOD_OPENSSL ${L_MOD_OPENSSL} ssl crypto)
if(NOT WITH_WOLFSSL)
set(L_MOD_OPENSSL ${L_MOD_OPENSSL} ssl)
endif()
set(L_MOD_OPENSSL ${L_MOD_OPENSSL} ${CRYPTO_LIBRARY})
target_link_libraries(mod_openssl ${L_MOD_OPENSSL})
set(L_MOD_AUTHN_FILE ${L_MOD_AUTHN_FILE} crypto)
set(L_MOD_AUTHN_FILE ${L_MOD_AUTHN_FILE} ${CRYPTO_LIBRARY})
target_link_libraries(mod_authn_file ${L_MOD_AUTHN_FILE})
target_link_libraries(mod_secdownload crypto)
target_link_libraries(mod_wstunnel crypto)
target_link_libraries(mod_secdownload ${CRYPTO_LIBRARY})
target_link_libraries(mod_wstunnel ${CRYPTO_LIBRARY})
endif()
if(WITH_LIBEV)

Loading…
Cancel
Save