File tree Expand file tree Collapse file tree 5 files changed +54
-8
lines changed Expand file tree Collapse file tree 5 files changed +54
-8
lines changed Original file line number Diff line number Diff line change 11cmake_minimum_required (VERSION 3.21)
2- project (libut LANGUAGES CXX)
2+ project (
3+ libut
4+ VERSION 0.1.0
5+ DESCRIPTION "Various useful bits of C++"
6+ HOMEPAGE_URL "https://github.com/dk949/libut"
7+ LANGUAGES CXX
8+ )
9+ include (cmake/install .cmake)
310include (cmake/targets.cmake)
411
512file (GLOB includes "${CMAKE_CURRENT_SOURCE_DIR} /include/*" )
613
7- add_library (all INTERFACE )
14+ add_library (ut INTERFACE )
815foreach (include ${includes} )
916 add_subdirectory ("${include} " )
1017 cmake_path(GET include FILENAME module_name)
11- target_link_libraries (all INTERFACE "${module_name} " )
18+ target_link_libraries (ut INTERFACE "${module_name} " )
1219 list (APPEND LIBUT_TARGET_LIST "${module_name} " )
1320endforeach ()
14- list (APPEND LIBUT_TARGET_LIST all )
21+ list (APPEND LIBUT_TARGET_LIST ut )
1522set (LIBUT_TARGET_LIST
1623 "${LIBUT_TARGET_LIST} "
1724 CACHE INTERNAL "" FORCE
1825)
19- message (STATUS "libut: adding UT::all" )
26+ message (STATUS "libut: adding UT::ut" )
27+ libut_install()
2028
2129if (PROJECT_IS_TOP_LEVEL)
2230 option (ENABLE_TESTING "Should tests be enabled?" ON )
Original file line number Diff line number Diff line change 22
33[ ![ CMake build and test] ( https://github.com/dk949/libut/actions/workflows/cmake-multi-platform.yml/badge.svg )] ( https://github.com/dk949/libut/actions/workflows/cmake-multi-platform.yml )
44
5- Various useful bits of c ++
5+ Various useful bits of C ++
66
77This is header only C++ library for doing useful things. Such as printing human
88readable type names, converting ` string_view ` s to numbers. See the [ Currently
@@ -67,7 +67,7 @@ target_link_libraries(MY_TARGET UT::target_name)
6767
6868<!-- AUTOGEN_END -->
6969
70- A special target ` UT::all ` is also available, combining all of the above.
70+ A special target ` UT::ut ` is also available, combining all of the above.
7171
7272## Testing
7373
Original file line number Diff line number Diff line change 1+ @PACKAGE_INIT@
2+
3+ # Let the config file find the targets file installed by install(EXPORT)
4+ include ("${CMAKE_CURRENT_LIST_DIR} /UTTargets.cmake" )
Original file line number Diff line number Diff line change 1+ include (GNUInstallDirs)
2+ include (CMakePackageConfigHelpers)
3+
4+ function (libut_install)
5+ install (
6+ TARGETS ${LIBUT_TARGET_LIST}
7+ EXPORT UTTargets
8+ FILE_SET HEADERS
9+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
10+ )
11+
12+ install (
13+ EXPORT UTTargets
14+ NAMESPACE UT::
15+ DESTINATION ${CMAKE_INSTALL_LIBDIR} /cmake/ut
16+ )
17+
18+ configure_package_config_file(
19+ "${CMAKE_CURRENT_LIST_DIR} /cmake/UTConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR} /UTConfig.cmake"
20+ INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR} /cmake/ut"
21+ NO_CHECK_REQUIRED_COMPONENTS_MACRO
22+ )
23+
24+ write_basic_package_version_file(
25+ "${CMAKE_CURRENT_BINARY_DIR} /UTConfigVersion.cmake"
26+ VERSION ${PROJECT_VERSION}
27+ COMPATIBILITY AnyNewerVersion
28+ )
29+
30+ install (FILES "${CMAKE_CURRENT_BINARY_DIR} /UTConfig.cmake"
31+ "${CMAKE_CURRENT_BINARY_DIR} /UTConfigVersion.cmake"
32+ DESTINATION ${CMAKE_INSTALL_LIBDIR} /cmake/ut
33+ )
34+ endfunction ()
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ check_source_compiles(
5454endblock()
5555
5656function (setup_target target )
57- target_link_libraries (${target} PRIVATE UT:: all )
57+ target_link_libraries (${target} PRIVATE ut )
5858 set_target_warnings(${target} )
5959 target_link_libraries (${target} PRIVATE Catch2::Catch2WithMain)
6060 target_precompile_headers(${target} PRIVATE <catch.hpp>)
You can’t perform that action at this time.
0 commit comments