-
Notifications
You must be signed in to change notification settings - Fork 18
/
CMakeLists.txt
109 lines (88 loc) · 3.24 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
#
# Copyright 2021 SpriteOvO
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
cmake_minimum_required(VERSION 3.13)
if (DEFINED PROJECT_NAME)
set(SIGMATCH_STANDALONE OFF)
else()
set(SIGMATCH_STANDALONE ON)
endif()
option(SIGMATCH_BUILD_TESTS "Build tests" ON)
include(CMakeDependentOption)
cmake_dependent_option(SIGMATCH_DEV_MODE "Development mode" ON "SIGMATCH_STANDALONE" OFF)
cmake_dependent_option(SIGMATCH_GENERATE_DOCS "Generate docs" OFF "SIGMATCH_STANDALONE" OFF)
cmake_dependent_option(SIGMATCH_BUILD_EXAMPLES "Build examples" ON "SIGMATCH_STANDALONE" OFF)
cmake_dependent_option(SIGMATCH_BUILD_BENCHMARKS "Build benchmarks" ON "SIGMATCH_STANDALONE" OFF)
if (SIGMATCH_DEV_MODE)
if (MSVC)
add_compile_options(
"/W4" # Warning level = Level4
"/WX" # Treat warnings as errors = Yes
"/MP" # Multi-processor compilation = Yes
"/Zc:preprocessor" # Enable MSVC preprocessor conformance
)
endif()
endif()
project(sigmatch LANGUAGES CXX VERSION 0.2.0)
add_library(sigmatch INTERFACE)
add_library(sigmatch::sigmatch ALIAS sigmatch)
target_include_directories(
sigmatch INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
target_compile_features(sigmatch INTERFACE cxx_std_20)
if (SIGMATCH_BUILD_TESTS)
include(CTest)
add_subdirectory(tests)
endif()
if (SIGMATCH_GENERATE_DOCS)
find_package(Doxygen)
if (NOT DOXYGEN_FOUND)
message(FATAL_ERROR "Doxygen not found.")
endif()
message("Doxygen version: ${DOXYGEN_VERSION}")
set(DOXYGEN_PREDEFINED "SIGMATCH_DOXYGEN")
set(DOXYGEN_SORT_MEMBER_DOCS "NO")
doxygen_add_docs(
sigmatch_docs
"include/sigmatch/sigmatch.hpp"
"README.md"
ALL
COMMENT "Documentations generating..."
)
endif()
if (SIGMATCH_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
if (SIGMATCH_BUILD_BENCHMARKS)
# TODO
endif()
# Install
set(SIGMATCH_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include")
set(SIGMATCH_INSTALL_CMAKE_DIR "${CMAKE_INSTALL_PREFIX}/lib/cmake/sigmatch")
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/sigmatch-config-version.cmake
VERSION ${sigmatch_VERSION}
COMPATIBILITY ExactVersion
)
install(DIRECTORY include/ DESTINATION ${SIGMATCH_INSTALL_INCLUDE_DIR})
install(TARGETS sigmatch EXPORT sigmatch-targets)
install(EXPORT sigmatch-targets NAMESPACE sigmatch:: DESTINATION "${SIGMATCH_INSTALL_CMAKE_DIR}")
install(
FILES cmake/sigmatch-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/sigmatch-config-version.cmake
DESTINATION "${SIGMATCH_INSTALL_CMAKE_DIR}"
)