@@ -5,9 +5,6 @@ cmake_minimum_required(VERSION 3.11)
55set (CMAKE_CXX_STANDARD 14)
66set (CMAKE_CXX_STANDARD_REQUIRED ON )
77
8- add_subdirectory (ext /Catch2)
9- include (CTest)
10-
118# When building documentation from readthedocs.io, we need to
129# run CMake, but we do not need to build C++ code, so we should
1310# skip any required dependencies.
@@ -18,9 +15,50 @@ endif()
1815
1916find_package (yaml-cpp 0.6 ${REQUIRED_STRING} )
2017
21- add_subdirectory (cerberus-cpp)
18+ # Add library target that can be linked against
19+ add_library (cerberus-cpp INTERFACE )
20+ target_include_directories (
21+ cerberus-cpp
22+ INTERFACE
23+ $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR} /include />
24+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR} >
25+ )
26+ target_link_libraries (cerberus-cpp INTERFACE yaml-cpp)
27+
28+ # Add an alias target for use if this project is included as a subproject in another project
29+ add_library (cerberus-cpp::cerberus-cpp ALIAS cerberus-cpp)
30+
31+ # Add documentation building
2232add_subdirectory (doc )
23- add_subdirectory (test )
33+
34+ # Add the testing subdirectories
35+ if (EXISTS ${CMAKE_SOURCE_DIR} /ext /Catch2/CMakeLists.txt)
36+ include (CTest)
37+ add_subdirectory (ext /Catch2)
38+ add_subdirectory (test )
39+ endif ()
40+
41+ # Installation rules
42+ include (GNUInstallDirs)
43+
44+ install (
45+ TARGETS cerberus-cpp
46+ EXPORT cerberus-cpp-config
47+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
48+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
49+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
50+ )
51+
52+ install (
53+ EXPORT cerberus-cpp-config
54+ NAMESPACE cerberus-cpp::
55+ DESTINATION ${CMAKE_INSTALL_LIBDIR} /cmake/cerberus-cpp
56+ )
57+
58+ install (
59+ DIRECTORY ${CMAKE_CURRENT_LIST_DIR} /include /
60+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
61+ )
2462
2563include (FeatureSummary)
2664feature_summary(WHAT ALL )
0 commit comments