Skip to content

build: integrate CVMix via FetchContent instead of download script#903

Merged
sebastianbeyer merged 2 commits into
mainfrom
feat/cvmix-fetchcontent
May 5, 2026
Merged

build: integrate CVMix via FetchContent instead of download script#903
sebastianbeyer merged 2 commits into
mainfrom
feat/cvmix-fetchcontent

Conversation

@sebastianbeyer
Copy link
Copy Markdown
Collaborator

We do need an offline-functionality for building on MN5, so I took this inspiration, read a bit into cmake and (together with claude), I came up with this simplification / extension:

Replace the custom download_cvmix.sh + add_custom_command + IMPORTED-target plumbing with FetchContent_MakeAvailable. CVMix is now built as a regular CMake subproject inside the build tree (no source-tree pollution, no separate sub-cmake invocation).

For builds on internet-restricted machines, point at a manually placed checkout with
-DFETCHCONTENT_SOURCE_DIR_CVMIX=/path/to/CVMix-src
and pass
-DFETCHCONTENT_FULLY_DISCONNECTED=ON.

@sebastianbeyer
Copy link
Copy Markdown
Collaborator Author

hm... looks like the issue is in the ci image in this case

@sebastianbeyer
Copy link
Copy Markdown
Collaborator Author

ah, should be okay, once #902 is merged

Comment thread src/CMakeLists.txt
include(FetchContent)
set(CVMIX_BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
set(CVMIX_BUILD_DRIVER OFF CACHE BOOL "" FORCE)
FetchContent_Declare(cvmix
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How does cmake know where to iinstall/put the CVMix files ? Or where does the clones repo end up ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The repo will be put into build/_deps/cvmix-src and then built in build/_deps/cvmix-build. It will be added to the main fesom build through add_subdirectory(), that is why cmake can then link it.

@patrickscholz
Copy link
Copy Markdown
Contributor

@suvarchal: We also had this improvement to the CVMix process, where suvi used a buildin Cmake function or something like that, #818, but apparently we never merged it. I think problem was that it was dependent on a rather actual CMake version, that not everywhere might be available. Sebastian solution looks very short and clean, but i honestly have no ideas about its pro/cons ...

@sebastianbeyer
Copy link
Copy Markdown
Collaborator Author

yes, that is the original PR that I found and that made me come up with this one. using FetchContent simplifies this a lot and does also handle the offline part very nicely.
It was added in Cmake 3.11 originally and the way we use it was added in 3.14. Fesom already required cmake 3.16. So that should be fine.

Replace the custom download_cvmix.sh + add_custom_command + IMPORTED-target
plumbing with FetchContent_MakeAvailable. CVMix is now built as a regular
CMake subproject inside the build tree (no source-tree pollution, no separate
sub-cmake invocation).

For builds on internet-restricted machines, point at a manually placed
checkout with -DFETCHCONTENT_SOURCE_DIR_CVMIX=/path/to/CVMix-src and pass
-DFETCHCONTENT_FULLY_DISCONNECTED=ON.
@sebastianbeyer sebastianbeyer force-pushed the feat/cvmix-fetchcontent branch from f3de96d to 597b600 Compare May 4, 2026 09:44
@suvarchal
Copy link
Copy Markdown
Collaborator

yes, that is the original PR that I found and that made me come up with this one. using FetchContent simplifies this a lot and does also handle the offline part very nicely. It was added in Cmake 3.11 originally and the way we use it was added in 3.14. Fesom already required cmake 3.16. So that should be fine.

wonderful, thanks for finishing this!

@sebastianbeyer sebastianbeyer merged commit f400e2b into main May 5, 2026
20 checks passed
@sebastianbeyer sebastianbeyer deleted the feat/cvmix-fetchcontent branch May 5, 2026 10:14
@JanStreffing JanStreffing added this to the FESOM 2.8 milestone May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants