serf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1834279 - in /serf/trunk: CMakeLists.txt build/SerfChecks.cmake test/CMakeLists.txt
Date Mon, 25 Jun 2018 06:23:33 GMT
Author: brane
Date: Mon Jun 25 06:23:33 2018
New Revision: 1834279

URL: http://svn.apache.org/viewvc?rev=1834279&view=rev
Log:
Make the CMake build more like the current SCons build.

* CMakeLists.txt:
   Add build options with names like the SCons options.
   Add missing config checks and set compiler debug and warning flags.

* test/CMakeLists.txt:
   Force C99 compilation mode if the top-level project forced C89 mode.

* build/SerfChecks.cmake:
   Make the feature tests use a more strict environment.

Modified:
    serf/trunk/CMakeLists.txt
    serf/trunk/build/SerfChecks.cmake
    serf/trunk/test/CMakeLists.txt

Modified: serf/trunk/CMakeLists.txt
URL: http://svn.apache.org/viewvc/serf/trunk/CMakeLists.txt?rev=1834279&r1=1834278&r2=1834279&view=diff
==============================================================================
--- serf/trunk/CMakeLists.txt (original)
+++ serf/trunk/CMakeLists.txt Mon Jun 25 06:23:33 2018
@@ -30,12 +30,28 @@ message(WARNING
         "has not been tested on many supported platforms.")
 
 
+# Build options
+option(PREFIX "Installation root directory" OFF)
+option(LIBDIR "Indstall directory for architecture-dependent libraries" OFF)
+option(APR "Path to APR's install area" OFF)
+option(APU "Path to APR-Util's install area" OFF)
+option(OPENSSL "Path to OpenSSL's install area" OFF)
+option(ZLIB "Path to zlib's install area" OFF)
+option(GSSAPI "Path to GSSAPI's install area" OFF)
+option(BROTLI "Path to Brotli's install area" OFF)
+option(DEBUG "Enable debugging info and strict compile warnings" OFF)
+option(DISABLE_LOGGING "Disable the logging framework at compile time" OFF)
+option(ENABLE_SLOW_TESTS "Enable long-running unit tests" OFF)
+
+
+# Public headers
 set(HEADERS
     "serf.h"
     "serf_bucket_types.h"
     "serf_bucket_util.h"
 )
 
