Skip to content
Open

Cmake #295

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions classes/cmake-3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
inherit: [cmake]

depends:
- name: devel::cmake-3
use: [tools]
tools:
target-toolchain: host-compat-toolchain
16 changes: 10 additions & 6 deletions classes/cmake.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
inherit: [cpackage, ninja, install, licenses]
inherit: [cpackage, ninja, install, licenses, make]
Copy link
Member

Choose a reason for hiding this comment

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

I'm afraid that doesn't work this way. After merging #282, the ninja and make classes set different values for the jobServer key. 😕

The only way forward that I see is to move the common parts of this class to classes/basement/bits/cmake.yaml and create a new class cmake-make that does inherit: ["basement::bits::cmake", make].

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😢 Bad timing... I have not rebased to #282...

I need this for only one package. I'll move make-inherit to the recipe and leave only the CMAKE_GENERATOR change here..

Copy link
Member

Choose a reason for hiding this comment

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

This seems fragile. I just had another idea. We could set jobServer: "fifo" explicitly in the cmake class again with a big, fat comment explaining why. This mode is compatible with both tools...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If make understands fifo as well why do we not simply set jobServer: "fifo" in the make-class?

Copy link
Member

Choose a reason for hiding this comment

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

It will fail if you start Bob from an old make. See here. OTOH, as soon as you hit a cmake/ninja recipe, this will happen anyway. Looking back, it should probably be a warning and just not pass the incompatible job server instead of failing.

Having said that, it sounds like an artificial problem. So using "fifo" consistently looks like the best way forward. Let's do it this way...


buildToolsWeak: [cmake]
buildVars: [AUTOCONF_HOST, AR, CC, CXX]
buildVars: [AUTOCONF_HOST, AR, CC, CXX, CMAKE_GENERATOR]
buildSetup: |
# Make sure CMake finds other stuff by its own logic too
CMAKE_FIND_ROOT_PATH=
Expand Down Expand Up @@ -144,7 +144,7 @@ buildSetup: |
pushd build

cmake "$1" \
-G Ninja \
-G "${CMAKE_GENERATOR:-Ninja}" \
${CMAKE_TOOLCHAIN_FILE:+-DCMAKE_TOOLCHAIN_FILE="$CMAKE_TOOLCHAIN_FILE"} \
-DCMAKE_FIND_ROOT_PATH="$CMAKE_FIND_ROOT_PATH" \
-DCMAKE_BUILD_TYPE=Bob \
Expand All @@ -155,9 +155,13 @@ buildSetup: |
-DCMAKE_MSVC_RUNTIME_LIBRARY="" \
"${@:2}"

ninjaParallel ${MAKE_OPTIONS:+"${MAKE_OPTIONS[@]}"} \
${MAKE_TARGETS:+"${MAKE_TARGETS[@]}"}

if [[ "${CMAKE_GENERATOR:-Ninja}" == Ninja ]]; then
ninjaParallel ${MAKE_OPTIONS:+"${MAKE_OPTIONS[@]}"} \
${MAKE_TARGETS:+"${MAKE_TARGETS[@]}"}
elif [[ "${CMAKE_GENERATOR:-Ninja}" == 'Unix Makefiles' ]]; then
makeParallel ${MAKE_OPTIONS:+"${MAKE_OPTIONS[@]}"} \
${MAKE_TARGETS:+"${MAKE_TARGET[@]}"}
fi
if [[ -n "$INSTALL" ]] ; then
DESTDIR="${PWD}/../install" cmake \
${INSTALL_COMPONENT:+-DCOMPONENT="$INSTALL_COMPONENT"} \
Expand Down
2 changes: 1 addition & 1 deletion classes/make.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
jobServer: "fifo-or-pipe"
jobServer: "fifo"
buildToolsWeak: [make]
buildVarsWeak: [MAKE_JOBS]
buildSetup: |
Expand Down
73 changes: 73 additions & 0 deletions recipes/devel/cmake-3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
inherit: [patch]

metaEnvironment:
PKG_VERSION: "3.31.0"
PKG_LICENSE: "BSD-3-Clause"

checkoutSCM:
scm: url
url: ${GITHUB_MIRROR}/Kitware/CMake/releases/download/v${PKG_VERSION}/cmake-${PKG_VERSION}.tar.gz
digestSHA256: "300b71db6d69dcc1ab7c5aae61cbc1aa2778a3e00cbd918bc720203e311468c3"
stripComponents: 1

