@@ -2,11 +2,13 @@ cmake_minimum_required(VERSION 3.22.1)
22
33list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR} /CMake" )
44include (ystdlib-cpp-helpers)
5-
6- project (YSTDLIB_CPP LANGUAGES CXX )
5+ include (CMakePackageConfigHelpers)
6+ include (GNUInstallDirs )
77
88set (YSTDLIB_CPP_VERSION "0.0.1" CACHE STRING "Project version." )
99
10+ project (YSTDLIB_CPP VERSION "${YSTDLIB_CPP_VERSION} " LANGUAGES CXX)
11+
1012option (BUILD_SHARED_LIBS "Build using shared libraries." OFF )
1113option (YSTDLIB_CPP_BUILD_TESTING "Build the testing tree for ystdlib-cpp." ON )
1214
@@ -82,4 +84,72 @@ if(YSTDLIB_CPP_ENABLE_TESTS)
8284 catch_discover_tests(${UNIFIED_UNIT_TEST_TARGET} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} /testbin)
8385endif ()
8486
87+ set (YSTDLIB_INSTALL_CONFIG_DIR ${CMAKE_INSTALL_LIBDIR} /cmake/ystdlib)
88+ set (YSTDLIB_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR} )
89+
90+ file (
91+ GLOB_RECURSE SOURCE_FILES
92+ CONFIGURE_DEPENDS
93+ "${PROJECT_SOURCE_DIR} /src/*.cpp"
94+ "${PROJECT_SOURCE_DIR} /src/*.hpp"
95+ "${PROJECT_SOURCE_DIR} /src/*.h"
96+ )
97+ list (FILTER SOURCE_FILES EXCLUDE REGEX ".*test_*\. .*" )
98+
99+ add_library (ystdlib ${SOURCE_FILES} )
100+ add_library (ystdlib::ystdlib ALIAS ystdlib)
101+
102+ target_include_directories (
103+ ystdlib
104+ PUBLIC
105+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /src>
106+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR} >
107+ )
108+
109+ target_compile_features (ystdlib PUBLIC cxx_std_20)
110+
111+ set_target_properties (
112+ ystdlib
113+ PROPERTIES
114+ LINKER_LANGUAGE
115+ CXX
116+ )
117+
118+ install (TARGETS ystdlib EXPORT ystdlib-targets)
119+
120+ install (EXPORT ystdlib-targets NAMESPACE ystdlib:: DESTINATION ${YSTDLIB_INSTALL_CONFIG_DIR} )
121+
122+ install (
123+ DIRECTORY
124+ "${PROJECT_SOURCE_DIR} /src/ystdlib"
125+ DESTINATION "${YSTDLIB_INSTALL_INCLUDE_DIR} "
126+ FILES_MATCHING
127+ PATTERN
128+ "*.h"
129+ PATTERN
130+ "*.hpp"
131+ PATTERN
132+ "*.tpp"
133+ )
134+
135+ configure_package_config_file(
136+ ${CMAKE_CURRENT_LIST_DIR} /CMake/ystdlib-config.cmake.in
137+ ${CMAKE_CURRENT_BINARY_DIR} /ystdlib-config.cmake
138+ INSTALL_DESTINATION ${YSTDLIB_INSTALL_CONFIG_DIR}
139+ PATH_VARS
140+ YSTDLIB_INSTALL_INCLUDE_DIR
141+ )
142+
143+ write_basic_package_version_file(
144+ ${CMAKE_CURRENT_BINARY_DIR} /ystdlib-config-version .cmake
145+ COMPATIBILITY SameMajorVersion
146+ )
147+
148+ install (
149+ FILES
150+ ${CMAKE_CURRENT_BINARY_DIR} /ystdlib-config.cmake
151+ ${CMAKE_CURRENT_BINARY_DIR} /ystdlib-config-version .cmake
152+ DESTINATION ${YSTDLIB_INSTALL_CONFIG_DIR}
153+ )
154+
85155add_subdirectory (src/ystdlib)
0 commit comments