-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/install cmake config package #32
Changes from all commits
39d540b
d744137
d462d55
dd79c46
9f39d9a
9a7fd7f
bc1b468
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
/build | ||
/out | ||
CMakeUserPresets.json | ||
CMakeCache.txt | ||
CMakeFiles/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,9 @@ | |
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
# cmake-format: on | ||
|
||
cmake_minimum_required(VERSION 3.23) | ||
set(CMAKE_SKIP_TEST_ALL_DEPENDENCY FALSE) | ||
|
||
cmake_minimum_required(VERSION 3.25...3.31) | ||
|
||
project( | ||
beman.inplace_vector | ||
|
@@ -13,6 +15,10 @@ project( | |
LANGUAGES CXX | ||
) | ||
|
||
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) | ||
message(FATAL_ERROR "In-source builds are not allowed!") | ||
endif() | ||
|
||
# [CMAKE.SKIP_EXAMPLES] | ||
option( | ||
BEMAN_EXEMPLAR_BUILD_EXAMPLES | ||
|
@@ -27,41 +33,90 @@ option( | |
${PROJECT_IS_TOP_LEVEL} | ||
) | ||
|
||
set(CPACK_GENERATOR TGZ) | ||
|
||
include(GNUInstallDirs) | ||
include(CMakePackageConfigHelpers) | ||
include(CPack) | ||
|
||
add_library(beman.inplace_vector INTERFACE) | ||
add_library(beman_inplace_vector INTERFACE) | ||
# [CMAKE.LIBRARY_ALIAS] | ||
add_library(beman::inplace_vector ALIAS beman.inplace_vector) | ||
add_library(beman::beman_inplace_vector ALIAS beman_inplace_vector) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is non conforming There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see #32 (comment) Please try yourself to make it work with confirming names!There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wdym try to make it work? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. endless loop: you want some changes; I show you it does not work; |
||
|
||
target_include_directories( | ||
beman.inplace_vector | ||
INTERFACE | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:include> | ||
target_sources( | ||
beman_inplace_vector | ||
PUBLIC | ||
FILE_SET inplace_vector_public_headers | ||
TYPE HEADERS | ||
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include | ||
FILES | ||
"${CMAKE_CURRENT_SOURCE_DIR}/include/beman/inplace_vector/inplace_vector.hpp" | ||
) | ||
set_target_properties( | ||
beman_inplace_vector | ||
PROPERTIES VERIFY_INTERFACE_HEADER_SETS ON | ||
) | ||
target_compile_features(beman_inplace_vector INTERFACE cxx_std_23) | ||
|
||
# export cmake config package | ||
set(TARGET_NAME inplace_vector) | ||
set(TARGET_NAMESPACE beman) | ||
set(TARGET_ALIAS ${TARGET_NAMESPACE}::${TARGET_NAME}) | ||
set(TARGET_PREFIX ${TARGET_NAMESPACE}.${TARGET_NAME}) # -> PROJECT_NAME? | ||
set(TARGET_PACKAGE_NAME ${TARGET_NAME}-config) | ||
set(TARGETS_EXPORT_NAME ${TARGET_NAME}-targets) | ||
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${TARGET_NAME}) | ||
|
||
# Install the InplaceVector library to the appropriate destination | ||
install( | ||
TARGETS beman.inplace_vector | ||
TARGETS beman_inplace_vector | ||
EXPORT ${TARGETS_EXPORT_NAME} | ||
DESTINATION | ||
${CMAKE_INSTALL_LIBDIR} | ||
FILE_SET inplace_vector_public_headers | ||
) | ||
|
||
write_basic_package_version_file( | ||
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PACKAGE_NAME}-version.cmake | ||
VERSION ${PROJECT_VERSION} | ||
COMPATIBILITY AnyNewerVersion | ||
) | ||
|
||
configure_package_config_file( | ||
cmake/config.cmake.in | ||
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PACKAGE_NAME}.cmake | ||
INSTALL_DESTINATION ${INSTALL_CONFIGDIR} | ||
) | ||
|
||
# Install the header files to the appropriate destination | ||
install( | ||
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME} | ||
FILES_MATCHING | ||
PATTERN | ||
"${CMAKE_CURRENT_SOURCE_DIR}/include/beman/inplace_vector/inplace_vector.hpp" | ||
FILES | ||
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PACKAGE_NAME}.cmake | ||
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PACKAGE_NAME}-version.cmake | ||
DESTINATION ${INSTALL_CONFIGDIR} | ||
) | ||
|
||
install( | ||
EXPORT ${TARGETS_EXPORT_NAME} | ||
FILE ${TARGETS_EXPORT_NAME}.cmake | ||
DESTINATION "${INSTALL_CONFIGDIR}" | ||
NAMESPACE ${TARGET_NAMESPACE}:: | ||
) | ||
|
||
if(BEMAN_INPLACE_VECTOR_BUILD_TESTS) | ||
include(CTest) | ||
enable_testing() | ||
add_subdirectory(tests/beman/inplace_vector) | ||
endif() | ||
|
||
if(BEMAN_EXEMPLAR_BUILD_EXAMPLES) | ||
add_subdirectory(examples) | ||
endif() | ||
|
||
# Coverage | ||
configure_file(cmake/gcovr.cfg.in gcovr.cfg @ONLY) | ||
|
||
add_custom_target( | ||
process_coverage | ||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | ||
DEPENDS test | ||
COMMENT "Running gcovr to process coverage results" | ||
COMMAND mkdir -p coverage | ||
COMMAND gcovr --config gcovr.cfg . | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# cmake/Config.cmake.in -*-makefile-*- | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
@PACKAGE_INIT@ | ||
|
||
include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake") | ||
check_required_components("@TARGET_NAME@") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception. | ||
|
||
root = @CMAKE_SOURCE_DIR@ | ||
cobertura = @CMAKE_BINARY_DIR@/coverage/cobertura.xml | ||
sonarqube = @CMAKE_BINARY_DIR@/coverage/sonarqube.xml | ||
html-details = @CMAKE_BINARY_DIR@/coverage/coverage.html | ||
# XXX gcov-executable = @GCOV_EXECUTABLE@ | ||
gcov-parallel = yes | ||
html-theme = blue | ||
html-self-contained = yes | ||
print-summary = yes | ||
filter = .*/beman/inplace_vector/.* | ||
exclude = .*\.t\.cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name is non conforming
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see too bemanproject/optional26#82