-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
192 lines (141 loc) · 5.36 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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
cmake_minimum_required (VERSION 3.25 FATAL_ERROR)
project (
lfilesystem
VERSION 0.0.1
LANGUAGES CXX C
DESCRIPTION "C++ filesystem library"
HOMEPAGE_URL "https://github.com/benthevining/lfilesystem/")
include (CMakeDependentOption)
cmake_dependent_option (LFILE_TESTS "Build the lfilesystem tests" "${lfilesystem_IS_TOP_LEVEL}"
"NOT IOS" OFF)
option (LFILE_DOCS "Build the lfilesystem docs" "${lfilesystem_IS_TOP_LEVEL}")
include (GNUInstallDirs)
set (LFILE_INSTALL_DEST "${CMAKE_INSTALL_LIBDIR}/cmake/lfilesystem"
CACHE STRING "Path where package files will be installed, relative to the install prefix")
mark_as_advanced (LFILE_INSTALL_DEST LFILE_TESTS LFILE_DOCS)
set_property (DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES "${CMAKE_CURRENT_LIST_DIR}/logs"
"${CMAKE_CURRENT_LIST_DIR}/deploy")
add_library (lfilesystem)
add_library (limes::lfilesystem ALIAS lfilesystem)
target_compile_features (lfilesystem PUBLIC cxx_std_20)
set_target_properties (lfilesystem PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN
ON)
set (public_header include/lfilesystem/lfilesystem.h)
set (
private_headers
include/lfilesystem/lfilesystem_CFile.h
include/lfilesystem/lfilesystem_Directory.h
include/lfilesystem/lfilesystem_DynamicLibrary.h
include/lfilesystem/lfilesystem_File.h
include/lfilesystem/lfilesystem_FilesystemEntry.h
include/lfilesystem/lfilesystem_FileWatcher.h
include/lfilesystem/lfilesystem_Misc.h
include/lfilesystem/lfilesystem_Paths.h
include/lfilesystem/lfilesystem_Permissions.h
include/lfilesystem/lfilesystem_SimpleWatcher.h
include/lfilesystem/lfilesystem_SpecialDirectories.h
include/lfilesystem/lfilesystem_SymLink.h
include/lfilesystem/lfilesystem_Volume.h)
set (export_header "${CMAKE_CURRENT_BINARY_DIR}/generated/lfilesystem/lfilesystem_Export.h")
include (GenerateExportHeader)
generate_export_header (
lfilesystem
EXPORT_MACRO_NAME
LFILE_EXPORT
NO_EXPORT_MACRO_NAME
LFILE_NO_EXPORT
EXPORT_FILE_NAME
"${export_header}")
target_sources (lfilesystem # PUBLIC "${public_header}"
PRIVATE ${private_headers} "${export_header}")
target_include_directories (
lfilesystem
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
install (FILES "${public_header}" "${export_header}" ${private_headers}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/lfilesystem" COMPONENT lfilesystem_dev)
if (APPLE)
enable_language (OBJCXX)
target_link_libraries (lfilesystem PRIVATE "-framework Foundation")
if (NOT IOS)
target_link_libraries (lfilesystem PRIVATE "-framework AppKit")
endif ()
elseif (WIN32)
target_compile_definitions (lfilesystem PRIVATE NOMINMAX)
elseif (LINUX)
include (CheckCXXSourceCompiles)
check_cxx_source_compiles (
"
#include <unistd.h>
#include <string>
int main (int, char**)
{
const std::string path { \"/some/file/path.txt\" };
[[maybe_unused]] auto result = pathconf (path.data(), _PC_CASE_SENSITIVE);
return 0;
}
"
limes_files_can_use_pathconf)
if (limes_files_can_use_pathconf)
target_compile_definitions (lfilesystem PRIVATE LFILE_IMPL_USE_PATHCONF=1)
else ()
target_compile_definitions (lfilesystem PRIVATE LFILE_IMPL_USE_PATHCONF=0)
endif ()
endif ()
if (EMSCRIPTEN)
target_compile_options (lfilesystem PRIVATE -sNO_DISABLE_EXCEPTION_CATCHING -fexceptions)
target_link_options (lfilesystem PRIVATE -fexceptions)
endif ()
target_link_libraries (lfilesystem PRIVATE ${CMAKE_DL_LIBS})
add_subdirectory (src)
install (
TARGETS lfilesystem
EXPORT lfilesystem
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lfilesystem
NAMELINK_COMPONENT lfilesystem_dev
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lfilesystem_dev
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT lfilesystem
INCLUDES
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install (
EXPORT lfilesystem
NAMESPACE limes::
FILE Targets.cmake
DESTINATION "${LFILE_INSTALL_DEST}"
COMPONENT lfilesystem_dev)
include (CMakePackageConfigHelpers)
write_basic_package_version_file (lfilesystem-config-version.cmake VERSION "${lfilesystem_VERSION}"
COMPATIBILITY SameMajorVersion)
configure_package_config_file (cmake/lfilesystem-config.in lfilesystem-config.cmake
INSTALL_DESTINATION "${LFILE_INSTALL_DEST}" NO_SET_AND_CHECK_MACRO)
install (FILES "${CMAKE_CURRENT_BINARY_DIR}/lfilesystem-config-version.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/lfilesystem-config.cmake"
DESTINATION "${LFILE_INSTALL_DEST}" COMPONENT lfilesystem_dev)
include (CPackComponent)
cpack_add_component (
lfilesystem
DISPLAY_NAME "Limes filesystem library"
DESCRIPTION
"The Limes C++ filesystem library. This is the runtime component needed by end users."
GROUP limes_files)
cpack_add_component (
lfilesystem_dev
DISPLAY_NAME "Limes filesystem library headers"
DESCRIPTION
"Development package for the Limes C++ filesystem library. This component includes the library's header files and CMake package files."
GROUP limes_files
DEPENDS lfilesystem)
cpack_add_component_group (limes_files DISPLAY_NAME "Limes filesystem"
DESCRIPTION "Limes filesystem library" PARENT_GROUP limes)
if (LFILE_TESTS)
enable_testing ()
add_subdirectory (tests)
include (CTest)
endif ()
if (LFILE_DOCS)
add_subdirectory (docs)
endif ()
if (lfilesystem_IS_TOP_LEVEL)
include (CPack)
endif ()