Skip to content
Merged
Show file tree
Hide file tree
Changes from 107 commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
dec0712
Make ystdlib a cmake library
PacificViking May 26, 2025
4aa941c
add missing ystdlib-config.cmake.in file
PacificViking May 26, 2025
662e768
add coderabbit suggestions
PacificViking May 26, 2025
93c4d50
Modify according to coderabbit suggestion
PacificViking May 27, 2025
0a88c49
add changes according to coderabbit suggestions
PacificViking May 28, 2025
e4dc708
fix gersemi linting errors for cmakelists
PacificViking May 29, 2025
a3bc9d5
this cmake.in file is preprocessed and should not be linted
PacificViking May 30, 2025
601c462
fix coderabbit suggestion
PacificViking Jun 5, 2025
2e54cdb
public target_compile_features
PacificViking Jun 5, 2025
f5e2b4b
Merge remote-tracking branch 'upstream/main' into dev
PacificViking Jun 6, 2025
89f53c1
cleanup unnecessary dependencies, merge new yscope-dev-utils
PacificViking Jun 6, 2025
1d313c3
use correct yscope-dev-utils version
PacificViking Jun 6, 2025
2f9f30b
Merge branch 'backup-main'
PacificViking Jun 6, 2025
a63a4f2
fix version ordering error
PacificViking Jun 6, 2025
847162f
add example, require boost
PacificViking Jun 6, 2025
5e55b58
rename project name and relevant variables to ystdlib (from YSTDLIB_CPP)
PacificViking Jun 6, 2025
77fc7ea
not working: splitting libraries
PacificViking Jun 6, 2025
521c1f9
working examples without filesets but with separate library targets
PacificViking Jun 6, 2025
1c44077
Merge branch 'dev'
PacificViking Jun 6, 2025
c8a3c93
modify according to coderabbit suggestions
PacificViking Jun 6, 2025
ef48733
fix examples/cmakelists according to coderabbit
PacificViking Jun 6, 2025
f62ee82
use filesets
PacificViking Jun 8, 2025
7a625e7
bump examples cmake version according to coderabbit
PacificViking Jun 9, 2025
277dc1d
remove examples
PacificViking Jun 9, 2025
f25859e
remove YSTDLIB_CPP_* to ystdlib_* change
PacificViking Jun 9, 2025
e94d6ae
update readme for new usage and dependencies
PacificViking Jun 9, 2025
36ab649
Revert "remove YSTDLIB_CPP_* to ystdlib_* change"
PacificViking Jun 9, 2025
cafa9be
increase consistency in naming everything ystdlib (rather than
PacificViking Jun 9, 2025
134b1e0
remove unneeded cxx direction
PacificViking Jun 9, 2025
487844d
further removal of unneeded cxx
PacificViking Jun 9, 2025
96b2811
Apply suggestions from code review
PacificViking Jun 10, 2025
07df644
further changes according to review
PacificViking Jun 10, 2025
9a7400c
fix cmake linting errors
PacificViking Jun 10, 2025
caff1ae
update readme according to coderabbit suggestions
PacificViking Jun 10, 2025
630d389
Refactor taskfiles and add build, install, and example tasks for all …
davidlion Jun 10, 2025
6c55590
Fix rabbit review.
davidlion Jun 10, 2025
7f2745f
Remove unnecessary config PATH_VARS and move ystdlib_INSTALL_CONFIG_D…
davidlion Jun 11, 2025
93b4a70
Fix boost version with components, update settings file path to default.
davidlion Jun 11, 2025
3ab6484
Update testbin path to new version.
davidlion Jun 11, 2025
f449cce
Resolve rabbit nits.
davidlion Jun 11, 2025
b1243ed
Drop deps utils hack for boost that doesn't work. Update manually for…
davidlion Jun 11, 2025
d14bfdb
Rabbit nit.
davidlion Jun 11, 2025
aea57aa
Try to make boost dependency more robust.
davidlion Jun 11, 2025
729db5c
add examples
PacificViking Jun 11, 2025
43ee6cc
add other targets for examples and a README
PacificViking Jun 11, 2025
c4e67c4
Bump dev-utils; fix lint tasks.
davidlion Jun 11, 2025
cd7b3aa
Fix gersemirc path.
davidlion Jun 11, 2025
2dbca54
Update examples.
davidlion Jun 11, 2025
22a27c8
Refactor cmake install. Add missing boost arg define.
davidlion Jun 11, 2025
56470ad
Refactor taskfiles.
davidlion Jun 11, 2025
8183762
Add examples to gh workflow.
davidlion Jun 11, 2025
1e5b9bc
Add readme pass.
davidlion Jun 11, 2025
e9cbd7c
Add missing test: prefix to gh workflow.
davidlion Jun 11, 2025
596beb5
Add uv to workflow and readme.
davidlion Jun 11, 2025
28916c0
Fix typo in examples cmake.
davidlion Jun 11, 2025
a9f7054
Refactor validate tasks.
davidlion Jun 11, 2025
b329870
Refactor linking-tests.cpp.
davidlion Jun 11, 2025
7c62982
Update and refactor taskfiles.
davidlion Jun 11, 2025
1633044
Fix linking-tests.cpp.
davidlion Jun 11, 2025
ed60a76
Temporary change of dev-utils for CI testing.
davidlion Jun 11, 2025
d351128
Change interface inheritance to pulbic.
davidlion Jun 11, 2025
ebb9984
Disable release unit tests in workflow.
davidlion Jun 11, 2025
95cb0a0
Fix examles task in gh workflow.
davidlion Jun 11, 2025
5b944b0
Fix copy-paste error messages in examples.
davidlion Jun 11, 2025
962c1e0
allow separate target installations through components (relies on
PacificViking Jun 11, 2025
7198859
Merge branch 'install_separate'
PacificViking Jun 11, 2025
edecfb2
Fix readme link for github syntax.
davidlion Jun 11, 2025
30ba595
install task tweak.
davidlion Jun 11, 2025
0395b33
Revert all taskfile related changes for a new PR.
davidlion Jun 11, 2025
bb56c10
Readme pass.
davidlion Jun 11, 2025
346dcfe
Apply suggestions from code review
davidlion Jun 11, 2025
5a404d5
Example readme tweak.
davidlion Jun 11, 2025
2de6525
Obey gersemi.
davidlion Jun 11, 2025
f02a658
Tweak examples/README.md.
davidlion Jun 12, 2025
1637b6e
Update examples/README.md
davidlion Jun 12, 2025
0688e49
Tweak examples/README.md.
davidlion Jun 12, 2025
0e0651e
Fix dumb mistake.
davidlion Jun 12, 2025
7133493
Large switch env variable to handle library installation selection.
davidlion Jun 14, 2025
1e7cd87
Revert require_argument_values to fix logic mistake; Address rabbit n…
davidlion Jun 15, 2025
24ea39a
Address rabbit comments; Improve style consistency.
davidlion Jun 15, 2025
64f3929
Fix readme install prefix.
davidlion Jun 15, 2025
7687b09
Apply suggestions from code review.
davidlion Jun 16, 2025
2066564
Address review comments.
davidlion Jun 16, 2025
7d89e7e
Refactor repeated string to variable.
davidlion Jun 16, 2025
8453a16
Gersemi
davidlion Jun 16, 2025
dbd5f01
Tweak cmake logic with rabbit's help.
davidlion Jun 16, 2025
e72fb28
Remove unused COMPONENT keyword from install EXPORTS.
davidlion Jun 22, 2025
5e83d4e
Tweak COMPONENTS comment.
davidlion Jun 22, 2025
913bdc1
Drop guard comment.
davidlion Jun 22, 2025
6bf405e
Defer find_package COMPONENTS support in config file for a later PR.
davidlion Jun 22, 2025
bda1ea0
Apply suggestions from code review
davidlion Jun 23, 2025
cfee30e
Merge commit 'refs/pull/65/head' of https://github.com/y-scope/ystdli…
davidlion Jun 23, 2025
6cd8c8b
Apply suggestions from code review
davidlion Jun 23, 2025
a9a73e0
Apply suggestions from code review
davidlion Jun 23, 2025
461fa47
Remove new test taskfile that was accidentally left in.
davidlion Jun 23, 2025
fc773c1
Merge commit 'refs/pull/65/head' of https://github.com/y-scope/ystdli…
davidlion Jun 23, 2025
9a4099c
Address review comments.
davidlion Jun 23, 2025
1a0c6df
Address review comments.
davidlion Jun 23, 2025
ae147cd
Apply suggestions from code review
davidlion Jun 23, 2025
b75247d
Move files to cmake/ystdlib.
davidlion Jun 23, 2025
2af9ed7
Refactor variables and naming.
davidlion Jun 23, 2025
4d81820
Good rabbit.
davidlion Jun 24, 2025
7b32ab0
Dedup variable.
davidlion Jun 24, 2025
550d683
Set new boost policy.
davidlion Jun 24, 2025
a6d8f2b
Simplify cmake include guards.
davidlion Jun 24, 2025
f544f70
Formatting.
davidlion Jun 24, 2025
db7d25a
Remove dead code.
davidlion Jun 24, 2025
f13a591
Update CMakeLists.txt
davidlion Jun 25, 2025
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
2 changes: 1 addition & 1 deletion .gersemirc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/BlankSpruce/gersemi/master/gersemi/configuration.schema.json

definitions:
- "CMake/ystdlib-cpp-helpers.cmake"
- "cmake/ystdlib-helpers.cmake"
- "build/deps/Catch2/Catch2-src/extras/Catch.cmake"
line_length: 100
list_expansion: "favour-expansion"
162 changes: 0 additions & 162 deletions CMake/ystdlib-cpp-helpers.cmake

This file was deleted.

91 changes: 61 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,73 +1,76 @@
cmake_minimum_required(VERSION 3.22.1)
cmake_minimum_required(VERSION 3.23)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")
include(ystdlib-cpp-helpers)
project(ystdlib VERSION "0.1.0" LANGUAGES CXX)

project(YSTDLIB_CPP LANGUAGES CXX)

set(YSTDLIB_CPP_VERSION "0.0.1" CACHE STRING "Project version.")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
include(ystdlib-helpers)

option(BUILD_SHARED_LIBS "Build using shared libraries." OFF)
option(YSTDLIB_CPP_BUILD_TESTING "Build the testing tree for ystdlib-cpp." ON)
option(ystdlib_BUILD_TESTING "Build the testing tree for ystdlib." ON)

# Require compiler versions that support the C++20 features necessary for compiling ystdlib-cpp
# Require compiler versions that support the C++20 features necessary for compiling ystdlib
if("AppleClang" STREQUAL "${CMAKE_CXX_COMPILER_ID}")
set(YSTDLIB_CPP_CMAKE_CXX_COMPILER_MIN_VERSION "16")
set(ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION "16")
elseif("Clang" STREQUAL "${CMAKE_CXX_COMPILER_ID}")
set(YSTDLIB_CPP_CMAKE_CXX_COMPILER_MIN_VERSION "16")
set(ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION "16")
elseif("GNU" STREQUAL "${CMAKE_CXX_COMPILER_ID}")
set(YSTDLIB_CPP_CMAKE_CXX_COMPILER_MIN_VERSION "11")
set(ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION "11")
else()
message(
FATAL_ERROR
"Unsupported compiler: ${CMAKE_CXX_COMPILER_ID}. Please use AppleClang, Clang, or GNU."
)
endif()
if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "${YSTDLIB_CPP_CMAKE_CXX_COMPILER_MIN_VERSION}")
if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "${ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION}")
message(
FATAL_ERROR
"${CMAKE_CXX_COMPILER_ID} version ${CMAKE_CXX_COMPILER_VERSION} is too low. Must be at \
least ${YSTDLIB_CPP_CMAKE_CXX_COMPILER_MIN_VERSION}."
least ${ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION}."
)
endif()

