-
Notifications
You must be signed in to change notification settings - Fork 15
/
CMakeLists.txt
152 lines (134 loc) · 4.28 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
cmake_minimum_required(VERSION 3.0.0)
project(libfunctionality)
set(libfunctionality_VERSION 0.2)
###
# Configuration Options
###
option(BUILD_SHARED_LIBS "Should we build as a shared library? Note that this doesn't affect whether we can load shared libraries." ON)
option(BUILD_WITH_DYNAMIC_SUPPORT "Should we support dynamically-loaded plugins? Note that this is the only implemented mode right now" ON)
if(NOT BUILD_WITH_DYNAMIC_SUPPORT)
message(FATAL_ERROR "Dynamically-loaded plugin support is presently the only support implemented!")
endif()
###
# CMake Modules
###
# Custom CMake modules from https://github.com/rpavlik/cmake-modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(CTest)
include(GNUInstallDirs)
if(NOT CMAKE_INSTALL_DOCDIR)
set(CMAKE_INSTALL_DOCDIR ${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME})
endif()
include(CMakeDependentOption)
find_program(CLANGTIDY_COMMAND
NAMES
clang-tidy
clang-tidy.exe
clang-tidy-6.0
clang-tidy-6.0.exe)
cmake_dependent_option(BUILD_WITH_CLANG_TIDY "Run the clang-tidy static analysis/lint tool during the build?" ON
"CLANGTIDY_COMMAND" OFF)
cmake_dependent_option(BUILD_WITH_CLANG_TIDY_FIXIT "Run the clang-tidy static analysis/lint tool in --fix mode during the build?" OFF
"CLANGTIDY_COMMAND;BUILD_WITH_CLANG_TIDY" OFF)
###
# Set up build directories
###
# Set up shared destination directories to avoid Windows hassle with DLL search paths.
set(EXECUTABLE_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${EXECUTABLE_BINARY_DIR}")
endif()
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
if(WIN32)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${EXECUTABLE_BINARY_DIR}")
else()
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
endif()
endif()
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${EXECUTABLE_BINARY_DIR}")
endif()
if(NOT WIN32 AND NOT APPLE)
set(CMAKE_INSTALL_RPATH "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
endif()
###
# Building
###
set(INCLUDE_BASE "${CMAKE_CURRENT_SOURCE_DIR}/inc")
if(WIN32)
set(CMAKE_DEBUG_POSTFIX "d")
endif()
add_subdirectory(src/libfunctionality)
if(WIN32)
set(CMAKE_DEBUG_POSTFIX "")
endif()
if(BUILD_TESTING)
if(WIN32)
set(gtest_force_shared_crt ON)
endif()
if(MSVC_VERSION EQUAL 1700)
add_definitions(/D_VARIADIC_MAX=10)
endif()
add_subdirectory(vendor/gtest-1.7.0)
add_subdirectory(tests)
endif()
###
# Build and install documentation
###
include(DoxygenTargets)
add_doxygen("${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile" NO_PDF)
if(WIN32)
set(README_DEST .)
else()
set(README_DEST "${CMAKE_INSTALL_DOCDIR}")
endif()
# For generating documentation in HTML
find_package(Markdown)
set(README_MARKDOWN
README.md
CONTRIBUTING.md)
if(MARKDOWN_FOUND)
include(UseMarkdown)
add_markdown_target(markdown-readme ${CMAKE_CURRENT_BINARY_DIR} ${README_MARKDOWN})
install_markdown_target(markdown-readme DESTINATION "${README_DEST}" COMPONENT Runtime)
else()
install(FILES ${README_MARKDOWN}
DESTINATION "${README_DEST}"
COMPONENT Runtime)
endif()
install(FILES LICENSE NOTICE
DESTINATION "${README_DEST}"
COMPONENT Runtime)
###
# Set Up Package for External Usage
###
include(CMakePackageConfigHelpers)
include(GenerateCompatibilityVersionFile)
set(CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/libfunctionality")
generate_compatibility_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/libfunctionalityConfigVersion.cmake"
VERSION ${libfunctionality_VERSION}
COMPATIBILITY AnyNewerVersion
C_ABI)
export(EXPORT libfunctionalityTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/libfunctionalityTargets.cmake"
NAMESPACE libfunctionality::)
export(PACKAGE libfunctionality)
configure_file(libfunctionalityConfig.cmake
"${CMAKE_CURRENT_BINARY_DIR}/libfunctionalityConfig.cmake"
COPYONLY)
install(EXPORT libfunctionalityTargets
FILE
libfunctionalityTargets.cmake
NAMESPACE
libfunctionality::
DESTINATION
${CONFIG_INSTALL_DIR})
install(FILES
libfunctionalityConfig.cmake
"${CMAKE_CURRENT_BINARY_DIR}/libfunctionalityConfigVersion.cmake"
DESTINATION
${CONFIG_INSTALL_DIR}
COMPONENT
Devel)