This repository has been archived by the owner on Dec 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
92 lines (83 loc) · 4.58 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
# Copyright (C) 2018-2019 Jonathan Müller <[email protected]>
# This file is subject to the license terms in the LICENSE file
# found in the top-level directory of this distribution.
cmake_minimum_required(VERSION 3.8)
project(foonathan_lex VERSION 0.0.0)
include(external/external.cmake)
set(detail_header_files
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/detail/assert.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/detail/production_rule_base.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/detail/production_rule_postprocess.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/detail/production_rule_production.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/detail/production_rule_token.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/detail/select_integer.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/detail/string.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/detail/trie.hpp
)
set(header_files
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/ascii.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/grammar.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/identifier_token.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/list_production.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/literal_token.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/match_result.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/operator_production.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/parse_error.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/parse_result.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/parser.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/production_kind.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/rule_production.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/rule_token.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/spelling.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/token.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/token_kind.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/token_regex.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/token_spec.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/tokenizer.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/lex/whitespace_token.hpp)
# main target
add_library(foonathan_lex INTERFACE)
add_library(foonathan::foonathan_lex ALIAS foonathan_lex)
target_compile_features(foonathan_lex INTERFACE cxx_std_14)
target_link_libraries(foonathan_lex INTERFACE debug_assert foonathan_lex_mp11)
target_sources(foonathan_lex INTERFACE "$<BUILD_INTERFACE:${detail_header_files};${header_files}>")
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
target_include_directories(foonathan_lex INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:include/>)
else()
target_include_directories(foonathan_lex SYSTEM INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:include/>)
endif()
# installation
if(NOT dependency_via_submodule)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(foonathan_lex-config-version.cmake COMPATIBILITY ExactVersion)
install(TARGETS foonathan_lex foonathan_lex_mp11 EXPORT foonathan_lex_targets
INCLUDES DESTINATION include)
install(EXPORT foonathan_lex_targets
DESTINATION lib/cmake/foonathan_lex
FILE foonathan_lex-targets.cmake
NAMESPACE foonathan::)
install(DIRECTORY include/
DESTINATION include)
install(FILES foonathan_lex-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/foonathan_lex-config-version.cmake
DESTINATION lib/cmake/foonathan_lex)
else()
message(STATUS "Dependency installed via submodule, installation unavailable")
endif()
# subdirectories
option(FOONATHAN_LEX_BUILD_TEST "build tests of foonathan/lex" OFF)
if(${FOONATHAN_LEX_BUILD_TEST} OR (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR))
enable_testing()
add_subdirectory(test)
endif()
option(FOONATHAN_LEX_BUILD_BENCHMARK "build benchmarks of foonathan/lex" OFF)
if(${FOONATHAN_LEX_BUILD_TEST} OR (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR))
add_subdirectory(benchmark)
endif()
option(FOONATHAN_LEX_BUILD_EXAMPLE "build examples of foonathan/lex" OFF)
if(${FOONATHAN_LEX_BUILD_EXAMPLE} OR (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR))
add_subdirectory(example)
endif()