# Enable exporting compile commands
set(CMAKE_EXPORT_COMPILE_COMMANDS
ON
CACHE BOOL
"Enable/Disable output of compile commands during generation."
FORCE
)

if(YSTDLIB_CPP_IS_TOP_LEVEL)
set(ystdlib_LIBRARIES
"containers"
"error_handling"
"io_interface"
"wrapped_facade_headers"
CACHE STRING
"Semicolon-separated list of libraries to be built."
)

message(STATUS "Building the following libraries:")
foreach(LIB IN LISTS ystdlib_LIBRARIES)
message(STATUS " - ${LIB}")
endforeach()

if(ystdlib_IS_TOP_LEVEL)
# Include dependency settings if the project isn't being included as a subproject.
# NOTE: We mark the file optional because if the user happens to have the dependencies
# installed, this file is not necessary.
include("build/deps/cmake-settings/settings.cmake" OPTIONAL)
include("build/deps/cmake-settings/all.cmake" OPTIONAL)

# If previously undefined, `BUILD_TESTING` will be set to ON.
include(CTest)
endif()

if(BUILD_TESTING AND YSTDLIB_CPP_BUILD_TESTING)
set(YSTDLIB_CPP_ENABLE_TESTS ON)
if(BUILD_TESTING AND ystdlib_BUILD_TESTING)
set(ystdlib_ENABLE_TESTS ON)
endif()

