-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
160 lines (131 loc) · 4.92 KB
/
CMakeLists.txt
File metadata and controls
160 lines (131 loc) · 4.92 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
cmake_minimum_required(VERSION 3.20)
project(Vextr VERSION 0.1.1 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POLICY_VERSION_MINIMUM 3.5)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(VEXTR_IS_TOPLEVEL ON)
else()
set(VEXTR_IS_TOPLEVEL OFF)
endif()
option(VEXTR_BUILD_TESTS "Build Vextr tests" ${VEXTR_IS_TOPLEVEL})
option(VEXTR_BUILD_EXAMPLES "Build Vextr examples" ${VEXTR_IS_TOPLEVEL})
option(VEXTR_BUILD_DOCS "Build Vextr docs" ${VEXTR_IS_TOPLEVEL})
if(MSVC)
add_compile_options(/W3)
else()
add_compile_options(-Wall -Wextra)
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
# ============================================================================
# DEPENDENCIES
# ============================================================================
include(FetchContent)
# utf8proc — always needed (Vextr links it)
FetchContent_Declare(
utf8proc
GIT_REPOSITORY https://github.com/JuliaStrings/utf8proc.git
GIT_TAG v2.9.0
EXCLUDE_FROM_ALL
)
FetchContent_MakeAvailable(utf8proc)
# GoogleTest — only when building tests
if(VEXTR_BUILD_TESTS)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0
EXCLUDE_FROM_ALL
)
FetchContent_MakeAvailable(googletest)
endif()
# ============================================================================
# LIBRARY: Vextr
# ============================================================================
file(GLOB_RECURSE VEXTR_SRC CONFIGURE_DEPENDS src/*.cpp)
add_library(vextr STATIC ${VEXTR_SRC})
add_library(vextr::vextr ALIAS vextr)
target_include_directories(vextr
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(vextr PUBLIC utf8proc)
# ============================================================================
# INSTALL
# ============================================================================
include(GNUInstallDirs)
install(TARGETS vextr
EXPORT vextrTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(DIRECTORY include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
# ============================================================================
# EXAMPLES
# ============================================================================
if(VEXTR_BUILD_EXAMPLES)
function(add_example name)
add_executable(${name} examples/${name}/main.cpp)
target_link_libraries(${name} PRIVATE vextr)
target_include_directories(${name} PRIVATE examples)
endfunction()
add_example(layout_example)
add_example(focus_example)
add_example(button_example)
add_example(navigator_example)
add_example(input_example)
add_example(border_example)
add_example(overlay_example)
add_example(scrollview_example)
add_example(text_widgets_example)
endif()
# ============================================================================
# TESTING
# ============================================================================
if(VEXTR_BUILD_TESTS)
include(GoogleTest)
enable_testing()
add_executable(vextr_tests
tests/main.cpp
tests/test_geometry.cpp
tests/test_input_parser.cpp
tests/test_label_widget.cpp
tests/test_text_view.cpp
tests/test_text_area.cpp
tests/test_scroll_view.cpp
tests/test_unicode.cpp
tests/test_app.cpp
)
target_link_libraries(vextr_tests PRIVATE vextr gtest gtest_main)
target_include_directories(vextr_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
gtest_discover_tests(vextr_tests WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()
# ============================================================================
# DOCUMENTATION (Doxygen)
# ============================================================================
if(VEXTR_BUILD_DOCS)
find_package(Doxygen)
if(DOXYGEN_FOUND)
set(DOXYGEN_PROJECT_NAME ${PROJECT_NAME})
set(DOXYGEN_PROJECT_NUMBER ${PROJECT_VERSION})
set(DOXYGEN_GENERATE_HTML NO)
set(DOXYGEN_GENERATE_XML YES)
set(DOXYGEN_XML_OUTPUT ${CMAKE_SOURCE_DIR}/docs/doxygen-xml)
set(DOXYGEN_RECURSIVE YES)
doxygen_add_docs(vextr_docs
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/src
COMMENT "Generating Doxygen XML"
)
else()
message(STATUS "Doxygen not found, skipping docs target.")
endif()
endif()