checkoutDeterministic: True
checkoutScript: |
patchApplySeries $<@cmake/*.patch@>
Copy link
Member

Choose a reason for hiding this comment

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

This is certainly not working, or? Even if it does currently, it will fail in the future. We have to keep the cmake-3 patches separate...


multiPackage:
"":
inherit: [cmake]
depends:
- libs::expat-dev
- libs::jsoncpp-dev
- libs::libarchive-dev
- libs::libuv-dev
- libs::rhash-dev
- libs::zlib-dev
- net::curl-dev
- use: []
depends:
- libs::expat-tgt
- libs::jsoncpp-tgt
- libs::libarchive-tgt
- libs::libuv-tgt
- libs::rhash-tgt
- libs::zlib-tgt
- net::curl-tgt

buildScript: |
cmakeBuild "$1" \
-DKWSYS_LFS_WORKS=TRUE \
-DKWSYS_CHAR_IS_SIGNED=TRUE \
-DCMAKE_USE_SYSTEM_LIBRARIES=1 \
-DCTEST_USE_XMLRPC=OFF \
-DBUILD_CursesDialog=OFF

packageScript: |
cmakePackageTgt

provideDeps: [ "*-tgt" ]

bootstrap:
Copy link
Member

Choose a reason for hiding this comment

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

AFAICT, the bootstrap package can be removed, couldn't it?

inherit: [make, install]

buildTools: [target-toolchain]
buildVars: [CC, CXX, LD, CPPFLAGS, CFLAGS, CXXFLAGS, LDFLAGS]
buildVarsWeak: [MAKE_JOBS] # hook onto make class
buildScript: |
mkdir -p build install
pushd build
"$1"/bootstrap \
--prefix=/usr \
--parallel="${MAKE_JOBS-$(nproc)}" -- \
-DCMAKE_USE_OPENSSL:BOOL=OFF \
-DBUILD_CursesDialog=OFF
makeParallel
make install DESTDIR="$PWD/../install"
popd

packageScript: |
installPackageTgt "$1/install/"

provideTools:
cmake: usr/bin
5 changes: 3 additions & 2 deletions recipes/devel/cmake.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
inherit: [patch]

metaEnvironment:
PKG_VERSION: "3.25.1"
PKG_VERSION: "${DEVEL__CMAKE_VERSION:-4.2.1}"
Copy link
Member

Choose a reason for hiding this comment

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

I'm not a huge fan of this to be honest. It's better to have a dedicated cmake-3 recipe.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks. I guess you overlooked the remaining DEVEL__CMAKE_VERSION override...

PKG_LICENSE: "BSD-3-Clause"

checkoutSCM:
scm: url
url: ${GITHUB_MIRROR}/Kitware/CMake/releases/download/v${PKG_VERSION}/cmake-${PKG_VERSION}.tar.gz
digestSHA256: 1c511d09516af493694ed9baf13c55947a36389674d657a2d5e0ccedc6b291d8
digestSHA256: "${DEVEL__CMAKE_DIGEST:-414aacfac54ba0e78e64a018720b64ed6bfca14b587047b8b3489f407a14a070}"
stripComponents: 1

checkoutDeterministic: True
Expand Down Expand Up @@ -40,6 +40,7 @@ multiPackage:
-DKWSYS_LFS_WORKS=TRUE \
-DKWSYS_CHAR_IS_SIGNED=TRUE \
-DCMAKE_USE_SYSTEM_LIBRARIES=1 \
-DCMAKE_USE_SYSTEM_LIBRARY_CPPDAP=OFF \
-DCTEST_USE_XMLRPC=OFF \
-DBUILD_CursesDialog=OFF

Expand Down
22 changes: 12 additions & 10 deletions recipes/devel/cmake/0001-fix-curl-lib-deps.patch
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,29 @@ Fix CURL find package module
The current implementation does not account for transitive dependencies of
cURL. Add what is strictly necessary to get it compiled in our environment.

diff -Nurp a/Modules/FindCURL.cmake b/Modules/FindCURL.cmake
--- a/Modules/FindCURL.cmake 2022-11-30 14:57:03.000000000 +0100
+++ b/Modules/FindCURL.cmake 2022-12-05 21:25:34.000000000 +0100
@@ -185,13 +185,19 @@ find_package_handle_standard_args(CURL
diff -Nurp a/Modules/FindCURL.cmake b/Modules/FindCURL.cmake
--- a/Modules/FindCURL.cmake 2025-12-08 19:33:58.000000000 +0100
+++ b/Modules/FindCURL.cmake 2026-01-21 14:42:55.650870435 +0100
@@ -291,7 +291,7 @@ find_package_handle_standard_args(CURL
HANDLE_COMPONENTS)

if(CURL_FOUND)
- set(CURL_LIBRARIES ${CURL_LIBRARY})
+ set(CURL_LIBRARIES ${CURL_LIBRARY} ${PC_CURL_LIBRARIES})
set(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIR})

if(NOT TARGET CURL::libcurl)
add_library(CURL::libcurl UNKNOWN IMPORTED)
@@ -299,6 +299,13 @@ if(CURL_FOUND)
set_target_properties(CURL::libcurl PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}")

+ if(PC_CURL_FOUND)
+ set(CURL_DEPENDENCY_LIBRARIES "${PC_CURL_LIBRARIES}")
+ list(REMOVE_ITEM CURL_DEPENDENCY_LIBRARIES curl)
+ set_target_properties(CURL::libcurl PROPERTIES
+ INTERFACE_LINK_LIBRARIES "${CURL_DEPENDENCY_LIBRARIES}")
+ endif()

if(EXISTS "${CURL_LIBRARY}")
set_target_properties(CURL::libcurl PROPERTIES
+
if(CURL_USE_STATIC_LIBS)
set_property(TARGET CURL::libcurl APPEND PROPERTY
INTERFACE_COMPILE_DEFINITIONS "CURL_STATICLIB")