find_package(Boost REQUIRED)
if(Boost_FOUND)
message(STATUS "Found Boost ${Boost_VERSION}.")
endif()

if(YSTDLIB_CPP_ENABLE_TESTS)
if(ystdlib_ENABLE_TESTS)
find_package(Catch2 3.8.0 REQUIRED)
if(Catch2_FOUND)
message(STATUS "Found Catch2 ${Catch2_VERSION}.")
else()
message(FATAL_ERROR "Could not find libraries for Catch2.")
endif()
message(STATUS "Found Catch2 ${Catch2_VERSION}.")
include(Catch)
Comment on lines +65 to 72
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Guard use of BUILD_TESTING when the project is a sub-directory

BUILD_TESTING is only defined after a call to include(CTest).
If this project is embedded via add_subdirectory and ystdlib_IS_TOP_LEVEL is false, include(CTest) is never executed, making BUILD_TESTING unknown here and triggering a CMake error on some policies.

Add a default:

if(NOT DEFINED BUILD_TESTING)
    set(BUILD_TESTING OFF)
endif()

before the if(BUILD_TESTING AND ystdlib_BUILD_TESTING) check.
This keeps the logic safe in all embedding scenarios.

🤖 Prompt for AI Agents
In CMakeLists.txt around lines 65 to 72, the variable BUILD_TESTING may be
undefined if the project is included as a subdirectory without calling
include(CTest), causing CMake errors. To fix this, add a check before the
existing if statement to set BUILD_TESTING to OFF if it is not defined. This
ensures the subsequent conditional logic using BUILD_TESTING is safe in all
embedding scenarios.


