Skip to content

Commit

Permalink
Merge pull request #13 from dokempf/modernize-cmake
Browse files Browse the repository at this point in the history
Modernize CMake build system
  • Loading branch information
dokempf authored Oct 15, 2021
2 parents 54ef66b + ed1e6e2 commit 408e830
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 13 deletions.
48 changes: 43 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ cmake_minimum_required(VERSION 3.11)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_subdirectory(ext/Catch2)
include(CTest)

# When building documentation from readthedocs.io, we need to
# run CMake, but we do not need to build C++ code, so we should
# skip any required dependencies.
Expand All @@ -18,9 +15,50 @@ endif()

find_package(yaml-cpp 0.6 ${REQUIRED_STRING})

add_subdirectory(cerberus-cpp)
# Add library target that can be linked against
add_library(cerberus-cpp INTERFACE)
target_include_directories(
cerberus-cpp
INTERFACE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_link_libraries(cerberus-cpp INTERFACE yaml-cpp)

# Add an alias target for use if this project is included as a subproject in another project
add_library(cerberus-cpp::cerberus-cpp ALIAS cerberus-cpp)

# Add documentation building
add_subdirectory(doc)
add_subdirectory(test)

# Add the testing subdirectories
if(EXISTS ${CMAKE_SOURCE_DIR}/ext/Catch2/CMakeLists.txt)
include(CTest)
add_subdirectory(ext/Catch2)
add_subdirectory(test)
endif()

# Installation rules
include(GNUInstallDirs)

install(
TARGETS cerberus-cpp
EXPORT cerberus-cpp-config
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

install(
EXPORT cerberus-cpp-config
NAMESPACE cerberus-cpp::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cerberus-cpp
)

install(
DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

include(FeatureSummary)
feature_summary(WHAT ALL)
6 changes: 0 additions & 6 deletions cerberus-cpp/CMakeLists.txt

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
if(BUILD_TESTING)
add_executable(testcerberus testcerberus.cc)
target_link_libraries(testcerberus yaml-cpp Catch2::Catch2)
target_include_directories(testcerberus PUBLIC ${CMAKE_SOURCE_DIR})
target_link_libraries(testcerberus PUBLIC cerberus-cpp Catch2::Catch2)
include(../ext/Catch2/contrib/Catch.cmake)
catch_discover_tests(testcerberus)
endif()
Expand Down

0 comments on commit 408e830

Please sign in to comment.