Repository navigation
Fix/opentims system install fallback - #9148
Conversation
|
@michalsta The following names might be missing from the
Please consider applying the following patch: --- AUTHORS 2026-04-14 16:32:41.836453712 +0000
+++ AUTHORS.new 2026-04-14 16:32:47.353012441 +0000
@@ -91,6 +91,7 @@
- Ole Schulz-Trieglaff
- Oliver Alka
- Oliver Kohlbacher
+ - openms-jenkins-bot
- Pasquale Domenico Colaianni
- Patricia Scheil
- Peter J. Jones |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a new CMake Find module for Opentims, changes external-lib logic to prefer a system/config package with a FetchContent fallback, updates how sqlite3/zstd are wired depending on discovery mode, and switches project and test linkages to the namespaced target Changes
Sequence Diagram(s)sequenceDiagram
rect rgba(220,230,241,0.5)
participant CMake
participant ConfigPkg as "Config Package\n(opentims)"
participant Finder as "Finder\n(find_path/find_library)"
participant Fetch as "FetchContent\n(opentims repo)"
participant SQLite as "SQLiteCpp/sqlite3"
participant Zstd as "zstd (system/bundled)"
participant Target as "opentims::opentims_cpp"
end
CMake->>ConfigPkg: try find_package(opentims CONFIG QUIET)
alt config package found
ConfigPkg->>CMake: provide imported target
CMake->>Target: validate/import target properties
CMake->>SQLite: inspect INTERFACE_COMPILE_DEFINITIONS -> maybe inject include/link
CMake->>Zstd: prefer system zstd targets if present
else config not found
CMake->>Finder: find_path(opentims++/opentims.h), find_library(opentims_cpp)
Finder-->>CMake: return include/lib paths
CMake->>Target: create IMPORTED STATIC target with properties
CMake->>SQLite: set up sqlite3 linkage if needed
CMake->>Zstd: use bundled zstddeclib.c if no system zstd
end
alt use FetchContent fallback
CMake->>Fetch: clone & configure (OPENTIMS_BUILD_LIB ON, Python OFF, static sqlite)
Fetch->>Target: build opentims_cpp
CMake->>Target: add namespace alias opentims::opentims_cpp
CMake->>SQLite: supply SQLite include/link privately
end
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
cmake/cmake_findExternalLibs.cmake (1)
281-326:⚠️ Potential issue | 🔴 CriticalCritical: Duplicate
WITH_OPENTIMSblock must be removed.This existing block at lines 281-326 was not removed, but a new block with find_package fallback logic was added at lines 408-475. Both blocks are gated by
if (WITH_OPENTIMS)and will execute sequentially, causing:
- The first block fetches and builds opentims via FetchContent
- The second block's
find_package(Opentims QUIET)then runs (but won't help since targets already exist)- Duplicate
FetchContent_Declareforopentims- The
add_library(opentims::opentims_cpp ALIAS opentims_cpp)on line 471 will fail because the target was already createdThe new block at lines 408-475 is the intended replacement that wraps FetchContent with a find_package guard. This original block should be removed entirely.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cmake/cmake_findExternalLibs.cmake` around lines 281 - 326, Remove the original duplicate WITH_OPENTIMS block (the FetchContent_Declare/FetchContent_MakeAvailable sequence that creates opentims and opentims_cpp, including the zstd fallback and target_* calls) so only the newer block with find_package(Opentims QUIET) and the guarded FetchContent remains; ensure you delete the entire first if (WITH_OPENTIMS) ... endif() that references FetchContent_Declare(opentims), target_include_directories(opentims_cpp ...), target_link_libraries(opentims_cpp ...), target_sources(opentims_cpp ...), and the message about Built opentims_cpp so add_library(opentims::opentims_cpp ALIAS opentims_cpp) in the later block will not collide with preexisting targets.
🧹 Nitpick comments (3)
cmake/cmake_findExternalLibs.cmake (1)
414-427: System-installed opentims may lackINTERFACE_COMPILE_DEFINITIONSwhen discovered via manual fallback.When
FindOpentims.cmakeuses the manual search fallback (no CMake config package), the imported target is created withoutINTERFACE_COMPILE_DEFINITIONS. This means_opentims_defswill be empty orNOTFOUND, and theOPENTIMS_LINK_SQLITE_STATICALLYcheck will never match—even if the library was actually built with that option.Consider either:
- Documenting that system installs must provide a CMake config package for full compatibility
- Adding a fallback that assumes
OPENTIMS_LINK_SQLITE_STATICALLYfor manually-discovered libraries (since OpenMS requires sqlite3 linking anyway)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cmake/cmake_findExternalLibs.cmake` around lines 414 - 427, The imported target opentims::opentims_cpp may not expose INTERFACE_COMPILE_DEFINITIONS when discovered via the manual fallback, so the get_target_property(_opentims_defs opentims::opentims_cpp INTERFACE_COMPILE_DEFINITIONS) check can be empty and miss OPENTIMS_LINK_SQLITE_STATICALLY; update the logic after get_target_property to treat an empty/NOTFOUND _opentims_defs as a potential manual-install case and fall back to assuming OPENTIMS_LINK_SQLITE_STATICALLY (or at least perform the same include/link injection) when Opentims_FOUND was set via the manual search path, ensuring target_include_directories and target_link_libraries are applied to opentims::opentims_cpp if the property is missing but the library was discovered manually.cmake/Modules/FindOpentims.cmake (2)
52-61: Manual fallback creates target without compile definitions.When creating the imported target via manual discovery,
INTERFACE_COMPILE_DEFINITIONSis not set. If the discovered library was built withOPENTIMS_LINK_SQLITE_STATICALLY, downstream code incmake_findExternalLibs.cmake(line 422) won't detect this and won't inject the required sqlite3 dependencies.This is a known limitation of manual discovery (you can't introspect how a library was built), but it should be documented or handled with a safe default assumption.
Option: Document limitation in module header
# Hints: # Set Opentims_ROOT_DIR to the root of a custom installation. +# +# Note: When discovered via manual search (no CMake config package), +# compile definitions like OPENTIMS_LINK_SQLITE_STATICALLY cannot be +# introspected. OpenMS will assume static sqlite linking is required.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cmake/Modules/FindOpentims.cmake` around lines 52 - 61, The manual-import branch that creates the imported target (when Opentims_FOUND is true and adding opentims::opentims_cpp via add_library) does not set INTERFACE_COMPILE_DEFINITIONS, so consumers can't detect OPENTIMS_LINK_SQLITE_STATICALLY; update this module to (1) add a clear header comment explaining this limitation and instruct downstream users how to override compile definitions if needed, and (2) when creating the imported target (add_library(opentims::opentims_cpp ...)/set_target_properties), explicitly set INTERFACE_COMPILE_DEFINITIONS (e.g., to an empty list or a documented safe default) so the property exists and downstream code in cmake_findExternalLibs.cmake can behave deterministically; reference Opentims_LIBRARY, Opentims_INCLUDE_DIR, INTERFACE_COMPILE_DEFINITIONS, and OPENTIMS_LINK_SQLITE_STATICALLY in the comment.
25-27:IMPORTED_LOCATIONmay be unset for interface or alias targets.When the config package defines
opentims::opentims_cppas an interface library or alias,get_target_property(... IMPORTED_LOCATION)at line 26 will returnNOTFOUND, leavingOpentims_LIBRARIESempty in the status message. However, sinceOpentims_LIBRARIESis used only for informational output (not actual linking), this is acceptable. The actual linking uses theopentims::opentims_cpptarget directly, which works correctly regardless.For better robustness, consider iterating through configuration-specific properties like
IMPORTED_LOCATION_RELEASEor checking if the target has the property before using it.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cmake/Modules/FindOpentims.cmake` around lines 25 - 27, The get_target_property call for opentims::opentims_cpp uses IMPORTED_LOCATION which may be NOTFOUND for interface/alias targets, causing Opentims_LIBRARIES to be empty; update the logic around the get_target_property for opener target opentims::opentims_cpp so it first checks has_property or falls back to configuration-specific properties (e.g., IMPORTED_LOCATION_RELEASE, IMPORTED_LOCATION_DEBUG) or skips setting Opentims_LIBRARIES when no imported location exists, while keeping Opentims_INCLUDE_DIR from INTERFACE_INCLUDE_DIRECTORIES and preserving the informational-only use of Opentims_LIBRARIES.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@cmake/cmake_findExternalLibs.cmake`:
- Around line 433-437: The FetchContent_Declare block for the opentims
dependency uses GIT_TAG v1.2.0b1 but the PR description requires OpenTIMS
v1.2.0b3; update the FetchContent_Declare invocation for the opentims target to
use the correct tag (change the GIT_TAG value), or if the documented version is
wrong, update the PR description to match GIT_TAG—ensure consistency between the
FetchContent_Declare (opentims / GIT_TAG) and the PR documentation.
---
Outside diff comments:
In `@cmake/cmake_findExternalLibs.cmake`:
- Around line 281-326: Remove the original duplicate WITH_OPENTIMS block (the
FetchContent_Declare/FetchContent_MakeAvailable sequence that creates opentims
and opentims_cpp, including the zstd fallback and target_* calls) so only the
newer block with find_package(Opentims QUIET) and the guarded FetchContent
remains; ensure you delete the entire first if (WITH_OPENTIMS) ... endif() that
references FetchContent_Declare(opentims),
target_include_directories(opentims_cpp ...), target_link_libraries(opentims_cpp
...), target_sources(opentims_cpp ...), and the message about Built opentims_cpp
so add_library(opentims::opentims_cpp ALIAS opentims_cpp) in the later block
will not collide with preexisting targets.
---
Nitpick comments:
In `@cmake/cmake_findExternalLibs.cmake`:
- Around line 414-427: The imported target opentims::opentims_cpp may not expose
INTERFACE_COMPILE_DEFINITIONS when discovered via the manual fallback, so the
get_target_property(_opentims_defs opentims::opentims_cpp
INTERFACE_COMPILE_DEFINITIONS) check can be empty and miss
OPENTIMS_LINK_SQLITE_STATICALLY; update the logic after get_target_property to
treat an empty/NOTFOUND _opentims_defs as a potential manual-install case and
fall back to assuming OPENTIMS_LINK_SQLITE_STATICALLY (or at least perform the
same include/link injection) when Opentims_FOUND was set via the manual search
path, ensuring target_include_directories and target_link_libraries are applied
to opentims::opentims_cpp if the property is missing but the library was
discovered manually.
In `@cmake/Modules/FindOpentims.cmake`:
- Around line 52-61: The manual-import branch that creates the imported target
(when Opentims_FOUND is true and adding opentims::opentims_cpp via add_library)
does not set INTERFACE_COMPILE_DEFINITIONS, so consumers can't detect
OPENTIMS_LINK_SQLITE_STATICALLY; update this module to (1) add a clear header
comment explaining this limitation and instruct downstream users how to override
compile definitions if needed, and (2) when creating the imported target
(add_library(opentims::opentims_cpp ...)/set_target_properties), explicitly set
INTERFACE_COMPILE_DEFINITIONS (e.g., to an empty list or a documented safe
default) so the property exists and downstream code in
cmake_findExternalLibs.cmake can behave deterministically; reference
Opentims_LIBRARY, Opentims_INCLUDE_DIR, INTERFACE_COMPILE_DEFINITIONS, and
OPENTIMS_LINK_SQLITE_STATICALLY in the comment.
- Around line 25-27: The get_target_property call for opentims::opentims_cpp
uses IMPORTED_LOCATION which may be NOTFOUND for interface/alias targets,
causing Opentims_LIBRARIES to be empty; update the logic around the
get_target_property for opener target opentims::opentims_cpp so it first checks
has_property or falls back to configuration-specific properties (e.g.,
IMPORTED_LOCATION_RELEASE, IMPORTED_LOCATION_DEBUG) or skips setting
Opentims_LIBRARIES when no imported location exists, while keeping
Opentims_INCLUDE_DIR from INTERFACE_INCLUDE_DIRECTORIES and preserving the
informational-only use of Opentims_LIBRARIES.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 18ba1c3f-2518-4b7f-bdab-14c0e52b7dd0
📒 Files selected for processing (2)
cmake/Modules/FindOpentims.cmakecmake/cmake_findExternalLibs.cmake
| # Prefer a CMake config package produced by opentims's own install rules. | ||
| find_package(opentims CONFIG QUIET | ||
| HINTS | ||
| "${Opentims_ROOT_DIR}" | ||
| "${Opentims_ROOT_DIR}/lib/cmake/opentims" | ||
| ) | ||
| if(opentims_FOUND) | ||
| if(NOT TARGET opentims::opentims_cpp) | ||
| message(FATAL_ERROR "opentims config package found but target opentims::opentims_cpp is missing") | ||
| endif() | ||
| set(Opentims_FOUND TRUE) | ||
| get_target_property(Opentims_INCLUDE_DIR opentims::opentims_cpp INTERFACE_INCLUDE_DIRECTORIES) | ||
| get_target_property(Opentims_LIBRARIES opentims::opentims_cpp IMPORTED_LOCATION) | ||
| return() | ||
| endif() |
There was a problem hiding this comment.
I think Cmake kind of does that distinction transparently, if you know what I mean.
You call find_package(${LIB}) from any main cmake file. This looks for a config file in ${LIB}_ROOT (or other system paths) automatically and if not, it falls back to whatever is done in cmake/Modules/Find${LIB}.cmake (if that Module exists locally or provided by CMake)
There was a problem hiding this comment.
You can force it to use one mode or the other by adding options to find_package() but by default it automatically tries both.
There was a problem hiding this comment.
I'm not enough of of CMake wizard to answer this intelligently, so I'll let Claude speak ;)
You're right that find_package(Foo) with no mode tries Config then Module automatically — but that switching only happens at the outermost call. Once CMake dispatches to our FindOpentims.cmake module,
it's fully in charge; CMake does not separately try Config mode afterward. The explicit find_package(opentims CONFIG QUIET) on line 22 is therefore necessary so that users with an upstream opentimsConfig.cmake get the proper imported target (including OPENTIMS_LINK_SQLITE_STATICALLY when relevant), with find_path/find_library as a fallback for installs that have no config package.
There was a problem hiding this comment.
Haha I don't get it. If the outermost call dispatches to Module mode, it does so because there is no Config found. Why would one want to try to find the Config again in the Find Module? It cannot magically appear.
@coderabbitai What do you think?
There was a problem hiding this comment.
@jpfeuffer, actually there are two concrete reasons why the inner find_package(opentims CONFIG QUIET) call inside FindOpentims.cmake is not redundant:
1. Module mode preempts Config mode entirely
CMake has two modes: "Module" mode and "Config" mode. Module mode is invoked with the basic signature, and only if no module is found does the command fall back to Config mode. Module mode searches for Find<PackageName>.cmake in CMAKE_MODULE_PATH first.
Since OpenMS registers its own cmake/Modules/ directory in CMAKE_MODULE_PATH and FindOpentims.cmake exists there, CMake finds the module immediately and never attempts Config mode at the outer level. The inner find_package(opentims CONFIG QUIET) is therefore the only place Config mode is ever tried.
2. Case sensitivity of config filenames on Linux
Even in a world without the FindOpentims.cmake module, there is a case-sensitivity trap. CMake config mode searches for a file called <PackageName>Config.cmake or <lower-case-package-name>-config.cmake.
So find_package(Opentims) (capital O) would look for OpentimsConfig.cmake (capital O) or opentims-config.cmake. But as pjones observed, the installed package ships opentimsConfig.cmake (lowercase o). If nameConfig.cmake is available, only find_package(name) works, not find_package(Name) — i.e. on a case-sensitive filesystem, the capital-O outer call would miss it. The inner find_package(opentims CONFIG QUIET) (lowercase) correctly matches opentimsConfig.cmake.
This is very likely the root cause of pjones's observation that the system-installed opentims 1.2.0b3 wasn't being detected — FindOpentims.cmake existed in CMAKE_MODULE_PATH, so the outer Config mode search was skipped entirely, and the inner Config call needs to use the correct lowercase name to match the installed file.
The fix to properly propagate Opentims_ROOT_DIR as a HINTS path to the inner call (which the current code already does) is also important for non-standard install prefixes.
🧠 Learnings used
Learnt from: jpfeuffer
Repo: OpenMS/OpenMS PR: 8530
File: src/pyOpenMS/CMakeLists.txt:78-80
Timestamp: 2026-01-12T12:26:12.890Z
Learning: In the OpenMS build system (src/pyOpenMS/CMakeLists.txt and related), when building pyOpenMS in standalone mode (via find_package(OpenMS REQUIRED)), the OpenMSConfig.cmake automatically finds all necessary public dependencies including Qt6, so Qt6_VERSION and related variables are available in both standalone and in-tree builds.
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8975
File: CMakeLists.txt:76-98
Timestamp: 2026-03-24T08:16:28.331Z
Learning: In OpenMS/OpenMS CMakeLists.txt, when using CMake FetchContent with DOWNLOAD_NO_EXTRACT TRUE for a plain (non-archive) file download (e.g., a .fasta file), the downloaded file lands in `<name>_SOURCE_DIR` with its original filename. The path `${<name>_SOURCE_DIR}/<filename>` is therefore the correct way to reference it, NOT `${<name>_DOWNLOADED_FILE}`. This was empirically verified by timosachsenberg in PR `#8975`.
|
@pjones author bot does some strange things |
Have you looked at the commits in this PR? They go back to 2022. The source branch for this PR is really, really weird. |
|
@michalsta I just tried to build this branch using an external opentims 1.2.0b3 and it doesn't find opentims and tries to use git. If it helps, here's the layout of the opentims package that shows up in the openms build environment: |
Adds FindOpentims.cmake and wraps the opentims FetchContent block in cmake_findExternalLibs.cmake with a find_package guard. If opentims is already installed (e.g. by a package manager or from source), CMake uses it directly and skips the git clone entirely. When no installation is found the existing FetchContent path is taken unchanged, so there is no regression for builds with network access. Fixes OpenMS#9147 Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…NITIONS - Bump FetchContent GIT_TAG from v1.2.0b1 to v1.2.0b3 to match the version in opentims pyproject.toml and the available git tags. - FindOpentims.cmake: explicitly set INTERFACE_COMPILE_DEFINITIONS to an empty list on the manual-import target so downstream consumers can distinguish "property absent" (CONFIG path) from "property set but empty" (manual path); add explanatory comment. - FindOpentims.cmake: fall back to IMPORTED_LOCATION_<Config> variants and clear Opentims_LIBRARIES to "" (not NOTFOUND) for interface-only CONFIG targets where IMPORTED_LOCATION is unset. - cmake_findExternalLibs.cmake: when INTERFACE_COMPILE_DEFINITIONS is NOTFOUND and the library was not found via a CMake config package, conservatively inject OpenMS sqlite3 since the build flags are unknown. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
CMake stores configuration-specific target properties under UPPERCASE suffixes (IMPORTED_LOCATION_RELEASE, not IMPORTED_LOCATION_Release). The fallback loop in FindOpentims.cmake was using mixed-case names, so the loop never matched and Opentims_LIBRARIES ended up empty when the package was installed without a bare IMPORTED_LOCATION property (e.g. a Release-only install from cmake --install). Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
… bump to v1.2.0b4 - Remove the old FetchContent-only block (lines 281-326) that predated the system-install fallback logic; the surviving block at the bottom of the file already handles both paths correctly. - Rename OPENTIMS_BUILD_CPP_LIB -> OPENTIMS_BUILD_LIB to match the refactored opentims CMakeLists.txt (idiomatic BUILD_SHARED_LIBS convention; the separate OPENTIMS_BUILD_SHARED_LIB option is gone). - Bump GIT_TAG from v1.2.0b3 to v1.2.0b4 to track the latest release. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
The unnamespaced opentims_cpp target only exists when opentims is built via FetchContent. When found as a system install, only the namespaced opentims::opentims_cpp imported target is available. Use the namespaced form everywhere so both paths work without conditional logic. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
a188b1b to
e127366
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (2)
cmake/Modules/FindOpentims.cmake (2)
79-84: Consider usingUNKNOWN IMPORTEDfor library type flexibility.Using
STATIC IMPORTEDassumes the library is always statically built. If OpenTIMS could be built as a shared library,UNKNOWN IMPORTEDwould let CMake infer the type from the file extension.This is a minor concern since OpenTIMS likely ships as a static library, but using
UNKNOWNis more robust.♻️ Optional: Use UNKNOWN for type inference
- add_library(opentims::opentims_cpp STATIC IMPORTED) + add_library(opentims::opentims_cpp UNKNOWN IMPORTED)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cmake/Modules/FindOpentims.cmake` around lines 79 - 84, The current add_library call creates an IMPORTED target with a fixed STATIC type; change the library type to UNKNOWN by using add_library(opentims::opentims_cpp UNKNOWN IMPORTED) so CMake can infer shared vs static from the file extension. Update the add_library invocation that defines the target opentims::opentims_cpp (leave set_target_properties and IMPORTED_LOCATION / INTERFACE_* properties unchanged) to ensure type-flexible linking without altering the rest of the target config.
14-19: Config mode hints may explain reported detection failure.The
HINTSonly take effect whenOpentims_ROOT_DIRis explicitly set. If the user installs OpenTIMS to a non-standard prefix without setting this variable,find_package(opentims CONFIG)won't find it unlessCMAKE_PREFIX_PATHoropentims_DIRis configured. This likely explains pjones' report that system OpenTIMS wasn't detected.Consider adding the standard
<PackageName>_ROOTvariable that CMake 3.12+ searches automatically:♻️ Suggested improvement for discovery
+# Support both the standard CMake <PackageName>_ROOT variable and custom hint. +# CMake 3.12+ automatically searches opentims_ROOT, but we also support Opentims_ROOT_DIR. +if(DEFINED Opentims_ROOT_DIR AND NOT DEFINED opentims_ROOT) + set(opentims_ROOT "${Opentims_ROOT_DIR}") +endif() + # Prefer a CMake config package produced by opentims's own install rules. find_package(opentims CONFIG QUIET HINTS "${Opentims_ROOT_DIR}" "${Opentims_ROOT_DIR}/lib/cmake/opentims" + "${opentims_ROOT}" + "${opentims_ROOT}/lib/cmake/opentims" )Alternatively, update the module documentation to clarify that users should set
CMAKE_PREFIX_PATHoropentims_DIR(the standard CMake variable for config mode) to point to their installation.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cmake/Modules/FindOpentims.cmake` around lines 14 - 19, The current find_package(opentims CONFIG ...) call only uses HINTS with Opentims_ROOT_DIR which CMake doesn't consult automatically; update the module so discovery also uses the standard package root/config variable and common prefix mechanisms: add support and mentions for opentims_DIR and CMAKE_PREFIX_PATH and, if desired, check for the conventional <PackageName>_ROOT variable behavior (Opentims_ROOT) so find_package(opentims CONFIG) will find installs without requiring Opentims_ROOT_DIR to be manually set; update the FindOpentims.cmake logic and/or module documentation to reference opentims_DIR and CMAKE_PREFIX_PATH as supported ways to point to the OpenTIMS installation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@cmake/Modules/FindOpentims.cmake`:
- Around line 79-84: The current add_library call creates an IMPORTED target
with a fixed STATIC type; change the library type to UNKNOWN by using
add_library(opentims::opentims_cpp UNKNOWN IMPORTED) so CMake can infer shared
vs static from the file extension. Update the add_library invocation that
defines the target opentims::opentims_cpp (leave set_target_properties and
IMPORTED_LOCATION / INTERFACE_* properties unchanged) to ensure type-flexible
linking without altering the rest of the target config.
- Around line 14-19: The current find_package(opentims CONFIG ...) call only
uses HINTS with Opentims_ROOT_DIR which CMake doesn't consult automatically;
update the module so discovery also uses the standard package root/config
variable and common prefix mechanisms: add support and mentions for opentims_DIR
and CMAKE_PREFIX_PATH and, if desired, check for the conventional
<PackageName>_ROOT variable behavior (Opentims_ROOT) so find_package(opentims
CONFIG) will find installs without requiring Opentims_ROOT_DIR to be manually
set; update the FindOpentims.cmake logic and/or module documentation to
reference opentims_DIR and CMAKE_PREFIX_PATH as supported ways to point to the
OpenTIMS installation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 96fa66c3-4491-4073-a5dc-fa8348c739ba
📒 Files selected for processing (4)
cmake/Modules/FindOpentims.cmakecmake/cmake_findExternalLibs.cmakesrc/openms/CMakeLists.txtsrc/tests/class_tests/openms/CMakeLists.txt
✅ Files skipped from review due to trivial changes (1)
- src/tests/class_tests/openms/CMakeLists.txt
🚧 Files skipped from review as they are similar to previous changes (1)
- cmake/cmake_findExternalLibs.cmake
…xport CMake requires every target linked by an exported target to be either an imported target or present in an export set — even for PRIVATE deps of a shared library. When opentims is found as a system install, opentims::opentims_cpp is an IMPORTED target and no export registration is needed. When it is built from source via FetchContent the target is a regular build target, which triggers: export called with target "OpenMS" which requires target "opentims_cpp" that is not in any export set. Fix by calling install_library(opentims_cpp) in the FetchContent path, which adds the target to OpenMSTargets — the same pattern used by Evergreen, SQLiteCpp, and other bundled dependencies. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Two issues from code review: 1. The manual-import fallback used `add_library(... STATIC IMPORTED)`. Change to `UNKNOWN IMPORTED` so CMake infers shared vs static from the file extension rather than assuming static. The rest of the set_target_properties call (IMPORTED_LOCATION, INTERFACE_*) is unchanged. 2. Only Opentims_ROOT_DIR (an OpenMS-specific variable) was listed in the hints/docs. Add opentims_ROOT to the find_path/find_library HINTS in the manual-search fallback so the standard CMP0074 package root variable is also effective there. Update the module header to document all supported discovery mechanisms: opentims_DIR, opentims_ROOT, CMAKE_PREFIX_PATH, and Opentims_ROOT_DIR (legacy). Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Yes, my bad: i initially started this off master branch, then realised its the wrong one, so I updated to devel but apparently that was not without side effects. I think it's fixed now with the force push. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@cmake/cmake_findExternalLibs.cmake`:
- Around line 390-394: The PR description still says "Requires OpenTIMS 1.2.0b3"
while the CMake FetchContent_Declare for opentims sets GIT_TAG to v1.2.0b4;
update the PR description to reference v1.2.0b4 (or add a note that 1.2.0b3
remains supported) and confirm compatibility, and if compatibility is required
document it in the PR description so the FetchContent_Declare (opentims /
GIT_TAG) and PR text are consistent.
- Around line 378-384: The condition that injects OpenMS sqlite3 uses
`_opentims_defs MATCHES "NOTFOUND"` which never matches the manual-fallback case
where `_opentims_defs` is set to an empty string; update the if condition in the
block that references `_opentims_defs` and `opentims_FOUND` (the same block that
calls target_include_directories(opentims::opentims_cpp ...) and
target_link_libraries(opentims::opentims_cpp ...)) to also treat an empty-string
`_opentims_defs` as the manual-fallback case (e.g., check `_opentims_defs
STREQUAL ""` in addition to MATCHES "NOTFOUND") so the sqlite3 include/link
injection runs when opentims is not found via config package.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 968f5993-0717-40f5-9327-cf7acb406d55
📒 Files selected for processing (1)
cmake/cmake_findExternalLibs.cmake
…halsta/OpenMS into fix/opentims-system-install-fallback
install_library() adds opentims_cpp to the install-tree export (OpenMSTargets via install(EXPORT)), but the build-tree export() call in export_macros.cmake uses _OPENMS_EXPORT_TARGETS, which is only populated by openms_register_export_target(). Without this call CMake errors at generate time: export called with target "OpenMS" which requires target "opentims_cpp" that is not in any export set. Matches the pattern used by Evergreen and IsoSpec in their own CMakeLists.txt files. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
@pjones The layout looks ok. But what is the layout of the external package? That would be the important one. The namings are a bit unconventional (_cpp.a, ++/ include dir) but should work. Depends on what is in the .cmake config. Can you also run OpenMS cmake with --debug-find? |
…tchContent path Two bugs in the FetchContent branch that only manifest on CI (where opentims is not installed system-wide): 1. BUILD_SHARED_LIBS=true is set in the top-level CMakeLists.txt (line 287) before cmake_findExternalLibs.cmake is included. Without an explicit override, opentims's CMakeLists.txt would produce libopentims_cpp.so instead of libopentims_cpp.a. The shared library lands in _deps/opentims-build/ rather than the system library path, so the build-time linker fails with "undefined reference to TimsDataHandle" when linking test binaries against libOpenMS.so (libopentims_cpp.so's directory is not in the test's -L search path). Fix: save/restore BUILD_SHARED_LIBS around FetchContent_MakeAvailable(opentims). 2. target_link_libraries(opentims_cpp PRIVATE sqlite3) links the bundled SQLite3 CMake target to the opentims_cpp STATIC library. For static library targets, CMake propagates PRIVATE deps into the link interface, so the export mechanism requires sqlite3 to be in the same export set. This conflicts with SQLiteCpp's own sqlite3 export and causes a CMake generate error. Fix: provide only the sqlite3 include directory (needed for compilation with OPENTIMS_LINK_SQLITE_STATICALLY); the sqlite3 symbols are resolved at final link time through OpenMS's SQLiteCpp dependency (SQLiteCpp PUBLIC-links sqlite3, so libsqlite3.a appears in libOpenMS.so's link command after libopentims_cpp.a). Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…llback sentinel FindOpentims.cmake sets INTERFACE_COMPILE_DEFINITIONS to "" on the manually created UNKNOWN IMPORTED target to signal "found via header/library search, sqlite linkage unknown". The previous condition only checked MATCHES "NOTFOUND" (which CMake sets when get_target_property finds no property), so it never fired for the empty-string case — skipping the sqlite3 include/link injection for system installs that lack a CMake config package. Add OR _opentims_defs STREQUAL "" to catch this case. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
okay, I think I've managed to coax it into building. The opentims side is done as well, with tag v1.2.0b4 being the one containing necessary changes. Ready for the merge when you are. |
|
I needed to test this against the latest commit on opentims to pull in the Thank you very much @michalsta!!! |
Add three missing entries for changes merged after the 2026-04-15 sync: - #9154: BrukerTimsFile spectra marked as CENTROID - #9148/#9147: system opentims install fallback before FetchContent - #9151: Bruker DIA MS2 centroiding without denoising (min_support=0) Co-authored-by: Copilot <[email protected]>
Add three missing entries for changes merged after the 2026-04-15 sync: - #9154: BrukerTimsFile spectra marked as CENTROID - #9148/#9147: system opentims install fallback before FetchContent - #9151: Bruker DIA MS2 centroiding without denoising (min_support=0) Co-authored-by: GitHub Copilot <[email protected]> Co-authored-by: Copilot <[email protected]>
Use standard CMake mechanisms to find OpenTIMS package already installed on system, fall back to git fetch+build from source (previous mechanism) if not present. Needs OpenTIMS 1.2.0b4 installed.
Summary by CodeRabbit
New Features
Chores