+# Serf library source files
 set(SOURCES
     "src/config_store.c"
     "src/context.c"
@@ -91,27 +107,38 @@ if(WINDOWS)
 endif(WINDOWS)
 
 
+# Process build options for dependency search
+if(APR)
+  set(APR_ROOT ${APR})
+endif()
+
+if(APU)
+  set(APRUTIL_ROOT ${APU})
+endif()
+
+if(OPENSSL)
+  set(OPENSSL_ROOT_DIR ${OPENSSL})
+endif()
+
+if(ZLIB)
+  set(ZLIB_ROOT ${ZLIB})
+endif()
+
+if(GSSAPI)
+  message(WARNING "option GSSAPI is not implemented yet")
+endif()
+
+if(BROTLI)
+  message(WARNING "option BROTLI is not implemented yet")
+endif()
+
+
+# Find dependencies
 find_package(OpenSSL)
 find_package(ZLib)
 find_package(APR)
 find_package(APRUtil)
 
-# Feature tests
-include(SerfChecks)
-CheckNotFunction("BIO_set_init" "SERF_NO_SSL_BIO_WRAPPERS" ${OPENSSL_LIBRARIES})
-CheckNotFunction("X509_STORE_get0_param" "SERF_NO_SSL_X509_STORE_WRAPPERS" ${OPENSSL_LIBRARIES})
-CheckNotFunction("X509_get0_notBefore" "SERF_NO_SSL_X509_GET0_NOTBEFORE" ${OPENSSL_LIBRARIES})
-CheckNotFunction("X509_get0_notAfter" "SERF_NO_SSL_X509_GET0_NOTAFTER" ${OPENSSL_LIBRARIES})
-CheckNotFunction("X509_STORE_CTX_get0_chain" "SERF_NO_SSL_X509_GET0_CHAIN" ${OPENSSL_LIBRARIES})
-CheckNotFunction("ASN1_STRING_get0_data" "SERF_NO_SSL_ASN1_STRING_GET0_DATA" ${OPENSSL_LIBRARIES})
-CheckFunction("CRYPTO_set_locking_callback" "SERF_HAVE_SSL_LOCKING_CALLBACKS" ${OPENSSL_LIBRARIES})
-CheckFunction("OPENSSL_malloc_init" "SERF_HAVE_OPENSSL_MALLOC_INIT" ${OPENSSL_LIBRARIES})
-CheckFunction("SSL_library_init" "SERF_HAVE_OPENSSL_SSL_LIBRARY_INIT" ${OPENSSL_LIBRARIES})
-CheckFunction("OpenSSL_version_num" "SERF_HAVE_OPENSSL_VERSION_NUM" ${OPENSSL_LIBRARIES})
-CheckFunction("SSL_set_alpn_protos" "SERF_HAVE_OPENSSL_ALPN" ${OPENSSL_LIBRARIES})
-CheckHeader("openssl/applink.c" "SERF_HAVE_OPENSSL_APPLINK_C" ${OPENSSL_INCLUDE_DIR})
-CheckType("OSSL_HANDSHAKE_STATE" "openssl/ssl.h" "SERF_HAVE_OSSL_HANDSHAKE_STATE" ${OPENSSL_INCLUDE_DIR})
-
 set(DEPENDENCY_INCLUDES
     ${OPENSSL_INCLUDE_DIR}
     ${ZLIB_INCLUDE_DIRS}
@@ -135,6 +162,78 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${AP
 include_directories(BEFORE SYSTEM ${DEPENDENCY_INCLUDES})
 include_directories(${CMAKE_SOURCE_DIR})
 
+
+# Feature tests
+include(SerfChecks)
+CheckNotFunction("BIO_set_init" "SERF_NO_SSL_BIO_WRAPPERS" ${OPENSSL_LIBRARIES})
+CheckNotFunction("X509_STORE_get0_param" "SERF_NO_SSL_X509_STORE_WRAPPERS" ${OPENSSL_LIBRARIES})
+CheckNotFunction("X509_get0_notBefore" "SERF_NO_SSL_X509_GET0_NOTBEFORE" ${OPENSSL_LIBRARIES})
+CheckNotFunction("X509_get0_notAfter" "SERF_NO_SSL_X509_GET0_NOTAFTER" ${OPENSSL_LIBRARIES})
+CheckNotFunction("X509_STORE_CTX_get0_chain" "SERF_NO_SSL_X509_GET0_CHAIN" ${OPENSSL_LIBRARIES})
+CheckNotFunction("ASN1_STRING_get0_data" "SERF_NO_SSL_ASN1_STRING_GET0_DATA" ${OPENSSL_LIBRARIES})
+CheckFunction("CRYPTO_set_locking_callback" "SERF_HAVE_SSL_LOCKING_CALLBACKS" ${OPENSSL_LIBRARIES})
+CheckFunction("OPENSSL_malloc_init" "SERF_HAVE_OPENSSL_MALLOC_INIT" ${OPENSSL_LIBRARIES})
+CheckFunction("SSL_library_init" "SERF_HAVE_OPENSSL_SSL_LIBRARY_INIT" ${OPENSSL_LIBRARIES})
+CheckFunction("OpenSSL_version_num" "SERF_HAVE_OPENSSL_VERSION_NUM" ${OPENSSL_LIBRARIES})
+CheckFunction("SSL_set_alpn_protos" "SERF_HAVE_OPENSSL_ALPN" ${OPENSSL_LIBRARIES})
+CheckHeader("openssl/applink.c" "SERF_HAVE_OPENSSL_APPLINK_C" ${OPENSSL_INCLUDE_DIR})
+CheckHeader("stdbool.h" "HAVE_STDBOOL_H=1")
+CheckType("OSSL_HANDSHAKE_STATE" "openssl/ssl.h" "SERF_HAVE_OSSL_HANDSHAKE_STATE" ${OPENSSL_INCLUDE_DIR})
+
+if(CMAKE_COMPILER_IS_GNUCC OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
+  set(CC_LIKE_GNUC TRUE)
+endif()
+
+# Process other build options
+if(PREFIX)
+  set(CMAKE_INSTALL_PREFIX ${PREFIX})
+endif()
+
+if(LIBDIR)
+  message(WARNING "option LIBDIR is not implemented yet")
+endif()
+
+if(NOT MSVC)
+  if(CC_LIKE_GNUC)
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wdeclaration-after-statement")
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-prototypes")
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c89")
+  endif()
+
+  if(DEBUG)
+    add_definitions("-DDEBUG" "-D_DEBUG")
+    if(CC_LIKE_GNUC)
+      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g")
+    endif()
+  else()
+    add_definitions("-DNDEBUG")
+    if(CC_LIKE_GNUC)
+      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
+    endif()
+  endif()
+else()
+  # Warning level 4, no unused argument warnings
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4 /wd4100")
+  # Conditional expression is constant
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4127")
+  # Assignment within conditional expression
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4706")
+
+  set(CMAKE_C_FLAGS_Debug "/Od /MDd /DDEBUG /D_DEBUG")
+  set(CMAKE_C_FLAGS_Release "/O2 /MD /DNDEBUG")
+  set(CMAKE_SHARED_LINKER_FLAGS_Release "/RELEASE")
+endif(NOT MSVC)
+
+if(DISABLE_LOGGING)
+  add_definitions("-DSERF_DISABLE_LOGGING")
+endif()
+
+if(ENABLE_SLOW_TESTS)
+  add_definitions("-DSERF_TEST_DEFLATE_4GBPLUS_BUCKETS")
+endif()
+
+
 add_library(serf SHARED ${SOURCES} ${SHARED_SOURCES})
 target_link_libraries(serf ${DEPENDENCY_LIBRARIES})
 

Modified: serf/trunk/build/SerfChecks.cmake
URL: http://svn.apache.org/viewvc/serf/trunk/build/SerfChecks.cmake?rev=1834279&r1=1834278&r2=1834279&view=diff
==============================================================================
--- serf/trunk/build/SerfChecks.cmake (original)
+++ serf/trunk/build/SerfChecks.cmake Mon Jun 25 06:23:33 2018
@@ -22,7 +22,12 @@ include(CheckIncludeFile)
 include(CheckTypeSize)
 
 function(_CheckFunction var_ name_ libraries_)
-  set(CMAKE_REQUIRED_LIBRARIES "${libraries_}")
+  if(libraries_)
+    set(CMAKE_REQUIRED_LIBRARIES "${libraries_}")
+  else()
+    unset(CMAKE_REQUIRED_LIBRARIES)
+  endif()
+
   check_function_exists("${name_}" "serf_foundit_${name_}_")
   if(${serf_foundit_${name_}_})
     set("${var_}" TRUE PARENT_SCOPE)
@@ -48,7 +53,12 @@ endmacro(CheckNotFunction)
 
 
 function(_CheckHeader var_ name_ includes_)
-  set(CMAKE_REQUIRED_INCLUDES "${includes_}")
+  if(includes_)
+    set(CMAKE_REQUIRED_INCLUDES "${includes_}")
+  else()
+    unset(CMAKE_REQUIRED_INCLUDES)
+  endif()
+
   check_include_file("${name_}" "serf_foundit_${name_}_")
   if(${serf_foundit_${name_}_})
     set("${var_}" TRUE PARENT_SCOPE)
@@ -67,8 +77,18 @@ endmacro(CheckHeader)
 
 
 function(_CheckType var_ name_ header_ includes_)
-  set(CMAKE_REQUIRED_INCLUDES "${includes_}")
-  set(CMAKE_EXTRA_INCLUDE_FILES "${header_}")
+  if(includes_)
+    set(CMAKE_REQUIRED_INCLUDES "${includes_}")
+  else()
+    unset(CMAKE_REQUIRED_INCLUDES)
+  endif()
+
+  if(header_)
+    set(CMAKE_EXTRA_INCLUDE_FILES "${header_}")
+  else()
+    unset(CMAKE_EXTRA_INCLUDE_FILES)
+  endif()
+
   check_type_size("${name_}" "serf_foundit_${name_}_")
   if(${HAVE_serf_foundit_${name_}_})
     set("${var_}" TRUE PARENT_SCOPE)

Modified: serf/trunk/test/CMakeLists.txt
URL: http://svn.apache.org/viewvc/serf/trunk/test/CMakeLists.txt?rev=1834279&r1=1834278&r2=1834279&view=diff
==============================================================================
--- serf/trunk/test/CMakeLists.txt (original)
+++ serf/trunk/test/CMakeLists.txt Mon Jun 25 06:23:33 2018
@@ -43,6 +43,11 @@ set(SIMPLE_TEST_TARGETS
     "serf_bwtp"
 )
 
+if(CC_LIKE_GNUC)
+  # MockHTTP requires C99 standard, so use it for the test suite.
+  string(REPLACE "-std=c89" "-std=c99" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
+endif()
+
 add_definitions("-DMOCKHTTP_OPENSSL")
 
 foreach(TEST_TARGET ${SIMPLE_TEST_TARGETS})



Mime
View raw message