Skip to content

fix[next]: do not enable C in the generated CMake project - #2966

Draft
starkphi wants to merge 2 commits into
GridTools:mainfrom
starkphi:cmake-languages-cxx
Draft

starkphi wants to merge 2 commits into
GridTools:mainfrom
starkphi:cmake-languages-cxx

Conversation

@starkphi

@starkphi starkphi commented Nov 4, 2026 •

Copy link
Copy Markdown

Description

project() without LANGUAGES also enables C. With CC unset, CMake picks the system cc, and because FindOpenMP caches a single OpenMP_gomp_LIBRARY for all enabled languages, the module links the system compiler's libgomp instead of the one belonging to CXX. The project now declares LANGUAGES NONE; the languages it needs (CXX, plus CUDA or HIP for GPU sources) are enabled by the enable_language calls that follow. The generated code is unchanged; only the link changes. DaCe's codegen/CMakeLists.txt has the same project(dace_program), which this PR does not touch.

Requirements

  • All fixes and/or new features come with corresponding tests.
  • Important design decisions have been documented in the appropriate ADR inside the docs/development/ADRs/ folder.

If this PR contains code authored by new contributors please make sure:

  • The PR contains an updated version of the AUTHORS.md file adding the names of all the new contributors.

🤖 Generated with Claude Code

`project()` without `LANGUAGES` enables C and C++. With `CC` unset, CMake
then picks the system `cc`, and since FindOpenMP probes every enabled
language and caches one `OpenMP_gomp_LIBRARY`, the C++ module links the
system compiler's libgomp instead of the one of `CXX`. The generated code
is identical; only the link changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Hannes Vogt <hannes@havogt.de>
@starkphi

starkphi commented Nov 5, 2026

Copy link
Copy Markdown
Author

DaCe's codegen/CMakeLists.txt has the same project(dace_program), so DaCe-compiled programs still link the system libgomp when CC is unset. Two options: fix it in DaCe (project(dace_program LANGUAGES CXX); CUDA and HIP are already added later by enable_language when needed), or have gt4py pass -DCMAKE_C_COMPILER through DaCe's compiler.extra_cmake_args (tested, it works). Which would you prefer?

@havogt

havogt commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

DaCe's codegen/CMakeLists.txt has the same project(dace_program), so DaCe-compiled programs still link the system libgomp when CC is unset. Two options: fix it in DaCe (project(dace_program LANGUAGES CXX); CUDA and HIP are already added later by enable_language when needed), or have gt4py pass -DCMAKE_C_COMPILER through DaCe's compiler.extra_cmake_args (tested, it works). Which would you prefer?

If DaCe doesn't use C, then I think the fix there makes sense.

This branch has not been deployed

No deployments
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.

2 participants