Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 47 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
cmake_minimum_required(VERSION 3.8.2)
project(Clara)
project(Clara VERSION 1.1.5)

set(SOURCE_FILES src/main.cpp src/ClaraTests.cpp include/clara.hpp)
include_directories( include third_party )
include(GNUInstallDirs)

add_library(Clara INTERFACE)
add_library(Clara::Clara ALIAS Clara)
target_include_directories(Clara
INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
target_compile_features(Clara
INTERFACE cxx_trailing_return_types)

set(SOURCE_FILES src/main.cpp src/ClaraTests.cpp)
add_executable(ClaraTests ${SOURCE_FILES})
target_include_directories(ClaraTests PRIVATE third_party)
target_link_libraries(ClaraTests PRIVATE Clara::Clara)

if(USE_CPP14)
set_property(TARGET ClaraTests PROPERTY CXX_STANDARD 14)
Expand Down Expand Up @@ -37,3 +49,35 @@ endif()

include(CTest)
add_test(NAME RunTests COMMAND $<TARGET_FILE:ClaraTests>)

set(target_export_name "${PROJECT_NAME}Targets")
set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
set(version_config "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake")

# install headers
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/single_include/"
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

# install project config
install(TARGETS Clara EXPORT ${target_export_name})
install(EXPORT ${target_export_name}
NAMESPACE Clara::
DESTINATION ${config_install_dir}
FILE "${PROJECT_NAME}Config.cmake")

# install version config
include(CMakePackageConfigHelpers)

# CMake automatically adds an architecture compatibility check to make sure
# 32 and 64 bit code is not accidentally mixed. For a header-only library this
# is not required. The check can be disabled by temporarily unsetting
# CMAKE_SIZEOF_VOID_P. In CMake 3.14 and later this can be achieved more cleanly
# with write_basic_package_version_file(ARCH_INDEPENDENT).
# TODO: Use this once a newer CMake can be required.
set(CLARA_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
unset(CMAKE_SIZEOF_VOID_P)
write_basic_package_version_file(${version_config}
COMPATIBILITY SameMajorVersion)
set(CMAKE_SIZEOF_VOID_P ${CLARA_SIZEOF_VOID_P})

install(FILES ${version_config} DESTINATION ${config_install_dir})