Skip to content

Commit

Permalink
depends: add native cmake package
Browse files Browse the repository at this point in the history
  • Loading branch information
theuni committed Apr 7, 2023
1 parent db720b5 commit cb2a9d6
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 0 deletions.
30 changes: 30 additions & 0 deletions depends/packages/native_cmake.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package=native_cmake
$(package)_version=3.26.3
$(package)_download_path=https://github.com/Kitware/CMake/archive/refs/tags
$(package)_file_name=v$($(package)_version).tar.gz
$(package)_sha256_hash=3d4d96dbb2bbc4a2f070f3c3a27cf304ea02dab2f8df565df1521eaeaa9efeed
$(package)_patches=0001-bootstrap-don-t-over-quote-compiler-variables.patch 0002-bootstrap-correctly-deal-with-CC-CXX-env-vars-with-s.patch
$(package)_config_env = MAKE=$(MAKE)
$(package)_config_opts = --no-system-libs --prefix=$(build_prefix)
$(package)_config_opts += CFLAGS="$($(package)_cflags) $($(package)_cppflags)"
$(package)_config_opts += CXXFLAGS="$($(package)_cxxflags) $($(package)_cppflags)"
$(package)_config_opts += LDFLAGS="$($(package)_ldflags)"
$(package)_config_opts += CC="$($(package)_cc)"
$(package)_config_opts += CXX="$($(package)_cxx)"

define $(package)_preprocess_cmds
patch -p1 < $($(package)_patch_dir)/0001-bootstrap-don-t-over-quote-compiler-variables.patch && \
patch -p1 < $($(package)_patch_dir)/0002-bootstrap-correctly-deal-with-CC-CXX-env-vars-with-s.patch
endef

define $(package)_config_cmds
./bootstrap $($(package)_config_opts)
endef

define $(package)_build_cmds
$(MAKE)
endef

define $(package)_stage_cmds
$(MAKE) DESTDIR=$($(package)_staging_dir) install
endef
2 changes: 2 additions & 0 deletions depends/packages/packages.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
packages:=

native_packages = native_cmake

boost_packages = boost

libevent_packages = libevent
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
From 5d5402c9fefbd7096a8c09d08e36030a271e171d Mon Sep 17 00:00:00 2001
From: Cory Fields <cory-nospam-@coryfields.com>
Date: Fri, 7 Apr 2023 18:01:31 +0000
Subject: [PATCH 1/2] bootstrap: don't over-quote compiler variables

---
bootstrap | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/bootstrap b/bootstrap
index 3d5ef405cd..8c52f98a73 100755
--- a/bootstrap
+++ b/bootstrap
@@ -879,7 +879,7 @@ cmake_try_run ()
echo "---------- file -----------------------"
cat "${TESTFILE}"
echo "------------------------------------------"
- "${COMPILER}" ${FLAGS} "${TESTFILE}" -o "${TMPFILE}"
+ ${COMPILER} ${FLAGS} "${TESTFILE}" -o "${TMPFILE}"
RES=$?
if test "${RES}" -ne "0"; then
echo "Test failed to compile"
@@ -1434,13 +1434,13 @@ cd "${cmake_bootstrap_dir}/${TMPFILE}"
if test "${cmake_bootstrap_generator}" = "Ninja"; then
echo '
rule cc
- command = "'"${cmake_c_compiler}"'" '"${cmake_ld_flags} ${cmake_c_flags}"' -o $out $in
+ command = '"${cmake_c_compiler}"' '"${cmake_ld_flags} ${cmake_c_flags}"' -o $out $in
build test: cc test.c
'>"build.ninja"
else
echo '
test: test.c
- "'"${cmake_c_compiler}"'" '"${cmake_ld_flags} ${cmake_c_flags}"' -o test test.c
+ '"${cmake_c_compiler}"' '"${cmake_ld_flags} ${cmake_c_flags}"' -o test test.c
'>"Makefile"
fi
echo '
--
2.32.1 (Apple Git-133)

Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
From dcf22cb6e28dc7668b484a541dc166a1c139287f Mon Sep 17 00:00:00 2001
From: Cory Fields <cory-nospam-@coryfields.com>
Date: Fri, 7 Apr 2023 18:02:00 +0000
Subject: [PATCH 2/2] bootstrap: correctly deal with CC/CXX env vars with
spaces

---
bootstrap | 61 +++++++++++++++++++++++++++++++++++--------------------
1 file changed, 39 insertions(+), 22 deletions(-)

diff --git a/bootstrap b/bootstrap
index 8c52f98a73..a609f360ac 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1202,11 +1202,8 @@ esac
# Test C compiler
cmake_c_compiler=

