forked from foonathan/lexy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
79 lines (66 loc) · 3.23 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
# Copyright (C) 2020-2023 Jonathan Müller and lexy contributors
# SPDX-License-Identifier: BSL-1.0
cmake_minimum_required(VERSION 3.8)
project(lexy VERSION 2022.12.1 LANGUAGES CXX)
set(LEXY_USER_CONFIG_HEADER "" CACHE FILEPATH "The user config header for lexy.")
option(LEXY_FORCE_CPP17 "Whether or not lexy should use C++17 even if compiler supports C++20." OFF)
add_subdirectory(src)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
cmake_minimum_required(VERSION 3.18)
option(LEXY_BUILD_BENCHMARKS "whether or not benchmarks should be built" OFF)
option(LEXY_BUILD_EXAMPLES "whether or not examples should be built" ON)
option(LEXY_BUILD_TESTS "whether or not tests should be built" ON)
option(LEXY_BUILD_DOCS "whether or not docs should be built" OFF)
option(LEXY_BUILD_PACKAGE "whether or not the package should be built" ON)
option(LEXY_ENABLE_INSTALL "whether or not to enable the install rule" ON)
if(LEXY_BUILD_PACKAGE)
set(package_files include/ src/ cmake/ CMakeLists.txt LICENSE)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lexy-src.zip
COMMAND ${CMAKE_COMMAND} -E tar c ${CMAKE_CURRENT_BINARY_DIR}/lexy-src.zip --format=zip -- ${package_files}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${package_files})
add_custom_target(lexy_package DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/lexy-src.zip)
endif()
if(LEXY_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
if(LEXY_BUILD_BENCHMARKS)
add_subdirectory(benchmarks)
endif()
if(LEXY_BUILD_TESTS)
set(DOCTEST_NO_INSTALL ON)
enable_testing()
add_subdirectory(tests)
endif()
if(LEXY_BUILD_DOCS)
add_subdirectory(docs EXCLUDE_FROM_ALL)
endif()
if(LEXY_ENABLE_INSTALL)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
install(TARGETS lexy lexy_core lexy_file lexy_unicode lexy_ext _lexy_base lexy_dev
EXPORT ${PROJECT_NAME}Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(EXPORT ${PROJECT_NAME}Targets
NAMESPACE foonathan::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
configure_package_config_file(
cmake/lexyConfig.cmake.in
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
# YYYY.MM.N1 is compatible with YYYY.MM.N2.
write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
COMPATIBILITY SameMinorVersion)
install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
install(DIRECTORY include/lexy include/lexy_ext
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN "*.hpp")
endif()
endif()