forked from AndreLouisCaron/cscgi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
113 lines (95 loc) · 3.22 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Copyright (c) 2011-2012, Andre Caron ([email protected])
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# Simple Common Gateway Interface protocol implementation in C.
#
cmake_minimum_required(VERSION 2.6)
project(cscgi)
option(CSCGI_BUILD_CXX "Build C++ wrappers." ON)
option(CSCGI_BUILD_DEMOS "Build demo programs." ON)
option(CSCGI_BUILD_TESTS "Build test programs." ON)
option(CSCGI_SHARED_LIBS "Build cscgi shared library." OFF)
# Add targets for library referenced as Git submodule.
macro(add_submodule name)
if(${ARGN1})
set(${name}_DIR ${ARGN1})
else()
set(${name}_DIR ${CMAKE_SOURCE_DIR}/libs/${name})
endif()
find_package(${name})
endmacro()
# Compile API documentation from source code.
function(add_api_documentation target)
if(DOXYGEN_EXECUTABLE)
add_custom_target(
${target}
COMMAND
${DOXYGEN_EXECUTABLE}
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}
COMMENT
"Compiling documentation."
VERBATIM
)
endif()
endfunction()
if(MSVC)
# Ignore Microsoft's recommendations of
# safety at the expense of portability.
add_definitions(
-D_CRT_SECURE_NO_WARNINGS
-D_SCL_SECURE_NO_WARNINGS
-D_CRT_NONSTDC_NO_WARNINGS
)
endif()
enable_testing()
# Put all libraries and executables in the build folder root.
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR})
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
# Build required libraries.
add_submodule(cnetstring)
# Build the primary target.
include_directories(
${cnetstring_include_dirs}
)
add_subdirectory(code)
# Optional targets (skip when building as a dependency).
if(${PROJECT_NAME} STREQUAL ${CMAKE_PROJECT_NAME})
# Build API documentation.
find_package(Doxygen QUIET)
configure_file(
${CMAKE_SOURCE_DIR}/help/Doxyfile
${CMAKE_BINARY_DIR}/Doxyfile @ONLY)
add_api_documentation(help)
# Resolve include directives as if installed on the system.
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/code)
# Configure the library and its dependencies.
set(cscgi_libraries
scgi ${cnetstring_libraries}
)
# Build demo projects.
if(CSCGI_BUILD_DEMOS)
add_subdirectory(demo)
endif()
# Register unit tests.
if(CSCGI_BUILD_TESTS)
add_subdirectory(test)
endif()
endif()