-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
124 lines (101 loc) · 4.21 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
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
#----------------------------------------------------------------------------------------
# Copyright (C) Electronic Arts Inc. All rights reserved.
#----------------------------------------------------------------------------------------
cmake_minimum_required (VERSION 3.21)
project(Fonttik CXX)
# ---------------------------------------------------------------------------------------
# Options
# ---------------------------------------------------------------------------------------
option(BUILD_TESTS "Build library tests" OFF)
option(BUILD_APPS "Build Fonttik console application" OFF)
option(BUILD_BENCHMAKRS "Build Fonttik benchmarks" OFF)
option(EXPORT_FONTTIK "Export and install library" OFF)
# ---------------------------------------------------------------------------------------
# Compiler Config
# ---------------------------------------------------------------------------------------
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# ---------------------------------------------------------------------------------------
# CUDA feature
# ---------------------------------------------------------------------------------------
if($CACHE{CUDA})
list(APPEND VCPKG_MANIFEST_FEATURES "cuda-opencv")
endif()
# ---------------------------------------------------------------------------------------
# Fonttik Library
# ---------------------------------------------------------------------------------------
# Define source files
file(GLOB_RECURSE HEADER_FILES ./include/fonttik/*.h)
file(GLOB_RECURSE PRIVATE_HEADER_FILES ./src/*.h)
file(GLOB_RECURSE SOURCE_FILES ./src/*.cpp)
# Dependencies
find_package(OpenCV CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
find_package(spdlog CONFIG REQUIRED)
# Library definition
add_library(fonttik STATIC ${SOURCE_FILES} ${PRIVATE_HEADER_FILES})
target_include_directories(fonttik
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
set_target_properties(fonttik PROPERTIES
PUBLIC_HEADER "${HEADER_FILES}"
)
target_link_libraries(fonttik PUBLIC
${OpenCV_LIBS}
nlohmann_json nlohmann_json::nlohmann_json
spdlog::spdlog
)
# ---------------------------------------------------------------------------------------
# Export Target
# ---------------------------------------------------------------------------------------
if(EXPORT_FONTTIK)
message("Install targets")
install(TARGETS fonttik EXPORT FonttikTargets ARCHIVE
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/fonttik
)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data
DESTINATION ${CMAKE_INSTALL_LIBDIR}
DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(EXPORT FonttikTargets
DESTINATION ${CMAKE_INSTALL_LIBDIR}/fonttik/cmake
NAMESPACE fonttik::
)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/fonttik)
configure_package_config_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/FonttikConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/FonttikConfig.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/fonttik/cmake
PATH_VARS LIB_INSTALL_DIR
)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/FonttikConfig.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/fonttik/cmake
)
endif()
# ---------------------------------------------------------------------------------------
# Build Fonttik Apps
# ---------------------------------------------------------------------------------------
if(BUILD_APPS)
message("Build Fonttik Apps")
add_subdirectory ("apps/FonttikApp")
add_subdirectory ("apps/FonttikApp_MT")
endif()
# ---------------------------------------------------------------------------------------
# Build Tests
# ---------------------------------------------------------------------------------------
if(BUILD_TESTS)
message("Build tests")
enable_testing()
add_subdirectory("tests/Fonttik.Tests")
add_subdirectory("tests/AddressSanitizer.Tests")
endif()
# ---------------------------------------------------------------------------------------
# Build Benchmarks
# ---------------------------------------------------------------------------------------
if(BUILD_BENCHMAKRS)
message("Build benchmarks")
add_subdirectory(benchmarks)
endif()