1
+ include (GNUInstallDirs )
1
2
2
3
# Automatically fetch Unicode database if not present.
3
4
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR} /ucd.cpp ) # if c++ files not auto-generated
@@ -35,8 +36,8 @@ add_library(unicode_ucd STATIC
35
36
ucd_ostream.h
36
37
)
37
38
add_library (unicode::ucd ALIAS unicode_ucd )
38
- target_include_directories (unicode_ucd PUBLIC ${PROJECT_SOURCE_DIR} /src ${CMAKE_SOURCE_DIR} /src )
39
- target_link_libraries ( unicode_ucd PUBLIC fmt::fmt-header-only )
39
+ target_include_directories (unicode_ucd PUBLIC $< BUILD_INTERFACE: ${CMAKE_CURRENT_SOURCE_DIR} /.. >
40
+ $< INSTALL_INTERFACE:include > )
40
41
41
42
# =========================================================================================================
42
43
@@ -59,8 +60,9 @@ add_custom_command(
59
60
60
61
add_library (unicode_loader STATIC codepoint_properties_loader.h codepoint_properties_loader.cpp )
61
62
add_library (unicode::loader ALIAS unicode_loader )
62
- target_include_directories (unicode_loader PUBLIC ${PROJECT_SOURCE_DIR} /src ${CMAKE_SOURCE_DIR} /src )
63
- target_link_libraries (unicode_loader PUBLIC fmt::fmt-header-only unicode::ucd )
63
+ target_include_directories (unicode_loader PUBLIC $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /..>
64
+ $< INSTALL_INTERFACE:include> )
65
+ target_link_libraries (unicode_loader PUBLIC unicode::ucd )
64
66
65
67
# =========================================================================================================
66
68
@@ -97,19 +99,58 @@ set(public_headers
97
99
set_target_properties (unicode PROPERTIES PUBLIC_HEADER "${public_headers} " )
98
100
99
101
add_library (unicode::core ALIAS unicode )
100
- target_include_directories (unicode PUBLIC ${PROJECT_SOURCE_DIR} /src ${CMAKE_SOURCE_DIR} /src )
101
- target_link_libraries (unicode PUBLIC unicode::ucd fmt::fmt-header-only )
102
-
103
- install (TARGETS unicode
104
- LIBRARY DESTINATION lib
105
- PUBLIC_HEADER DESTINATION include /unicode )
102
+ target_include_directories (unicode PUBLIC $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /..>
103
+ $< INSTALL_INTERFACE:include> )
104
+ target_link_libraries (unicode PUBLIC unicode::ucd )
106
105
107
106
add_executable (unicode_tablegen tablegen.cpp )
108
- target_include_directories (unicode_tablegen PRIVATE ${PROJECT_SOURCE_DIR} /src ${CMAKE_SOURCE_DIR} /src )
109
- target_link_libraries (unicode_tablegen PRIVATE unicode::loader fmt::fmt-header-only )
107
+ target_link_libraries (unicode_tablegen PRIVATE unicode::loader )
108
+
109
+ # {{{ installation
110
+ set (LIBUNICODE_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR} /cmake/libunicode" CACHE PATH "Installation directory for cmake files, a relative path that will be joined with ${CMAKE_INSTALL_PREFIX} or an absolute path." )
111
+ set (LIBUNICODE_INSTALL_CMAKE_FILES ${MASTER_PROJECT} CACHE BOOL "Decides whether or not to install CMake config and -version files." )
112
+ message (NOTICE "HELLO HERE: ${LIBUNICODE_CMAKE_DIR} " )
113
+
114
+ set (INSTALL_TARGETS unicode_ucd unicode_loader unicode )
115
+ set (TARGETS_EXPORT_NAME unicode-targets )
116
+
117
+ # Create and install package configuration and version files.
118
+ # Install library and headers.
119
+ install (TARGETS ${INSTALL_TARGETS}
120
+ EXPORT ${TARGETS_EXPORT_NAME}
121
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
122
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
123
+ PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_PREFIX} /include/unicode"
124
+ FRAMEWORK DESTINATION "."
125
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
126
+
127
+ install (
128
+ FILES
129
+ ucd.h
130
+ ucd_enums.h
131
+ ucd_fmt.h
132
+ ucd_ostream.h
133
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR} /unicode"
134
+ )
135
+
136
+ if (LIBUNICODE_INSTALL_CMAKE_FILES )
137
+ set (version "${CMAKE_PROJECT_VERSION} " )
138
+ configure_file (${CMAKE_CURRENT_SOURCE_DIR} /libunicode-config.cmake.in
139
+ ${CMAKE_CURRENT_BINARY_DIR} /libunicode-config.cmake @ONLY )
140
+
141
+ configure_file (${CMAKE_CURRENT_SOURCE_DIR} /libunicode-config-version.cmake.in
142
+ ${CMAKE_CURRENT_BINARY_DIR} /libunicode-config-version.cmake @ONLY )
143
+
144
+ install (FILES ${CMAKE_CURRENT_BINARY_DIR} /libunicode-config.cmake
145
+ ${CMAKE_CURRENT_BINARY_DIR} /libunicode-config-version.cmake
146
+ DESTINATION ${LIBUNICODE_CMAKE_DIR} )
147
+
148
+ # Install version, config and target files.
149
+ install (EXPORT ${TARGETS_EXPORT_NAME} DESTINATION ${LIBUNICODE_CMAKE_DIR} NAMESPACE unicode:: )
150
+ endif ()
151
+ # }}}
110
152
111
- # --------------------------------------------------------------------------------------------------------
112
- # unicode_test
153
+ # {{{ unicode_test
113
154
if (LIBUNICODE_TESTING )
114
155
enable_testing ()
115
156
add_executable (unicode_test
@@ -127,6 +168,7 @@ if(LIBUNICODE_TESTING)
127
168
width_test.cpp
128
169
word_segmenter_test.cpp
129
170
)
130
- target_link_libraries (unicode_test unicode Catch2::Catch2 )
171
+ target_link_libraries (unicode_test unicode Catch2::Catch2 fmt::fmt-header-only )
131
172
add_test (unicode_test unicode_test )
132
173
endif ()
174
+ # }}}
0 commit comments