11cmake_minimum_required (VERSION 3.22.1)
22
3+ set (ystdlib_VERSION "0.0.1" CACHE STRING "Project version." )
4+
5+ project (ystdlib VERSION "${ystdlib_VERSION} " LANGUAGES CXX)
6+
37list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR} /CMake" )
48include (ystdlib-cpp-helpers)
59include (CMakePackageConfigHelpers)
610include (GNUInstallDirs)
711
8- set (YSTDLIB_CPP_VERSION "0.0.1" CACHE STRING "Project version." )
9-
10- project (YSTDLIB_CPP VERSION "${YSTDLIB_CPP_VERSION} " LANGUAGES CXX)
11-
1212option (BUILD_SHARED_LIBS "Build using shared libraries." OFF )
13- option (YSTDLIB_CPP_BUILD_TESTING "Build the testing tree for ystdlib-cpp." ON )
13+ option (ystdlib_BUILD_TESTING "Build the testing tree for ystdlib-cpp." ON )
1414
1515# Require compiler versions that support the C++20 features necessary for compiling ystdlib-cpp
1616if ("AppleClang" STREQUAL "${CMAKE_CXX_COMPILER_ID} " )
17- set (YSTDLIB_CPP_CMAKE_CXX_COMPILER_MIN_VERSION "16" )
17+ set (ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION "16" )
1818elseif ("Clang" STREQUAL "${CMAKE_CXX_COMPILER_ID} " )
19- set (YSTDLIB_CPP_CMAKE_CXX_COMPILER_MIN_VERSION "16" )
19+ set (ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION "16" )
2020elseif ("GNU" STREQUAL "${CMAKE_CXX_COMPILER_ID} " )
21- set (YSTDLIB_CPP_CMAKE_CXX_COMPILER_MIN_VERSION "11" )
21+ set (ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION "11" )
2222else ()
2323 message (
2424 FATAL_ERROR
2525 "Unsupported compiler: ${CMAKE_CXX_COMPILER_ID} . Please use AppleClang, Clang, or GNU."
2626 )
2727endif ()
28- if ("${CMAKE_CXX_COMPILER_VERSION} " VERSION_LESS "${YSTDLIB_CPP_CMAKE_CXX_COMPILER_MIN_VERSION } " )
28+ if ("${CMAKE_CXX_COMPILER_VERSION} " VERSION_LESS "${ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION } " )
2929 message (
3030 FATAL_ERROR
3131 "${CMAKE_CXX_COMPILER_ID} version ${CMAKE_CXX_COMPILER_VERSION} is too low. Must be at \
32- least ${YSTDLIB_CPP_CMAKE_CXX_COMPILER_MIN_VERSION } ."
32+ least ${ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION } ."
3333 )
3434endif ()
3535
@@ -41,7 +41,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS
4141 FORCE
4242)
4343
44- if (YSTDLIB_CPP_IS_TOP_LEVEL )
44+ if (ystdlib_IS_TOP_LEVEL )
4545 # Include dependency settings if the project isn't being included as a subproject.
4646 # NOTE: We mark the file optional because if the user happens to have the dependencies
4747 # installed, this file is not necessary.
@@ -51,16 +51,16 @@ if(YSTDLIB_CPP_IS_TOP_LEVEL)
5151 include (CTest)
5252endif ()
5353
54- if (BUILD_TESTING AND YSTDLIB_CPP_BUILD_TESTING )
55- set (YSTDLIB_CPP_ENABLE_TESTS ON )
54+ if (BUILD_TESTING AND ystdlib_BUILD_TESTING )
55+ set (ystdlib_ENABLE_TESTS ON )
5656endif ()
5757
5858find_package (Boost REQUIRED)
5959if (Boost_FOUND)
6060 message (STATUS "Found Boost ${Boost_VERSION} ." )
6161endif ()
6262
63- if (YSTDLIB_CPP_ENABLE_TESTS )
63+ if (ystdlib_ENABLE_TESTS )
6464 find_package (Catch2 3.8.0 REQUIRED)
6565 if (Catch2_FOUND)
6666 message (STATUS "Found Catch2 ${Catch2_VERSION} ." )
@@ -84,60 +84,31 @@ if(YSTDLIB_CPP_ENABLE_TESTS)
8484 catch_discover_tests(${UNIFIED_UNIT_TEST_TARGET} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} /testbin)
8585endif ()
8686
87- set (YSTDLIB_INSTALL_CONFIG_DIR ${CMAKE_INSTALL_LIBDIR} /cmake/ystdlib)
88- set (YSTDLIB_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR} )
87+ set (ystdlib_INSTALL_CONFIG_DIR ${CMAKE_INSTALL_LIBDIR} /cmake/ystdlib)
88+ set (ystdlib_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR} )
8989
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)
90+ add_subdirectory (src/ystdlib)
11091
111- set_target_properties (
112- ystdlib
113- PROPERTIES
114- LINKER_LANGUAGE
115- CXX
92+ install (TARGETS
93+ containers
94+ error_handling
95+ io_interface
96+ wrapped_facade_headers
97+ EXPORT ystdlib-targets
98+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
99+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
100+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
101+ FILE_SET HEADERS
116102)
117103
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- )
104+ install (EXPORT ystdlib-targets NAMESPACE ystdlib:: DESTINATION ${ystdlib_INSTALL_CONFIG_DIR} )
134105
135106configure_package_config_file(
136107 ${CMAKE_CURRENT_LIST_DIR} /CMake/ystdlib-config.cmake.in
137108 ${CMAKE_CURRENT_BINARY_DIR} /ystdlib-config.cmake
138- INSTALL_DESTINATION ${YSTDLIB_INSTALL_CONFIG_DIR }
109+ INSTALL_DESTINATION ${ystdlib_INSTALL_CONFIG_DIR }
139110 PATH_VARS
140- YSTDLIB_INSTALL_INCLUDE_DIR
111+ ystdlib_INSTALL_INCLUDE_DIR
141112)
142113
143114write_basic_package_version_file(
@@ -149,7 +120,6 @@ install(
149120 FILES
150121 ${CMAKE_CURRENT_BINARY_DIR} /ystdlib-config.cmake
151122 ${CMAKE_CURRENT_BINARY_DIR} /ystdlib-config-version .cmake
152- DESTINATION ${YSTDLIB_INSTALL_CONFIG_DIR }
123+ DESTINATION ${ystdlib_INSTALL_CONFIG_DIR }
153124)
154125
155- add_subdirectory (src/ystdlib)
0 commit comments