Skip to content

Add CMake example#2731

Open
pavelzw wants to merge 3 commits intoconda-forge:mainfrom
pavelzw:cmake
Open

Add CMake example#2731
pavelzw wants to merge 3 commits intoconda-forge:mainfrom
pavelzw:cmake

Conversation

@pavelzw
Copy link
Member

@pavelzw pavelzw commented Jan 30, 2026

PR Checklist:

  • note any issues closed by this PR with closing keywords
  • if you are adding a new page under docs/ or community/, you have added it to the sidebar in the corresponding _sidebar.json file
  • put any other relevant information below

@netlify
Copy link

netlify bot commented Jan 30, 2026

Deploy Preview for conda-forge-previews ready!

Name Link
🔨 Latest commit cfc6e49
🔍 Latest deploy log https://app.netlify.com/projects/conda-forge-previews/deploys/698c9494e1cff20008cfe751
😎 Deploy Preview https://deploy-preview-2731--conda-forge-previews.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 70
Accessibility: 96
Best Practices: 100
SEO: 89
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@pavelzw pavelzw marked this pull request as ready for review January 30, 2026 16:52
@pavelzw pavelzw requested a review from a team as a code owner January 30, 2026 16:52
Comment on lines 19 to 46
build:
number: 0
script:
content:
- if: unix
then:
- cmake -B build -GNinja $CMAKE_ARGS .
else:
- cmake -B build -GNinja %CMAKE_ARGS% .
- cmake --build build
- cmake --install build

requirements:
build:
- ${{ stdlib('c') }}
- ${{ compiler('c') }}
- ${{ compiler('cxx') }} # optional
- cmake
- ninja
host:
# put any dependencies here
run_exports:
- ${{ pin_subpackage('example-package', upper_bound='x.x.x') }}

tests:
- package_contents:
lib:
- example_package
Copy link
Member

Choose a reason for hiding this comment

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

Maybe helpful to add some inline comments with short explanations like those you can see in #2739.

Or, otherwise, a paragraph or two explaining some of the decisions made in this recipem like in Rust or Go.

Copy link
Member Author

Choose a reason for hiding this comment

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

i would prefer adding the paragraphs below as i always get annoyed by the need to delete half of the lines in https://github.com/conda-forge/staged-recipes/blob/main/recipes/example-v1/recipe.yaml

Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines 23 to 29
- if: unix
then:
- cmake -B build -GNinja $CMAKE_ARGS .
else:
- cmake -B build -GNinja %CMAKE_ARGS% .
- cmake --build build
- cmake --install build
Copy link
Member

Choose a reason for hiding this comment

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

Let's use scripts for these and add ctest, CPU_COUNT etc.

Copy link
Member Author

Choose a reason for hiding this comment

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

wdym with scripts? build.sh and build.bat?

Copy link
Member

Choose a reason for hiding this comment

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

yes

Copy link
Member Author

@pavelzw pavelzw Feb 11, 2026

Choose a reason for hiding this comment

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

i don't like separating trivial-ish recipes into recipe.yaml, build.sh and build.bat, especially if windows and linux are basically the same. this takes longer to copy as i need to copy three files instead of just one and harder to review on first glance as things are now split between files.

cfc6e49 (this PR)

Copy link
Member

Choose a reason for hiding this comment

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

The bot knows how to edit build.sh and build.bat when adding cross compilation. So it's important to have them.

Copy link
Member Author

@pavelzw pavelzw Feb 11, 2026

Choose a reason for hiding this comment

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

what additional modifications are needed to build.sh/build.bat when cross-compiling cmake projects? in https://conda-forge.org/blog/2020/10/29/macos-arm64/#how-to-add-a-osx-arm64-build-to-a-feedstock i only see the mentioning of ${CMAKE_ARGS} which are already in this template

Copy link
Member

Choose a reason for hiding this comment

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

I agree on preferring to have proper build scripts.

@pavelzw pavelzw requested review from isuruf and jaimergp February 11, 2026 14:40
else:
- cmake -B build -GNinja %CMAKE_ARGS% .
- cmake --build build --parallel %CPU_COUNT%
- ctest --test-dir build --output-on-failure
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Grepping through the rattler-build codebase, the only env variable i can find is CONDA_BUILD_CROSS_COMPILATION. @wolfv is CONDA_BUILD_SKIP_TESTS and CROSSCOMPILING_EMULATOR not being set intentional?

Also, why not something like

if [[ "${CONDA_BUILD_SKIP_TESTS:-}" != "1" ]]; then
    ctest
fi

in build.sh?

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.

4 participants