Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

neatudarius
Copy link
Member

@neatudarius neatudarius commented Sep 25, 2024

Missing changed from #14

Updates:

  • Apply CMAKE.CONFIG

@neatudarius neatudarius force-pushed the more-tweaks-after-standard-updates branch 2 times, most recently from c04aadb to 06ba4e1 Compare September 25, 2024 15:05
add_subdirectory(examples)

write_basic_package_version_file(
Copy link
Member Author

@neatudarius neatudarius Sep 25, 2024

Choose a reason for hiding this comment

The 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:

  1. Are we OK to install only the next artifacts?
  • $export_path/include/beman/$short_name/* (all headers, in this repo - 1 file)
  • $export_path/lib/libbeman.short_name.a (1 file)
  • $export_path/lib/cmake/beman.short_name.Config[Version].cmake (2 files)
    What we should NOT export:
  • example binaries (we do that for optional26 , I'll fix it)
  • test binaries
  • scripts
  • docs
  1. @camio proposed to add a subdirectory for cmake configs - a.k.a. /opt/beman.exemplar/lib/cmake/beman.exemplarConfig.cmake -> /opt/beman.exemplar/lib/cmake/beman.exemplar/beman.exemplarConfig.cmake. Do people agree with that?

  2. @steve-downey , do we need these lines https://github.com/beman-project/optional26/blob/main/CMakeLists.txt#L36-L39?

Waiting for your input here. If any decision will be made here, we can put it into Beman standard.

CC: @camio @steve-downey @dietmarkuehl @bretbrownjr

Copy link
Contributor

Choose a reason for hiding this comment

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

[W]e should NOT export...docs

I'm okay with this for now. Eventually, we should export docs at installation time to the docs/beman.short_name/ directory, but we need to get our docs story figured out first.

@camio proposed to add a subdirectory for cmake configs

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Eventually we should just have a function like install_beman_library that wraps up all of the above. Packaging for Arch, packaging for vcpkg, packaging for Conan, etc., are all different, and it would be a mistake to hardcode logic for each library for each environment. That's an MxN complexity algorithm. We need an abstraction that gives us an M+N task.

@neatudarius neatudarius marked this pull request as ready for review September 25, 2024 15:19
@neatudarius neatudarius force-pushed the more-tweaks-after-standard-updates branch from 06ba4e1 to 9446152 Compare September 25, 2024 15:26
Copy link
Contributor

@bretbrownjr bretbrownjr left a comment

Choose a reason for hiding this comment

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

I have a few suggestions here and there. The most important changes I'd like to request are:

  • I suspect we're missing the Targets.cmake file from the installation logic, given the tree command doesn't note it
  • I suspect we're missing some sort of test to confirm the packaging works. I guess that could be another PR, but it would be nice to at least manually test that installing into a staging dir, manipulating CMAKE_PREFIX_PATH, and then calling find_package(exemplar REQUIRED) in an example works well. For what it's worth, Conan ships with a test that does this.
  • We'll want to do exact version matching or just ignore versions altogether (both work for me). Trying to support semantic versioning for locating a built binary is not a recipe for success. That's only really appropriate for intentionally ABI stable projects like libc++ or various C libraries. Certainly not Beman libraries, which are disclaiming stability, at least until they reach the "stable" status.

Minor general note: At some point in recent refactoring, we also lost the support for install COMPONENTS. We should add that back in, but it can be another PR.

FYI @steve-downey. I'm guessing we aren't using install components in optional26 either.

add_subdirectory(examples)

write_basic_package_version_file(
Copy link
Contributor

Choose a reason for hiding this comment

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

Eventually we should just have a function like install_beman_library that wraps up all of the above. Packaging for Arch, packaging for vcpkg, packaging for Conan, etc., are all different, and it would be a mistake to hardcode logic for each library for each environment. That's an MxN complexity algorithm. We need an abstraction that gives us an M+N task.

include(CTest)
include(FetchContent)
include(GNUInstallDirs)

set(TARGETS_EXPORT_NAME ${CMAKE_PROJECT_NAME}Targets)
Copy link
Contributor

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.

add_subdirectory(examples)

write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config-version.cmake

Just because lower.caseThenCamelCase.cmake is not how anyone would choose to name a file. See upstream docs on support for kebab-case filenames.


configure_package_config_file(
"cmake/Config.cmake.in"
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config.cmake

See the comment about *ConfigVersion.cmake

add_subdirectory(examples)

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't all the library metadata (i.e., exemplar-config.cmake, etc.) go in the src/beman/exemplar subdir?

write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
COMPATIBILITY AnyNewerVersion)
COMPATIBILITY ExactVersion)

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.

INSTALL_DESTINATION ${INSTALL_CONFIGDIR})

install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake
FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config.cmake


install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config-version.cmake

Comment on lines +228 to +229
│   ├── beman.exemplarConfig.cmake
│   └── beman.exemplarConfigVersion.cmake
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
│   ├── beman.exemplarConfig.cmake
│   └── beman.exemplarConfigVersion.cmake
│   ├── beman.exemplar-config.cmake
│   └── beman.exemplar-config-version.cmake

Also, what happened to the file referenced by this bit in the config file?
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")

@wusatosi
Copy link
Member

@neatudarius Mind if I contribute directly to this PR?

@neatudarius
Copy link
Member Author

@neatudarius Mind if I contribute directly to this PR?

Sure, please contribute

@wusatosi
Copy link
Member

wusatosi commented Dec 3, 2024

@neatudarius Mind if I contribute directly to this PR?

Sure, please contribute

I am in my finals week, I no longer have extra capacity to work on this.

@camio
Copy link
Contributor

camio commented Dec 4, 2024

There's was a review of this PR on October 1st, but no updates since. Should we close this PR and re-open it when someone wants to drive it forward?

@neatudarius
Copy link
Member Author

There's was a review of this PR on October 1st, but no updates since. Should we close this PR and re-open it when someone wants to drive it forward?

I will finish it this week. Sorry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants