Skip to content

COMP: Modernize CMake for add_subdirectory, googletest, and CMake 4.0 compatibility#130

Closed
hjmjohnson wants to merge 3 commits intoSCIInstitute:masterfrom
hjmjohnson:modernize-googletest
Closed

COMP: Modernize CMake for add_subdirectory, googletest, and CMake 4.0 compatibility#130
hjmjohnson wants to merge 3 commits intoSCIInstitute:masterfrom
hjmjohnson:modernize-googletest

Conversation

@hjmjohnson
Copy link
Copy Markdown

@hjmjohnson hjmjohnson commented Apr 15, 2026

Fix CMake >= 4.0 compatibility and improve add_subdirectory integration. Supersedes #129 (includes all its changes with cleaned-up commit history).

Motivated by SCIInstitute/ITKCleaver#77 — the ITK remote module CI currently works around these issues by forcing BUILD_TESTING OFF for the vendored Cleaver lib.

Commits (3)
  1. COMP: Scope CMake variables for add_subdirectory integration — replace CMAKE_BINARY_DIR/CMAKE_SOURCE_DIR with CLEAVER2_BINARY_DIR/CLEAVER2_SOURCE_DIR throughout; unset EXECUTABLE_OUTPUT_PATH to prevent propagation to consuming projects (from update cmake config for better integration #129, squashed and attributed)
  2. COMP: Replace CIBC-Internal/googletest with google/googletest v1.15.2 — FetchContent with modern CMake targets replaces 120-line ExternalProject + manual library path handling
  3. COMP: Bump vendored teem cmake_minimum_required to 3.10.2 — old VERSION 2.4 rejected by CMake >= 4.0; upstream teem now requires 3.25

@hjmjohnson
Copy link
Copy Markdown
Author

@jcfr I'm trying to get all ITK remote modules to work. Cleaver is failing due to some upstream deprecated code and cmake requirements.

@hjmjohnson hjmjohnson marked this pull request as ready for review April 15, 2026 20:45
@hjmjohnson hjmjohnson force-pushed the modernize-googletest branch from c7c99b1 to ecb553e Compare April 15, 2026 20:48
hjmjohnson and others added 3 commits April 15, 2026 15:51
Replace CMAKE_BINARY_DIR, CMAKE_SOURCE_DIR, and
CMAKE_CURRENT_SOURCE_DIR with CLEAVER2_BINARY_DIR and
CLEAVER2_SOURCE_DIR throughout. This prevents variable
collisions when Cleaver is consumed via add_subdirectory()
from a parent project (e.g., ITKCleaver).

Also unset EXECUTABLE_OUTPUT_PATH to stop propagating it
to consuming projects.

Co-Authored-By: stevencui2 <l5cui@uwaterloo.ca>
The old ExternalProject fetched an ancient fork
(CIBC-Internal/googletest, branch "origin/cleaver") whose
cmake_minimum_required predates 3.5, which CMake >= 4.0 rejects.

Replace with FetchContent from google/googletest v1.15.2 and use
the modern CMake targets (GTest::gtest_main, GTest::gmock). This
eliminates 120 lines of manual library path handling, platform-
specific linking workarounds, and the copy_deps ExternalProject step.
The vendored teem copy used cmake_minimum_required(VERSION 2.4),
which CMake >= 4.0 rejects. Bump to 3.10.2 to match the rest of
the project. Note: the upstream teem (github.com/mhalle/teem) now
requires CMake 3.25; this is a conservative bump for the vendored
copy.
@hjmjohnson hjmjohnson force-pushed the modernize-googletest branch from ecb553e to a65d048 Compare April 15, 2026 20:51
@hjmjohnson hjmjohnson changed the title COMP: Modernize googletest and fix CMake 4.0 compatibility COMP: Modernize CMake for add_subdirectory, googletest, and CMake 4.0 compatibility Apr 15, 2026
hjmjohnson added a commit to hjmjohnson/ITKCleaver that referenced this pull request Apr 15, 2026
The bundled googletest in SCIInstitute/Cleaver uses
cmake_minimum_required < 3.5 which CMake >= 4.0 rejects.
Disable BUILD_TESTING for the vendored lib unconditionally.
Upstream fix tracked at SCIInstitute/Cleaver#130.

The ITK module has its own CTest-based tests that are unaffected.
@hjmjohnson
Copy link
Copy Markdown
Author

Abandoning update to Cleaver. If this project becomes active again, revisit closed PRs.

@hjmjohnson hjmjohnson closed this Apr 23, 2026
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.

1 participant