|
1 | | -cmake_minimum_required(VERSION 3.8.0) |
| 1 | +cmake_minimum_required(VERSION 3.14.0) |
2 | 2 |
|
3 | 3 | if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.29.20240416") |
4 | 4 | set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "0e5b6991-d74f-4b3d-a41c-cf096e0b2508") |
@@ -31,38 +31,95 @@ cmake_dependent_option(CTRE_BUILD_PACKAGE_RPM |
31 | 31 | "Create RPM Package (${PROJECT_NAME})" ON |
32 | 32 | "CTRE_BUILD_PACKAGE;CTRE_RPMBUILD_FOUND" OFF) |
33 | 33 |
|
34 | | -add_library(${PROJECT_NAME} INTERFACE) |
35 | | -add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) |
36 | | - |
37 | | -target_include_directories(${PROJECT_NAME} INTERFACE |
38 | | - $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> |
39 | | - $<INSTALL_INTERFACE:include>) |
40 | | - |
41 | | -if (NOT CTRE_CXX_STANDARD) |
42 | | - set(CTRE_CXX_STANDARD 20) |
43 | | -endif() |
44 | | - |
45 | | -target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_${CTRE_CXX_STANDARD}) |
46 | | - |
47 | | -if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.29.20240416") |
48 | | - add_library(${PROJECT_NAME}_module) |
49 | | - add_library(${PROJECT_NAME}::module ALIAS ${PROJECT_NAME}_module) |
50 | | - |
51 | | - target_sources(${PROJECT_NAME}_module PUBLIC FILE_SET CXX_MODULES FILES ctre.cppm) |
52 | | - |
53 | | - if (NOT CTRE_CXX_MODULE_STANDARD) |
54 | | - set(CTRE_CXX_MODULE_STANDARD ${CTRE_CXX_STANDARD}) |
| 34 | +option(CTRE_MODULE "build C++ module" OFF) |
| 35 | + |
| 36 | +if(CTRE_MODULE) |
| 37 | + if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.29.20240416") |
| 38 | + add_library(${PROJECT_NAME}) |
| 39 | + |
| 40 | + target_sources(${PROJECT_NAME} PUBLIC FILE_SET CXX_MODULES TYPE CXX_MODULES FILES ctre.cppm) |
| 41 | + target_sources(${PROJECT_NAME} PUBLIC FILE_SET HEADERS TYPE HEADERS FILES |
| 42 | + include/ctll.hpp |
| 43 | + include/ctre/functions.hpp |
| 44 | + include/ctre/utility.hpp |
| 45 | + include/ctre/utf8.hpp |
| 46 | + include/ctre/evaluation.hpp |
| 47 | + include/ctre/starts_with_anchor.hpp |
| 48 | + include/ctre/pcre_actions.hpp |
| 49 | + include/ctre/rotate.hpp |
| 50 | + include/ctre/iterators.hpp |
| 51 | + include/ctre/literals.hpp |
| 52 | + include/ctre/return_type.hpp |
| 53 | + include/ctre/find_captures.hpp |
| 54 | + include/ctre/id.hpp |
| 55 | + include/ctre/atoms_characters.hpp |
| 56 | + include/ctre/actions/mode.inc.hpp |
| 57 | + include/ctre/actions/characters.inc.hpp |
| 58 | + include/ctre/actions/class.inc.hpp |
| 59 | + include/ctre/actions/look.inc.hpp |
| 60 | + include/ctre/actions/sequence.inc.hpp |
| 61 | + include/ctre/actions/fusion.inc.hpp |
| 62 | + include/ctre/actions/asserts.inc.hpp |
| 63 | + include/ctre/actions/capture.inc.hpp |
| 64 | + include/ctre/actions/named_class.inc.hpp |
| 65 | + include/ctre/actions/backreference.inc.hpp |
| 66 | + include/ctre/actions/options.inc.hpp |
| 67 | + include/ctre/actions/atomic_group.inc.hpp |
| 68 | + include/ctre/actions/set.inc.hpp |
| 69 | + include/ctre/actions/hexdec.inc.hpp |
| 70 | + include/ctre/actions/repeat.inc.hpp |
| 71 | + include/ctre/actions/properties.inc.hpp |
| 72 | + include/ctre/actions/boundaries.inc.hpp |
| 73 | + include/ctre/operators.hpp |
| 74 | + include/ctre/pcre.hpp |
| 75 | + include/ctre/atoms_unicode.hpp |
| 76 | + include/ctre/range.hpp |
| 77 | + include/ctre/wrapper.hpp |
| 78 | + include/ctre/first.hpp |
| 79 | + include/ctre/flags_and_modes.hpp |
| 80 | + include/ctre/atoms.hpp |
| 81 | + include/unicode-db.hpp |
| 82 | + include/unicode-db/unicode_interface.hpp |
| 83 | + include/unicode-db/unicode-db.hpp |
| 84 | + include/ctll/parser.hpp |
| 85 | + include/ctll/actions.hpp |
| 86 | + include/ctll/fixed_string.hpp |
| 87 | + include/ctll/list.hpp |
| 88 | + include/ctll/utilities.hpp |
| 89 | + include/ctll/grammars.hpp |
| 90 | + include/ctre.hpp |
| 91 | + include/ctre-unicode.hpp |
| 92 | + ) |
| 93 | + |
| 94 | + # we are using `import std;` |
| 95 | + if (CTRE_CXX_STANDARD LESS 23) |
| 96 | + set(CTRE_CXX_STANDARD 23) |
| 97 | + endif() |
| 98 | + |
| 99 | + target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) |
| 100 | + target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_${CTRE_CXX_STANDARD}) |
| 101 | + else() |
| 102 | + message(FATAL_ERROR "unsupported cmake for c++ modules") |
55 | 103 | endif() |
| 104 | +else() |
| 105 | + add_library(${PROJECT_NAME} INTERFACE) |
56 | 106 |
|
57 | | - if (CTRE_CXX_MODULE_STANDARD LESS 23) |
58 | | - set(CTRE_CXX_MODULE_STANDARD 23) |
| 107 | + target_include_directories(${PROJECT_NAME} INTERFACE |
| 108 | + $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> |
| 109 | + $<INSTALL_INTERFACE:include>) |
| 110 | + |
| 111 | + if (NOT CTRE_CXX_STANDARD) |
| 112 | + set(CTRE_CXX_STANDARD 20) |
59 | 113 | endif() |
60 | 114 |
|
61 | | - target_compile_features(${PROJECT_NAME}_module PUBLIC cxx_std_${CTRE_CXX_MODULE_STANDARD}) |
62 | | - target_link_libraries(${PROJECT_NAME}_module PRIVATE ${PROJECT_NAME}) |
| 115 | + target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_${CTRE_CXX_STANDARD}) |
| 116 | + |
| 117 | + install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-targets) |
63 | 118 | endif() |
64 | 119 |
|
65 | | -install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-targets) |
| 120 | +add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) |
| 121 | + |
| 122 | +if (NOT CTRE_MODULE) |
66 | 123 |
|
67 | 124 | if (NOT EXISTS "${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake.in") |
68 | 125 | file(WRITE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake.in [[ |
@@ -132,3 +189,5 @@ install(FILES "${PKG_CONFIG_FILE_NAME}" |
132 | 189 | list(APPEND CPACK_SOURCE_IGNORE_FILES /.git/ /build/ .gitignore .DS_Store) |
133 | 190 |
|
134 | 191 | include(CPack) |
| 192 | + |
| 193 | +endif() |
0 commit comments