ENH: Modernize CMake packaging to match vtkAddon (supersedes #27)#28
Open
RafaelPalomar wants to merge 2 commits into
Open
ENH: Modernize CMake packaging to match vtkAddon (supersedes #27)#28RafaelPalomar wants to merge 2 commits into
RafaelPalomar wants to merge 2 commits into
Conversation
- Removed old configuration and use CMake files in favor of`qRestAPIConfig.cmake.in` - Enable install configuration through implementation of qRestAPIInstallConfig.cmake.in - Enabled installation of development files.
…tall) Export an imported qRestAPI target for both build and install trees via install(EXPORT), and generate the install-tree package config with configure_package_config_file() so the install is relocatable (no absolute CMAKE_INSTALL_PREFIX baked in). Declare include directories as PUBLIC usage requirements with BUILD_INTERFACE/INSTALL_INTERFACE and link Qt with explicit PUBLIC visibility. Legacy path variables (qRestAPI_INCLUDE_DIRS, qRestAPI_LIBRARY_DIRS, qRestAPI_LIBRARIES) are kept for backward compatibility. Config templates remain at the project root, matching the vtkAddon convention.
RafaelPalomar
marked this pull request as ready for review
July 14, 2026 08:00
|
Thanks a lot for this, looks promising
Sounds good. Could apply a similar Readme update PR on Slicer/vtkAddon#70 so that it's documented there too, for consistency? |
lassoan
approved these changes
Jul 15, 2026
lassoan
left a comment
Member
There was a problem hiding this comment.
Thank you, this looks good to me.
Would it be possible to add an option for ${PROJECT_NAME}_INSTALL_NO_DEVELOPMENT?
- It is the standard way of telling that it is a public configuration variable.
- It would allow setting a default value, so we could avoid the awkward double-negative: instead of
qRestAPI_INSTALL_NO_DEVELOPMENT=OFFwe could simply haveqRestAPI_INSTALL_DEVELOPMENT=ON. - Its documentation would show up both in the CMakeLists.txt file and in the CMake GUI (you would not need to go anywhere else for documentation and the risk of documentation and implementation getting out of sync would be lower).
Consistency is useful, so we could fix this negative naming and lack of option defintion in vtkAddon, before it spreads to too many places.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This supersedes #27 and builds on it: it keeps that PR's install/config rework and brings qRestAPI's CMake packaging in line with vtkAddon, the reference project for Slicer-family libraries. The goal is a library that installs cleanly and can be consumed standalone (e.g. building Slicer with
SUPERBUILD=OFF, or via distro/homebrew packaging).What changes
qRestAPItarget for both the build tree and the install tree throughinstall(EXPORT). Downstream projects link the target and inherit include directories transitively, soUseqRestAPI.cmake/qRestAPI_USE_FILEare no longer needed and are removed.configure_package_config_file(), making installed trees relocatable (no absoluteCMAKE_INSTALL_PREFIXis baked in).PUBLICusage requirements (BUILD_INTERFACE/INSTALL_INTERFACE) and link Qt with explicit visibility.qRestAPI_INCLUDE_DIRS,qRestAPI_LIBRARY_DIRSandqRestAPI_LIBRARIESvariables for backward compatibility.Consumers that relied on
qRestAPI_USE_FILEmust drop it and link theqRestAPItarget instead (a matching one-line change is needed in Slicer'sBase/QTCore).Location of the config templates
The predecessor PR was discussed at the Slicer developer weekly meeting on 2026-07-07, where @lassoan suggested moving the CMake config files under a
CMake/directory rather than leaving them at the project root.This PR keeps the
*Config.cmake.intemplates at the root. The rationale is consistency with vtkAddon, where the root holds the public package-config templates whileCMake/is reserved for build-helper modules (macros, wrap scripts). The placement is functionally neutral — the template path is given explicitly toconfigure_file()and is not affected byCMAKE_MODULE_PATH— so matching the reference project is the deciding factor. Happy to move them underCMake/if the preference stands.qRestAPI_INSTALL_NO_DEVELOPMENTkept as a plain variable@ferdymercury suggested (in #27) promoting this to a cache option. This PR keeps it as an
if(NOT DEFINED ...)default, primarily for consistency with vtkAddon and other Slicer-family libraries, which use the same pattern for their install-layout variables. The functional difference is small; the main trade-off of not using a cache option is reduced discoverability incmake-gui, which is addressed by documenting these variables in the README. This is a convention call rather than a technical constraint — happy to discuss a change on this with the devs.This PR was prepared with the help of Claude Code (Opus 4.8).