-
Notifications
You must be signed in to change notification settings - Fork 7
build(cmake)!: Add support for installation and usage as a library in other CMake projects; Add example project to test this use case. #65
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
108 commits
Select commit
Hold shift + click to select a range
dec0712
Make ystdlib a cmake library
PacificViking 4aa941c
add missing ystdlib-config.cmake.in file
PacificViking 662e768
add coderabbit suggestions
PacificViking 93c4d50
Modify according to coderabbit suggestion
PacificViking 0a88c49
add changes according to coderabbit suggestions
PacificViking e4dc708
fix gersemi linting errors for cmakelists
PacificViking a3bc9d5
this cmake.in file is preprocessed and should not be linted
PacificViking 601c462
fix coderabbit suggestion
PacificViking 2e54cdb
public target_compile_features
PacificViking f5e2b4b
Merge remote-tracking branch 'upstream/main' into dev
PacificViking 89f53c1
cleanup unnecessary dependencies, merge new yscope-dev-utils
PacificViking 1d313c3
use correct yscope-dev-utils version
PacificViking 2f9f30b
Merge branch 'backup-main'
PacificViking a63a4f2
fix version ordering error
PacificViking 847162f
add example, require boost
PacificViking 5e55b58
rename project name and relevant variables to ystdlib (from YSTDLIB_CPP)
PacificViking 77fc7ea
not working: splitting libraries
PacificViking 521c1f9
working examples without filesets but with separate library targets
PacificViking 1c44077
Merge branch 'dev'
PacificViking c8a3c93
modify according to coderabbit suggestions
PacificViking ef48733
fix examples/cmakelists according to coderabbit
PacificViking f62ee82
use filesets
PacificViking 7a625e7
bump examples cmake version according to coderabbit
PacificViking 277dc1d
remove examples
PacificViking f25859e
remove YSTDLIB_CPP_* to ystdlib_* change
PacificViking e94d6ae
update readme for new usage and dependencies
PacificViking 36ab649
Revert "remove YSTDLIB_CPP_* to ystdlib_* change"
PacificViking cafa9be
increase consistency in naming everything ystdlib (rather than
PacificViking 134b1e0
remove unneeded cxx direction
PacificViking 487844d
further removal of unneeded cxx
PacificViking 96b2811
Apply suggestions from code review
PacificViking 07df644
further changes according to review
PacificViking 9a7400c
fix cmake linting errors
PacificViking caff1ae
update readme according to coderabbit suggestions
PacificViking 630d389
Refactor taskfiles and add build, install, and example tasks for all …
davidlion 6c55590
Fix rabbit review.
davidlion 7f2745f
Remove unnecessary config PATH_VARS and move ystdlib_INSTALL_CONFIG_D…
davidlion 93b4a70
Fix boost version with components, update settings file path to default.
davidlion 3ab6484
Update testbin path to new version.
davidlion f449cce
Resolve rabbit nits.
davidlion b1243ed
Drop deps utils hack for boost that doesn't work. Update manually for…
davidlion d14bfdb
Rabbit nit.
davidlion aea57aa
Try to make boost dependency more robust.
davidlion 729db5c
add examples
PacificViking 43ee6cc
add other targets for examples and a README
PacificViking c4e67c4
Bump dev-utils; fix lint tasks.
davidlion cd7b3aa
Fix gersemirc path.
davidlion 2dbca54
Update examples.
davidlion 22a27c8
Refactor cmake install. Add missing boost arg define.
davidlion 56470ad
Refactor taskfiles.
davidlion 8183762
Add examples to gh workflow.
davidlion 1e5b9bc
Add readme pass.
davidlion e9cbd7c
Add missing test: prefix to gh workflow.
davidlion 596beb5
Add uv to workflow and readme.
davidlion 28916c0
Fix typo in examples cmake.
davidlion a9f7054
Refactor validate tasks.
davidlion b329870
Refactor linking-tests.cpp.
davidlion 7c62982
Update and refactor taskfiles.
davidlion 1633044
Fix linking-tests.cpp.
davidlion ed60a76
Temporary change of dev-utils for CI testing.
davidlion d351128
Change interface inheritance to pulbic.
davidlion ebb9984
Disable release unit tests in workflow.
davidlion 95cb0a0
Fix examles task in gh workflow.
davidlion 5b944b0
Fix copy-paste error messages in examples.
davidlion 962c1e0
allow separate target installations through components (relies on
PacificViking 7198859
Merge branch 'install_separate'
PacificViking edecfb2
Fix readme link for github syntax.
davidlion 30ba595
install task tweak.
davidlion 0395b33
Revert all taskfile related changes for a new PR.
davidlion bb56c10
Readme pass.
davidlion 346dcfe
Apply suggestions from code review
davidlion 5a404d5
Example readme tweak.
davidlion 2de6525
Obey gersemi.
davidlion f02a658
Tweak examples/README.md.
davidlion 1637b6e
Update examples/README.md
davidlion 0688e49
Tweak examples/README.md.
davidlion 0e0651e
Fix dumb mistake.
davidlion 7133493
Large switch env variable to handle library installation selection.
davidlion 1e7cd87
Revert require_argument_values to fix logic mistake; Address rabbit n…
davidlion 24ea39a
Address rabbit comments; Improve style consistency.
davidlion 64f3929
Fix readme install prefix.
davidlion 7687b09
Apply suggestions from code review.
davidlion 2066564
Address review comments.
davidlion 7d89e7e
Refactor repeated string to variable.
davidlion 8453a16
Gersemi
davidlion dbd5f01
Tweak cmake logic with rabbit's help.
davidlion e72fb28
Remove unused COMPONENT keyword from install EXPORTS.
davidlion 5e83d4e
Tweak COMPONENTS comment.
davidlion 913bdc1
Drop guard comment.
davidlion 6bf405e
Defer find_package COMPONENTS support in config file for a later PR.
davidlion bda1ea0
Apply suggestions from code review
davidlion cfee30e
Merge commit 'refs/pull/65/head' of https://github.com/y-scope/ystdli…
davidlion 6cd8c8b
Apply suggestions from code review
davidlion a9a73e0
Apply suggestions from code review
davidlion 461fa47
Remove new test taskfile that was accidentally left in.
davidlion fc773c1
Merge commit 'refs/pull/65/head' of https://github.com/y-scope/ystdli…
davidlion 9a4099c
Address review comments.
davidlion 1a0c6df
Address review comments.
davidlion ae147cd
Apply suggestions from code review
davidlion b75247d
Move files to cmake/ystdlib.
davidlion 2af9ed7
Refactor variables and naming.
davidlion 4d81820
Good rabbit.
davidlion 7b32ab0
Dedup variable.
davidlion 550d683
Set new boost policy.
davidlion a6d8f2b
Simplify cmake include guards.
davidlion f544f70
Formatting.
davidlion db7d25a
Remove dead code.
davidlion f13a591
Update CMakeLists.txt
davidlion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,21 @@ | ||
| include(CMakeFindDependencyMacro) | ||
|
|
||
| @PACKAGE_INIT@ | ||
|
|
||
| if(@Catch2_FOUND@) | ||
| find_dependency(Catch2) | ||
| endif() | ||
davidlion marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| if(@outcome_FOUND@) | ||
| find_dependency(outcome) | ||
| endif() | ||
davidlion marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
davidlion marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| set_and_check(ystdlib_INCLUDE_DIR "@PACKAGE_YSTDLIB_INSTALL_INCLUDE_DIR@") | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| check_required_components(ystdlib) | ||
|
|
||
| # Avoid repeatedly including the targets | ||
| if(NOT TARGET ystdlib::ystdlib) | ||
| include(${CMAKE_CURRENT_LIST_DIR}/ystdlib-targets.cmake) | ||
| endif() | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
This file contains hidden or 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,18 @@ | ||
| cmake_minimum_required(VERSION 3.22.1) | ||
|
|
||
|
|
||
| list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake") | ||
| include(ystdlib-cpp-helpers) | ||
|
|
||
| project(YSTDLIB_CPP LANGUAGES CXX) | ||
| include(CMakePackageConfigHelpers) | ||
| include(GNUInstallDirs) | ||
|
|
||
| set(YSTDLIB_CPP_VERSION "0.0.1" CACHE STRING "Project version.") | ||
|
|
||
| project(YSTDLIB_CPP | ||
| VERSION "${YSTDLIB_CPP_VERSION}" | ||
| LANGUAGES CXX | ||
| ) | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| option(BUILD_SHARED_LIBS "Build using shared libraries." OFF) | ||
| option(YSTDLIB_CPP_BUILD_TESTING "Build the testing tree for ystdlib-cpp." ON) | ||
|
|
||
|
|
@@ -84,4 +90,79 @@ if(YSTDLIB_CPP_ENABLE_TESTS) | |
| catch_discover_tests(${UNIFIED_UNIT_TEST_TARGET} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/testbin) | ||
| endif() | ||
|
|
||
| set(YSTDLIB_INSTALL_CONFIG_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/ystdlib) | ||
| set(YSTDLIB_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}) | ||
|
|
||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| file(GLOB_RECURSE SOURCE_FILES | ||
| "${PROJECT_SOURCE_DIR}/src/*.cpp" | ||
| "${PROJECT_SOURCE_DIR}/src/*.hpp" | ||
| "${PROJECT_SOURCE_DIR}/src/*.h" | ||
| ) | ||
| list(FILTER SOURCE_FILES EXCLUDE REGEX ".*test_*\..*") | ||
|
|
||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| add_library(ystdlib ${SOURCE_FILES}) | ||
| add_library(ystdlib::ystdlib ALIAS ystdlib) | ||
|
|
||
| target_include_directories(ystdlib | ||
| PUBLIC | ||
| $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src> | ||
| $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> | ||
| ) | ||
|
|
||
| target_compile_features(ystdlib | ||
| PRIVATE cxx_std_20 | ||
| ) | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| set_target_properties(ystdlib PROPERTIES LINKER_LANGUAGE CXX) | ||
|
|
||
| install( | ||
| TARGETS | ||
| ystdlib | ||
| EXPORT | ||
| ystdlib-targets | ||
| ) | ||
davidlion marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| install( | ||
| EXPORT | ||
| ystdlib-targets | ||
| NAMESPACE | ||
| ystdlib:: | ||
| DESTINATION | ||
| ${YSTDLIB_INSTALL_CONFIG_DIR} | ||
| ) | ||
|
|
||
| install( | ||
| DIRECTORY | ||
| "${PROJECT_SOURCE_DIR}/src/ystdlib" | ||
| DESTINATION | ||
| "${YSTDLIB_INSTALL_INCLUDE_DIR}" | ||
| FILES_MATCHING | ||
| PATTERN "*.h" | ||
| PATTERN "*.hpp" | ||
| PATTERN "*.tpp" | ||
| ) | ||
|
|
||
| configure_package_config_file( | ||
| ${CMAKE_CURRENT_LIST_DIR}/CMake/ystdlib-config.cmake.in | ||
| ${CMAKE_CURRENT_BINARY_DIR}/ystdlib-config.cmake | ||
|
||
| INSTALL_DESTINATION | ||
| ${YSTDLIB_INSTALL_CONFIG_DIR} | ||
| PATH_VARS | ||
| YSTDLIB_INSTALL_INCLUDE_DIR | ||
| ) | ||
|
|
||
| write_basic_package_version_file( | ||
| ${CMAKE_CURRENT_BINARY_DIR}/ystdlib-config-version.cmake | ||
|
||
| COMPATIBILITY | ||
| SameMajorVersion | ||
| ) | ||
|
|
||
| install( | ||
| FILES | ||
| ${CMAKE_CURRENT_BINARY_DIR}/ystdlib-config.cmake | ||
| ${CMAKE_CURRENT_BINARY_DIR}/ystdlib-config-version.cmake | ||
| DESTINATION | ||
| ${YSTDLIB_INSTALL_CONFIG_DIR} | ||
| ) | ||
|
|
||
| add_subdirectory(src/ystdlib) | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.