-
Notifications
You must be signed in to change notification settings - Fork 18
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
More tweaks after standard updates #31
base: main
Are you sure you want to change the base?
Changes from all commits
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 | ||||
---|---|---|---|---|---|---|
|
@@ -4,18 +4,22 @@ | |||||
cmake_minimum_required(VERSION 3.23) | ||||||
|
||||||
project( | ||||||
beman.exemplar # CMake Project Name, which is also the name of the top-level | ||||||
# targets (e.g., library, executable, etc.). | ||||||
beman.exemplar | ||||||
DESCRIPTION "A Beman library exemplar" | ||||||
VERSION 0.0.0 | ||||||
LANGUAGES CXX) | ||||||
|
||||||
include(CMakePackageConfigHelpers) | ||||||
include(CTest) | ||||||
include(FetchContent) | ||||||
include(GNUInstallDirs) | ||||||
|
||||||
set(TARGETS_EXPORT_NAME ${CMAKE_PROJECT_NAME}Targets) | ||||||
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake) | ||||||
|
||||||
if(BUILD_TESTING) | ||||||
enable_testing() | ||||||
|
||||||
# Fetch GoogleTest | ||||||
FetchContent_Declare( | ||||||
googletest | ||||||
GIT_REPOSITORY https://github.com/google/googletest.git | ||||||
|
@@ -25,5 +29,19 @@ if(BUILD_TESTING) | |||||
endif() | ||||||
|
||||||
add_subdirectory(src/beman/exemplar) | ||||||
|
||||||
add_subdirectory(examples) | ||||||
|
||||||
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. Shouldn't all the library metadata (i.e., |
||||||
write_basic_package_version_file( | ||||||
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. Inspect current behavior from https://github.com/beman-project/execution26/blob/main/CMakeLists.txt and https://github.com/beman-project/optional26/blob/main/CMakeLists.txt. I tried to extract only the minimum required code to do the install. Expected tree: $ cmake --install build --prefix /opt/beman.exemplar
-- Install configuration: ""
-- Installing: /opt/beman.exemplar/lib/libbeman.exemplar.a
-- Installing: /opt/beman.exemplar/include
-- Installing: /opt/beman.exemplar/include/beman
-- Installing: /opt/beman.exemplar/include/beman/exemplar
-- Installing: /opt/beman.exemplar/include/beman/exemplar/identity.hpp
-- Installing: /opt/beman.exemplar/lib/cmake/beman.exemplarConfig.cmake
-- Installing: /opt/beman.exemplar/lib/cmake/beman.exemplarConfigVersion.cmake
$ tree /opt/beman.exemplar
/opt/beman.exemplar
├── include
│ └── beman
│ └── exemplar
│ └── identity.hpp
└── lib
├── cmake
│ ├── beman.exemplarConfig.cmake
│ └── beman.exemplarConfigVersion.cmake
└── libbeman.exemplar.a
6 directories, 4 files I would like your feedback and decide a standard pattern, which will be applied initially to beman.examplar, and eventually mirror it into other 2 repos. Open questions:
Waiting for your input here. If any decision will be made here, we can put it into Beman standard. 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.
I'm okay with this for now. Eventually, we should export docs at installation time to the
Yes, this is the convention for the ArchLinux distribution and probably others as well. See openjpeg2's contents for an example. Config Mode's Search Procedure includes a table indicating how *Config.cmake files are found. 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. Eventually we should just have a function like |
||||||
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake | ||||||
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.
Suggested change
Just because |
||||||
VERSION ${PROJECT_VERSION} | ||||||
COMPATIBILITY AnyNewerVersion) | ||||||
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.
Suggested change
Unless we're doing something specific to guarantee some ABI compatibility across versions of a Beman project, we should be conservative about version matching. On the contrary, I fully expect API and ABI breaks across releases of Beman projects since they're by definition experimental and prone to design changes. We could maybe revisit this choice on a case-by-case basis for projects that a "stable" status. But unless they're spelling their implementations with ABI tags and such, I wouldn't advise people bother. |
||||||
|
||||||
configure_package_config_file( | ||||||
"cmake/Config.cmake.in" | ||||||
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake | ||||||
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.
Suggested change
See the comment about |
||||||
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}) | ||||||
|
||||||
install( | ||||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake | ||||||
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.
Suggested change
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake | ||||||
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.
Suggested change
|
||||||
DESTINATION ${INSTALL_CONFIGDIR}) |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -17,7 +17,7 @@ Implements: `std::identity` proposed in [Standard Library Concepts (P0898R3)](ht | |||||||||
|
||||||||||
### Usage: default projection in constrained algorithms | ||||||||||
|
||||||||||
The following code snippet illustrates how we can achieve a default projection using `beman::exemplar::identity`: | ||||||||||
The following code snippet illustrates how we can achieve a default projection using `beman::exemplar::identity`: | ||||||||||
|
||||||||||
|
||||||||||
```cpp | ||||||||||
|
@@ -73,7 +73,7 @@ int main() | |||||||||
|
||||||||||
``` | ||||||||||
|
||||||||||
Full runable examples can be found in `examples/` (e.g., [./examples/identity_as_default_projection.cpp.cpp](./examples/identity_as_default_projection.cpp.cpp)). | ||||||||||
Full runable examples can be found in `examples/` (e.g., [./examples/identity_as_default_projection.cpp](./examples/identity_as_default_projection.cpp)). | ||||||||||
|
||||||||||
## Building beman.exemplar | ||||||||||
|
||||||||||
|
@@ -152,7 +152,8 @@ $ cmake -B build -S . -DCMAKE_CXX_STANDARD=20 | |||||||||
-- Check for working CXX compiler: /usr/bin/c++ - skipped | ||||||||||
-- Detecting CXX compile features | ||||||||||
-- Detecting CXX compile features - done | ||||||||||
-- Configuring done (0.1s) | ||||||||||
... | ||||||||||
-- Configuring done (2.9s) | ||||||||||
-- Generating done (0.0s) | ||||||||||
-- Build files have been written to: /path/to/repo/build | ||||||||||
|
||||||||||
|
@@ -167,17 +168,17 @@ $ cmake --build build | |||||||||
[ 50%] Building CXX object _deps/googletest-build/googletest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.o | ||||||||||
[ 60%] Linking CXX static library ../../../lib/libgtest_main.a | ||||||||||
[ 60%] Built target gtest_main | ||||||||||
[ 70%] Building CXX object src/beman/exemplar/tests/CMakeFiles/beman.exemplar.Test.dir/identity.t.cpp.o | ||||||||||
[ 80%] Linking CXX executable beman.exemplar.Test | ||||||||||
[ 80%] Built target beman.exemplar.Test | ||||||||||
[ 90%] Building CXX object examples/CMakeFiles/identity_usage.dir/identity_usage.cpp.o | ||||||||||
[100%] Linking CXX executable identity_usage | ||||||||||
[100%] Built target identity_usage | ||||||||||
[ 70%] Building CXX object src/beman/exemplar/CMakeFiles/beman.exemplar.tests.dir/identity.t.cpp.o | ||||||||||
[ 80%] Linking CXX executable beman.exemplar.tests | ||||||||||
[ 80%] Built target beman.exemplar.tests | ||||||||||
[ 90%] Building CXX object examples/CMakeFiles/beman.exemplar.examples.identity_direct_usage.dir/identity_direct_usage.cpp.o | ||||||||||
[100%] Linking CXX executable beman.exemplar.examples.identity_direct_usage | ||||||||||
[100%] Built target beman.exemplar.examples.identity_direct_usage | ||||||||||
|
||||||||||
# Run beman.exemplar tests. | ||||||||||
$ ctest --test-dir build | ||||||||||
Internal ctest changing into directory: /path/to/your/repo/build | ||||||||||
Test project /path/to/your/repo/build | ||||||||||
Internal ctest changing into directory: /path/to/repo/build | ||||||||||
Test project /path/to/repo/build | ||||||||||
Start 1: IdentityTest.call_identity_with_int | ||||||||||
1/4 Test #1: IdentityTest.call_identity_with_int ........... Passed 0.00 sec | ||||||||||
Start 2: IdentityTest.call_identity_with_custom_type | ||||||||||
|
@@ -193,7 +194,7 @@ Total Test time (real) = 0.01 sec | |||||||||
|
||||||||||
|
||||||||||
# Run examples. | ||||||||||
$ build/exemplar/beman.exemplar.examples.identity_direct_usage | ||||||||||
$ build/examples/beman.exemplar.examples.identity_direct_usage | ||||||||||
2024 | ||||||||||
|
||||||||||
``` | ||||||||||
|
@@ -207,11 +208,13 @@ $ build/exemplar/beman.exemplar.examples.identity_direct_usage | |||||||||
# Install build artifacts from `build` directory into `opt/beman.exemplar` path. | ||||||||||
$ cmake --install build --prefix /opt/beman.exemplar | ||||||||||
-- Install configuration: "" | ||||||||||
-- Up-to-date: /opt/beman.exemplar/lib/libbeman.exemplar.a | ||||||||||
-- Up-to-date: /opt/beman.exemplar/include | ||||||||||
-- Up-to-date: /opt/beman.exemplar/include/beman | ||||||||||
-- Up-to-date: /opt/beman.exemplar/include/beman/exemplar | ||||||||||
-- Up-to-date: /opt/beman.exemplar/include/beman/exemplar/identity.hpp | ||||||||||
-- Installing: /opt/beman.exemplar/lib/libbeman.exemplar.a | ||||||||||
-- Installing: /opt/beman.exemplar/include | ||||||||||
-- Installing: /opt/beman.exemplar/include/beman | ||||||||||
-- Installing: /opt/beman.exemplar/include/beman/exemplar | ||||||||||
-- Installing: /opt/beman.exemplar/include/beman/exemplar/identity.hpp | ||||||||||
-- Installing: /opt/beman.exemplar/lib/cmake/beman.exemplarConfig.cmake | ||||||||||
-- Installing: /opt/beman.exemplar/lib/cmake/beman.exemplarConfigVersion.cmake | ||||||||||
|
||||||||||
# Check tree. | ||||||||||
$ tree /opt/beman.exemplar | ||||||||||
|
@@ -221,9 +224,12 @@ $ tree /opt/beman.exemplar | |||||||||
│ └── exemplar | ||||||||||
│ └── identity.hpp | ||||||||||
└── lib | ||||||||||
├── cmake | ||||||||||
│ ├── beman.exemplarConfig.cmake | ||||||||||
│ └── beman.exemplarConfigVersion.cmake | ||||||||||
Comment on lines
+228
to
+229
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.
Suggested change
Also, what happened to the file referenced by this bit in the config file? |
||||||||||
└── libbeman.exemplar.a | ||||||||||
|
||||||||||
5 directories, 2 files | ||||||||||
6 directories, 4 files | ||||||||||
``` | ||||||||||
|
||||||||||
</details> | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
@PACKAGE_INIT@ | ||
|
||
include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake") | ||
check_required_components("@PROJECT_NAME@") |
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.
I'd rather just inline this below instead of making a variable that's used only once.