-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
91 lines (74 loc) · 2.37 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
cmake_minimum_required(VERSION 3.26)
# CMAKE INCLUDES
list(PREPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/external/cmake/)
include(CMakePrintHelpers)
include(cmtk/CppLibraryProject)
# CONFIGURATION
disable_in_source_build()
set_build_type_ifndef()
# C++ PROJECT
set(PROJECT_NAME "arba-wgen")
set(project_namespace "arba")
set(project_base_name "wgen")
set(PROJECT_VERSION 0.2.0)
project(${PROJECT_NAME}
VERSION ${PROJECT_VERSION}
DESCRIPTION "A C++ library providing functions generating random words."
HOMEPAGE_URL "https://github.com/arapelle/arba-wgen"
LANGUAGES CXX)
message(STATUS "PROJECT: ${PROJECT_NAME} ${PROJECT_VERSION} ${CMAKE_BUILD_TYPE}")
include(CTest)
# C++ LIBRARY
## Generated/Configured headers:
generate_version_macro_header(generated_version_header
${project_namespace}_${project_base_name}
${project_namespace}/${project_base_name}/version.hpp)
## Headers:
set(headers
include/arba/wgen/default_syllabary.hpp
include/arba/wgen/syllabary.hpp
)
## Sources:
set(sources
src/default_syllabary.cpp
src/syllabary.cpp
)
## Add C++ library:
add_cpp_library(
SHARED ${PROJECT_NAME}
STATIC ${PROJECT_NAME}-static
BUILD_SHARED BUILD_arba-arba
BUILD_STATIC BUILD_arba-arba-static
HEADERS ${headers} ${generated_version_header}
SOURCES ${sources}
CXX_STANDARD 20
)
## Link C++ targets:
if(NOT TARGET arba-strn)
find_package(arba-strn 0.2.0 REQUIRED CONFIG)
endif()
cpp_library_link_libraries(
SHARED ${PROJECT_NAME}
STATIC ${PROJECT_NAME}-static
PUBLIC
arba-strn
)
## Install C++ library:
install_cpp_library(
SHARED ${PROJECT_NAME}
STATIC ${PROJECT_NAME}-static
EXPORT ${PROJECT_NAME}-targets
)
## Install project package
install_library_package(${PROJECT_NAME} INPUT_PACKAGE_CONFIG_FILE cmake/config/package-config.cmake.in)
install_uninstall_script(${PROJECT_NAME} FILENAME uninstall.cmake)
## Add tests:
option_or_set_ifdef(BUILD_${PROJECT_NAME}_TESTS "Build ${PROJECT_NAME} tests or not" OFF BUILD_arba-arba_TESTS)
if(BUILD_${PROJECT_NAME}_TESTS AND BUILD_TESTING)
add_subdirectory(test)
endif()
## Add examples:
option_or_set_ifdef(BUILD_${PROJECT_NAME}_EXAMPLES "Build ${PROJECT_NAME} examples or not" OFF BUILD_arba-arba_EXAMPLES)
if(BUILD_${PROJECT_NAME}_EXAMPLES AND BUILD_TESTING)
add_subdirectory(example)
endif()