-# If CC is set, use that for compiler, otherwise use list of known compilers
if test -n "${cmake_toolchain}"; then
eval cmake_c_compilers="\${cmake_toolchain_${cmake_toolchain}_CC}"
-elif test -n "${CC}"; then
- cmake_c_compilers="${CC}"
else
cmake_c_compilers="${CMAKE_KNOWN_C_COMPILERS}"
fi
@@ -1240,17 +1237,28 @@ int main(int argc, char* argv[])
' > "${TMPFILE}.c"
for std in 11 99 90; do
std_flags="`cmake_extract_standard_flags \"${cmake_toolchain}\" C \"${std}\"`"
- for compiler in ${cmake_c_compilers}; do
- for std_flag in '' $std_flags; do
- for thread_flag in '' $thread_flags; do
- echo "Checking whether '${compiler} ${cmake_c_flags} ${cmake_ld_flags} ${std_flag} ${thread_flag}' works." >> cmake_bootstrap.log 2>&1
- if cmake_try_run "${compiler}" "${cmake_c_flags} ${cmake_ld_flags} ${std_flag} ${thread_flag}" \
+ for std_flag in '' $std_flags; do
+ for thread_flag in '' $thread_flags; do
+ # If CC is set, use that for compiler, otherwise use list of known compilers
+ if test -n "${CC}" && test -z "${cmake_toolchain}"; then
+ echo "Checking whether '${CC} ${cmake_c_flags} ${cmake_ld_flags} ${std_flag} ${thread_flag}' works." >> cmake_bootstrap.log 2>&1
+ if cmake_try_run "${CC}" "${cmake_c_flags} ${cmake_ld_flags} ${std_flag} ${thread_flag}" \
"${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
- cmake_c_compiler="${compiler}"
- cmake_c_flags="${cmake_c_flags} ${std_flag} ${thread_flag}"
- break 4
+ cmake_c_compiler="${CC}"
+ cmake_c_flags="${cmake_c_flags} ${std_flag} ${thread_flag}"
+ break 3
fi
- done
+ else
+ for compiler in ${cmake_cxx_compilers}; do
+ echo "Checking whether '${compiler} ${cmake_c_flags} ${cmake_ld_flags} ${std_flag} ${thread_flag}' works." >> cmake_bootstrap.log 2>&1
+ if cmake_try_run "${compiler}" "${cmake_c_flags} ${cmake_ld_flags} ${std_flag} ${thread_flag}" \
+ "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
+ cmake_c_compiler="${compiler}"
+ cmake_c_flags="${cmake_c_flags} ${std_flag} ${thread_flag}"
+ break 4
+ fi
+ done
+ fi
done
done
done
@@ -1273,8 +1281,6 @@ cmake_cxx_compiler=
# If CC is set, use that for compiler, otherwise use list of known compilers
if test -n "${cmake_toolchain}"; then
eval cmake_cxx_compilers="\${cmake_toolchain_${cmake_toolchain}_CXX}"
-elif test -n "${CXX}"; then
- cmake_cxx_compilers="${CXX}"
else
cmake_cxx_compilers="${CMAKE_KNOWN_CXX_COMPILERS}"
fi
@@ -1361,17 +1367,28 @@ int main()
' > "${TMPFILE}.cxx"
for std in 17 14 11; do
std_flags="`cmake_extract_standard_flags \"${cmake_toolchain}\" CXX \"${std}\"`"
- for compiler in ${cmake_cxx_compilers}; do
- for std_flag in '' $std_flags; do
- for thread_flag in '' $thread_flags; do
- echo "Checking whether '${compiler} ${cmake_cxx_flags} ${cmake_ld_flags} ${std_flag} ${thread_flag}' works." >> cmake_bootstrap.log 2>&1
- if cmake_try_run "${compiler}" "${cmake_cxx_flags} ${cmake_ld_flags} ${std_flag} ${thread_flag}" \
+ for std_flag in '' $std_flags; do
+ for thread_flag in '' $thread_flags; do
+ # If CXX is set, use that for compiler, otherwise use list of known compilers
+ if test -n "${CXX}" && test -z "${cmake_toolchain}"; then
+ echo "Checking whether '${CXX} ${cmake_cxx_flags} ${cmake_ld_flags} ${std_flag} ${thread_flag}' works." >> cmake_bootstrap.log 2>&1
+ if cmake_try_run "${CXX}" "${cmake_cxx_flags} ${cmake_ld_flags} ${std_flag} ${thread_flag}" \
"${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
- cmake_cxx_compiler="${compiler}"
+ cmake_cxx_compiler="${CXX}"
cmake_cxx_flags="${cmake_cxx_flags} ${std_flag} ${thread_flag} "
- break 4
+ break 3
fi
- done
+ else
+ for compiler in ${cmake_cxx_compilers}; do
+ echo "Checking whether '${compiler} ${cmake_cxx_flags} ${cmake_ld_flags} ${std_flag} ${thread_flag}' works." >> cmake_bootstrap.log 2>&1
+ if cmake_try_run "${compiler}" "${cmake_cxx_flags} ${cmake_ld_flags} ${std_flag} ${thread_flag}" \
+ "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
+ cmake_cxx_compiler="${compiler}"
+ cmake_cxx_flags="${cmake_cxx_flags} ${std_flag} ${thread_flag} "
+ break 4
+ fi
+ done
+ fi
done
done
done
--
2.32.1 (Apple Git-133)

0 comments on commit cb2a9d6

Please sign in to comment.