-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
948dc2d
commit ec4adea
Showing
2 changed files
with
53 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,47 @@ | ||
cmake_minimum_required(VERSION 3.12) | ||
cmake_minimum_required(VERSION 3.14) | ||
|
||
project(muc) | ||
project(muc VERSION 0.0.1 LANGUAGES CXX) | ||
|
||
add_library(muc INTERFACE) | ||
add_library(muc::muc ALIAS muc) | ||
|
||
include(CMakeDependentOption) | ||
|
||
cmake_dependent_option(MUC_ENABLE_UBSAN_IN_DEBUG_BUILD "Enable UndefinedBehaviorSanitizer in debug build" ON BUILD_TESTING OFF) | ||
# https://cmake.org/cmake/help/latest/variable/PROJECT_IS_TOP_LEVEL.html | ||
string(COMPARE EQUAL ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} PROJECT_IS_TOP_LEVEL) | ||
|
||
option(MUC_INSTALL "Generate and install muc target" ${PROJECT_IS_TOP_LEVEL}) | ||
option(MUC_TEST "Build and perform muc tests" ${PROJECT_IS_TOP_LEVEL}) | ||
cmake_dependent_option(MUC_ENABLE_UBSAN_IN_DEBUG_BUILD "Enable UndefinedBehaviorSanitizer in debug build" ON MUC_TEST OFF) | ||
|
||
# The implementation generally assumes a platform that implements at least C++17 support | ||
target_compile_features(muc INTERFACE "cxx_std_17") | ||
|
||
include(CTest) | ||
if(BUILD_TESTING) | ||
# Setup include directory | ||
add_subdirectory(include) | ||
|
||
if (MUC_TEST) | ||
enable_testing() | ||
add_subdirectory(test) | ||
endif() | ||
|
||
if (MUC_INSTALL) | ||
include(GNUInstallDirs) | ||
include(CMakePackageConfigHelpers) | ||
|
||
install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/muc" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
|
||
set(export_name "mucConfig") | ||
set(namespace "muc::") | ||
set(cmake_files_install_dir ${CMAKE_INSTALL_DATADIR}/cmake/muc) | ||
|
||
install(TARGETS muc EXPORT ${export_name} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
install(EXPORT ${export_name} NAMESPACE ${namespace} DESTINATION ${cmake_files_install_dir}) | ||
export(TARGETS muc NAMESPACE ${namespace} FILE ${export_name}.cmake) | ||
|
||
set(muc_config_version "${CMAKE_CURRENT_BINARY_DIR}/mucConfigVersion.cmake") | ||
|
||
write_basic_package_version_file(${muc_config_version} COMPATIBILITY SameMajorVersion ARCH_INDEPENDENT) | ||
|
||
install(FILES ${muc_config_version} DESTINATION ${cmake_files_install_dir}) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Add include folders to the library and targets that consume it | ||
# the SYSTEM keyword suppresses warnings for users of the library | ||
# | ||
# By adding this directory as an include directory the user gets a | ||
# namespace effect. | ||
# | ||
# IE: | ||
# #include "muc/type_traits" | ||
if(PROJECT_IS_TOP_LEVEL) | ||
target_include_directories(muc INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>) | ||
else() | ||
target_include_directories(muc SYSTEM INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>) | ||
endif() |