Merge pull request #115 from hfmanson/master
[tlspool] / CMakeLists.txt
1 cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
2 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
3
4 project(tlspool C)
5
6 include (FeatureSummary)
7 find_package (ARPA2CM 0.5 QUIET NO_MODULE)
8 set_package_properties (ARPA2CM PROPERTIES
9     DESCRIPTION "CMake modules for ARPA2 projects"
10     TYPE REQUIRED
11     URL "https://github.com/arpa2/arpa2cm/"
12     PURPOSE "Required for the CMake build system for ${PROJECT}"
13 )
14 if (ARPA2CM_FOUND)
15     set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ARPA2CM_MODULE_PATH})
16 else()
17     feature_summary (WHAT ALL)
18     message (FATAL_ERROR "ARPA2CM is required.")
19 endif()
20
21 include(MacroEnsureOutOfSourceBuild)
22 include(MacroGitVersionInfo)
23
24 include(CTest)
25 include(FeatureSummary)
26 include(GNUInstallDirs)
27
28 set(CMAKE_C_STANDARD 99)
29 set(CMAKE_C_STANDARD_REQUIRED ON)
30
31 macro_ensure_out_of_source_build(
32     "Do not build TLSPool in the source directory.")
33 get_version_from_git(TLSPool 0.20)
34
35 # Finding dependencies, find-modules provided by:
36 # - "ARPA" is shipped with ARPA2CM
37 # - "Module" is shipped with CMake itself
38 # - "Config" is shipped with that software package
39 #
40 find_package(BDB REQUIRED)         # ARPA
41 find_package(GnuTLS REQUIRED)      # Module
42 find_package(GnuTLSDane REQUIRED)  # ARPA
43 find_package(KERBEROS REQUIRED)    # Local
44 find_package(Libldns REQUIRED)     # ARPA
45 find_package(LibTASN1 REQUIRED)    # ARPA
46 find_package(OpenLDAP REQUIRED)    # ARPA
47 find_package(P11-Kit REQUIRED)     # ARPA
48 find_package(Quick-DER 1.2.4 REQUIRED NO_MODULE)  # Config
49 find_package(Unbound REQUIRED)     # ARPA
50 find_package(com_err REQUIRED)     # Local
51
52 # TODO: look for TLS-KDH
53
54 if(GnuTLSDane_FOUND)
55     add_definitions(-DHAVE_GNUTLS_DANE)
56 endif()
57
58
59 feature_summary(WHAT ALL VAR _features)
60 message(STATUS ${_features})
61
62 option(DEBUG "Produce debugging output (for developers)" OFF)
63
64 option(TEST_UNDER_TLSPOOL "Test under the assumption of an available TLS Pool" OFF)
65
66 option(EXPERIMENTAL_SRP_SUPPORT "Enable support for SRP based on relative file names" OFF)
67 if (EXPERIMENTAL_SRP_SUPPORT)
68     add_definitions(-DEXPERIMENTAL_SRP)
69 endif()
70
71 option(EXPERIMENTAL_LIBEV "Experiment with libev as a event backend" OFF)
72
73 # Constrain the acceptable STARTTLS driver names
74 # to those that are supported in our source code
75 # set_property (CACHE STARTTLS_DRIVER PROPERTY STRINGS gnutls openssl mbedtls)
76 if (NOT STARTTLS_DRIVER)
77     if (GnuTLS_FOUND)
78         set (STARTTLS_DRIVER gnutls CACHE STRING "Select the driving software for the STARTTLS feature")
79     endif()
80 endif()
81 if (NOT STARTTLS_DRIVER)
82     # For now, require a STARTTLS_DRIVER choice
83     # Later, consider using it to select available features (see PIOC_PING_V2)
84     message (FATAL_ERROR "You need _some_ driver for STARTTLS")
85 endif()
86 set_property (CACHE STARTTLS_DRIVER PROPERTY STRINGS gnutls)
87
88 # These are compile flags, not definitions, but it happens to work.
89 add_definitions(-fPIC -pthread)
90 if (DEBUG)
91         add_definitions (-ggdb3 -O0)
92 endif()
93 # Pretend we looked for pthread libraries, so that we can write
94 # cmake code that looks consistent.
95 set(pthread_LIBRARIES pthread)
96 # Always include the TLSPool top-level include/ dir.
97 include_directories(${CMAKE_SOURCE_DIR}/include)
98
99 enable_testing()
100
101 add_subdirectory(src)
102 add_subdirectory(lib)
103 add_subdirectory(tool)
104 add_subdirectory(pulleyback)
105 add_subdirectory(doc)
106 if(BUILD_TESTING)
107     add_subdirectory(test)
108 endif()