# Set up the unified unit test target
set(UNIFIED_UNIT_TEST_TARGET "unit-test-all")
add_executable(${UNIFIED_UNIT_TEST_TARGET})
target_link_libraries(${UNIFIED_UNIT_TEST_TARGET} PRIVATE Catch2::Catch2WithMain)
Expand All @@ -82,4 +85,32 @@ if(YSTDLIB_CPP_ENABLE_TESTS)
catch_discover_tests(${UNIFIED_UNIT_TEST_TARGET} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/testbin)
endif()

# We require all libraries use the same minimum version of dependencies to avoid issues.
set(BOOST_MIN_VERSION "1.81.0")

set(CONFIG_PATH_SUFFIX "cmake/ystdlib")
set(CONFIG_LIBS_PATH_SUFFIX "${CONFIG_PATH_SUFFIX}/libs")

# Used by libraries and must come before add_subdirectory.
set(CONFIG_LIBS_DEST_DIR "${CMAKE_INSTALL_LIBDIR}/${CONFIG_LIBS_PATH_SUFFIX}")
set(CONFIG_LIBS_INPUT_DIR "${PROJECT_SOURCE_DIR}/${CONFIG_LIBS_PATH_SUFFIX}")

add_subdirectory(src/ystdlib)

set(CONFIG_FILE_PREFIX "ystdlib-config")
set(CONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/${CONFIG_PATH_SUFFIX})
set(CONFIG_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_FILE_PREFIX}.cmake")
set(CONFIG_VERSION_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_FILE_PREFIX}-version.cmake")

configure_package_config_file(
"${CMAKE_CURRENT_LIST_DIR}/${CONFIG_PATH_SUFFIX}/${CONFIG_FILE_PREFIX}.cmake.in"
"${CONFIG_OUTPUT_PATH}"
INSTALL_DESTINATION "${CONFIG_INSTALL_DIR}"
)
write_basic_package_version_file("${CONFIG_VERSION_OUTPUT_PATH}" COMPATIBILITY SameMajorVersion)
install(
FILES
"${CONFIG_OUTPUT_PATH}"
"${CONFIG_VERSION_OUTPUT_PATH}"
DESTINATION "${CONFIG_INSTALL_DIR}"
)
Loading