-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
115 lines (91 loc) · 3.76 KB
/
Copy pathCMakeLists.txt
File metadata and controls
115 lines (91 loc) · 3.76 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
cmake_minimum_required(VERSION 3.18)
project(vxcore
VERSION 0.1.0
DESCRIPTION "VNote Core Library - Cross-platform note management engine"
LANGUAGES CXX C
)
option(VXCORE_BUILD_SHARED "Build shared library" ON)
option(VXCORE_BUILD_CLI "Build command-line interface" ON)
option(VXCORE_BUILD_TESTS "Build tests" ON)
option(VXCORE_BUILD_TOOLS "Build diagnostic tools" OFF)
option(VXCORE_INSTALL "Enable install targets" ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Disable Qt's AUTOMOC/AUTOUIC/AUTORCC for this pure C/C++ library
# (prevents warnings when built as subdirectory of Qt projects)
set(CMAKE_AUTOMOC OFF)
set(CMAKE_AUTOUIC OFF)
set(CMAKE_AUTORCC OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
find_package(Threads REQUIRED)
# OpenSSL is only required on Linux; Windows uses WinHTTP and macOS uses SecureTransport.
if(UNIX AND NOT APPLE)
find_package(OpenSSL REQUIRED)
endif()
# MSVC: enable C++ exception unwinding (/EHsc). Without this, try/catch blocks
# emit C4530 warnings AND don't actually unwind at runtime — uncaught exceptions
# trigger std::terminate() → abort() → "VC++ Runtime Library" modal dialog,
# breaking tests like test_git_options::malformed_json_falls_back_to_defaults
# that legitimately expect nlohmann::json::parse to throw.
# Using add_compile_options (NOT target_compile_options) propagates to vxcore
# lib + CLI + every test target via subdirectory inheritance.
if(MSVC)
add_compile_options(/EHsc)
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)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
add_subdirectory(third_party)
# Discover Iconv after libgit2: leaking ICONV_FOUND into its configuration
# enables Unicode precomposition on Linux and can close an uninitialized handle.
# Keep the imported target in this scope for both src and standalone tests.
if(NOT WIN32)
find_package(Iconv REQUIRED)
endif()
add_subdirectory(src)
if(VXCORE_BUILD_CLI)
add_subdirectory(cli)
endif()
if(VXCORE_BUILD_TOOLS)
add_subdirectory(tools/search-validate)
endif()
if(VXCORE_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
if(VXCORE_INSTALL)
include(GNUInstallDirs)
get_target_property(_vxcore_sodium_source_dir sodium SOURCE_DIR)
install(FILES "${_vxcore_sodium_source_dir}/libsodium/LICENSE"
DESTINATION ${CMAKE_INSTALL_DATADIR}/licenses/vxcore RENAME LICENSE.libsodium)
install(FILES "${_vxcore_sodium_source_dir}/LICENSE"
DESTINATION ${CMAKE_INSTALL_DATADIR}/licenses/vxcore RENAME LICENSE.libsodium-cmake)
get_target_property(_vxcore_pugixml_license pugixml VXCORE_LICENSE_FILE)
install(FILES "${_vxcore_pugixml_license}"
DESTINATION ${CMAKE_INSTALL_DATADIR}/licenses/vxcore RENAME LICENSE.pugixml)
if(NOT APPLE)
get_target_property(_vxcore_curl_license vxcore_webdav_curl VXCORE_LICENSE_FILE)
install(FILES "${_vxcore_curl_license}"
DESTINATION ${CMAKE_INSTALL_DATADIR}/licenses/vxcore RENAME LICENSE.curl)
endif()
install(DIRECTORY include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h"
)
install(DIRECTORY data/
DESTINATION ${CMAKE_INSTALL_BINDIR}/data
FILES_MATCHING PATTERN "*.json"
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/vxcore-config-version.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/vxcore-config-version.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/vxcore
)
endif()