Commit Graph

46 Commits

Author SHA1 Message Date
Tjalling Hattink
29a56e0412 build: suppress cmake warnings about unused vars
When cmake is invoked to build a package it usually reports a warning
about unused variables passed to it. This is caused by openwrt passing
all supported variables to cmake, even if they are not all required by
the package being compiled.

To reduce clutter when compiling such packages these warnings are now
suppressed.

Approved-by: Rosen Penev <rosenp@gmail.com>
Reviewed-by: Robert Marko <robimarko@gmail.com>
Signed-off-by: Tjalling Hattink <t.hattink@fugro.com>
2023-10-04 12:28:45 +02:00
Ansuel Smith
88204bfa82 treewide: drop use of which
Ubuntu started to flag which as deprecated and it
seems which is not really standard and may vary
across Distro.
Drop the use of which and use the standard 'command -v'
for this simple task.
Which is still present in the prereq if some package/script
still use which.
A utility script called command_all.sh is implemented that
will just mimic the output of which -a.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
2022-01-17 09:14:26 +01:00
Felix Fietkau
a6a9f9be27 include/cmake.mk: add support for overriding the host install prefix
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2021-11-04 16:55:04 +01:00
Felix Fietkau
1c07eab9f8 include/cmake.mk: fix host builds with CMAKE_BINARY_SUBDIR
Use it in the same way as for target builds

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2021-10-20 11:35:34 +02:00
Felix Fietkau
18430a34e6 build: do not override DESTDIR for cmake ninja host builds
The full prefix is already passed to cmake

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2021-06-12 14:33:57 +02:00
Felix Fietkau
0c7c24d40a build: use ninja for cmake packages by default
Speed goes from:

Executed in     178.08 secs     fish            external
usr time        20.16 mins      509.00 micros   20.16 mins
sys time        2.88 mins       39.00 micros    2.88 mins

To:

Executed in     175.90 secs     fish            external
usr time        20.19 mins      0.00 micros     20.19 mins
sys time        2.85 mins       497.00 micros   2.85 mins

Tested with "time make -j 12" on AMD Ryzen 3600

When building individual packages, the build time difference is often
significantly bigger than that.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-06-12 10:46:39 +02:00
Felix Fietkau
97258f5363 build: add ninja build tool and make it available for cmake
ninja is faster at building cmake packages than make, and according to reports
also more reliable at handling parallel builds
This commit includes a patch that adds GNU make jobserver support, in order to
allow more precise control over the number of parallel tasks

Enable parallel build by default for packages using ninja

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-06-12 10:46:39 +02:00
Clemens Fruhwirth
1f5e722486 Revert "build: replace which with Bash command built-in"
This reverts commit c7aec47e5e.

The original commit replaces 'which' with 'command'. Sadly most of
them are not equivalent and for 'which -a', there is no easy
replacements that would not reimplement PATH parsing logic. Hence
revert. Keeping a dependency on which is absolutely fine.

Signed-off-by: Clemens Fruhwirth <clemens@endorphin.org>
2021-03-03 22:51:39 +01:00
Petr Štetiar
c7aec47e5e build: replace which with Bash command built-in
`which` utility is not shipped by default for example on recent Arch
Linux and then any steps relying on its presence fails, like for example
following Python3 prereq build check:

 $ python3 --version
 Python 3.9.1

 $ make
 /bin/sh: line 1: which: command not found
 /bin/sh: line 1: which: command not found
 /bin/sh: line 1: which: command not found
 ...
 Checking 'python3'... failed.
 ...

Fix this by switching to Bash builtin `command` which should provide
same functionality.

Fixes: FS#3525
Signed-off-by: Petr Štetiar <ynezz@true.cz>
2021-01-04 19:32:25 +01:00
Hirokazu MORIKAWA
d6cb50c7ba include/cmake.mk: Fix the bug in ccache support
Fix the bug in ccache support due to this change.
bfc433efd4

The new cmake uses this for the wrapper.
https://cmake.org/cmake/help/v3.19/prop_tgt/LANG_COMPILER_LAUNCHER.html

Signed-off-by: Hirokazu MORIKAWA <morikw2@gmail.com>
2020-12-21 19:53:10 +01:00
Petr Štetiar
524fb5646e cmake.mk,rules.mk: fix host builds using CMake and ccache
Commit f98878e4c1 ("cmake.mk: set C/CXX compiler for host builds as
well") has introduced regression as it didn't taken usage of ccache into
the account so fix it by handling ccache use cases as well.

In order to get this working we need to export HOSTCXX_NOCACHE in
rules.mk as well.

Fixes: f98878e4c1 ("cmake.mk: set C/CXX compiler for host builds as well")
Reported-by: Ansuel Smith <ansuelsmth@gmail.com>
Tested-by: Ansuel Smith <ansuelsmth@gmail.com>
Signed-off-by: Petr Štetiar <ynezz@true.cz>
2020-11-28 16:17:58 +01:00
Rosen Penev
f98878e4c1 cmake.mk: set C/CXX compiler for host builds as well
Without this, cmake will use whatever CC/CXX is set to, which could be
clang. In that case, at least libjson-c/host will fail to compile.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-11-27 14:46:13 +01:00
Felix Fietkau
d31da371ac build: support cmake verbose for host builds
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-11-14 14:48:30 +01:00
Jeffery To
f8b775e287 cmake: Disable use of package registries
CMake provides a user package registry (stored in ~/.cmake/packages) and
a system package registry (not available on non-Windows platforms).

The "export(PACKAGE)" command may store information in the user package
registry, and the "find_package()" command may search both user and
system package registries for information.

This sets various variables to disable the use of these package
registries (both saving and retrieval of package information).

This also sets deprecated variables that perform similar functions, in
case external toolchains include older versions of CMake.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2020-08-24 18:53:59 +02:00
Rosen Penev
383abffb11 cmake: Install host packages to lib instead of lib64
Several CMake packages such as log4cplus and protobuf(-c) install to
lib64 instead of lib on some hosts. This completely breaks rpath linking.
Override it globally to avoid fixing each package individually.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Tested-by: Sebastian Kemper <sebastian_ml@gmx.net>
2019-12-23 00:22:07 +01:00
Amol Bhave
366e6ef5c3 build: use CMAKE_SOURCE_SUBDIR variable to cmake.mk
Sometimes, the CMakeLists.txt file is not in the root directory of a
repo. In those cases, the CMAKE_SOURCE_SUBDIR variable can be specified
to use CMakeLists.txt from a subdirectory instead.

Signed-off-by: Amol Bhave <ambhave@fb.com>
2018-09-29 17:23:11 +02:00
Felix Fietkau
294e908a2c cmake: skip build system check on compile
cmake checks the build system and its variables on its own to detect if
the makefiles need to be regenerated.
Unfortunately this can invalidate overrides passed in the
Build/Configure step. On non-Linux systems this breaks the build when
switching between targets of the same package architecture.

Fix this by forcibly disabling the build system check and relying on the
LEDE build system to take care of these things

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2017-02-21 13:03:20 +01:00
Matthias Schiffer
3d71786154
build: move STAGING_DIR_HOSTPKG and BUILD_DIR_HOST back to a common directory for all targets
Using a single host package staging dir (and build dir) significantly speeds up
builds when multiple targets are built in succession, especially for large host
packages like NodeJS.

$(STAGING_DIR)/host is kept in addition to $(STAGING_DIR_HOSTPKG) in most
places; it is still used as destination for host files in Build/InstallDev.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
2017-01-18 19:47:36 +01:00
Hauke Mehrtens
559fb537d8 build: use CXXFLAGS if defined
Instead of using TARGET_CFLAGS and EXTRA_CFLAGS in cmake and scons
build use the TARGET_CXXFLAGS and EXTRA_CXXFLAGS like it is done for
normal make and configure. configure used TARGET_CXXFLAGS and
EXTRA_CFLAGS for the CXXFLAGS. The package-default.mk sets
"EXTRA_CXXFLAGS = $(EXTRA_CFLAGS)" so using EXTRA_CXXFLAGS flags should
be save.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2016-10-13 17:04:43 +02:00
Felix Fietkau
50e7c1f79d include/cmake.mk: fix host builds
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2016-07-29 22:47:46 +02:00
Luke McKee
eadf5fb7f8 cmake: include/cmake.mk add CMAKE_BINARY_SUBDIR to allow out of source tree builds
Some packages need out of source tree building with cmake, for example
when building kernel modules.
See an example here:
https://sourceforge.net/p/accel-ppp/code/ci/master/tree/README

Signed-off-by: Luke McKee <hojuruku@gmail.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name> [cleanup, rework]
2016-07-29 20:27:34 +02:00
Vasilis Tsiligiannis
d55512075b include/cmake.mk: Add helper macro to handle conditionals for CMake boolean type variables
Signed-off-by: Vasilis Tsiligiannis <acinonyx@openwrt.gr>

SVN-Revision: 49164
2016-04-13 20:21:38 +00:00
Felix Fietkau
1d2c63c455 include/cmake.mk: search in $(STAGING_DIR)/usr instead of plain $(STAGING_DIR) to avoid picking up stuff from host/
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 48492
2016-01-25 15:49:49 +00:00
Felix Fietkau
7b5236de85 include/cmake.mk: adjust for STAGING_DIR_HOST split
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 48491
2016-01-25 15:49:44 +00:00
Felix Fietkau
48fc1f9781 build: for cmake, always use ccache from staging dir instead of relying on the host
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 48079
2016-01-03 14:44:30 +00:00
Felix Fietkau
d2ecd10f2f cmake.mk: enable -Bsymbolic-functions by default for linking shared libs, slightly improves performance and compression
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 45508
2015-04-19 18:33:07 +00:00
Felix Fietkau
4cfc7b50ae cmake.mk: add host build support
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 45282
2015-04-06 19:37:42 +00:00
Felix Fietkau
a5422864f5 build: fix CMake assembly builds with ccache
CMAKE_ASM_COMPILER is automatically set to CMAKE_C_COMPILER by CMake, but
CMAKE_C_COMPILER_ARG1 is lost. This causes assembly builds to fail when ccache
is enabled (for example the package fastd on x86).

Fix this by explicitly defining CMAKE_ASM_COMPILER and CMAKE_ASM_COMPILER_ARG1.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>

SVN-Revision: 45119
2015-03-29 05:12:58 +00:00
Felix Fietkau
da91462013 cmake: include external toolchain directory in CMAKE_FIND_ROOT_PATH (fixes #19074)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 44825
2015-03-16 07:51:45 +00:00
Jo-Philipp Wich
fd53d49f5b include: cmake: prevent inclusion of rpath in binaries
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>

SVN-Revision: 44328
2015-02-08 22:54:15 +00:00
Felix Fietkau
9a46799804 build: use gcc-provided ar, nm and ranlib where appropriate
Since GCC 4.7, GCC provides its own wrappers around ar, nm and ranlib, which
should be used for builds with link-time optimization. Since GCC 4.9, using them
actually necessary for LTO builds using convenience libraries to succeed.

There are some packages which try to automatically detect if gcc-{ar,nm,ranlib}
exist (one example is my package "fastd" in the package repository, which tries
to use LTO). This breaks because the OpenWrt build system explicitly sets the
binutils versions of these tools.

As it doesn't cause any issues to use gcc-{ar,nm,ranlib} instead of
{ar,nm,ranlib} even without LTO, this patch just makes OpenWrt use the
GCC-provided versions by default, which fixes the build of such packages with
GCC 4.9.

(I know that builds fail though when clang is used with -flto and
gcc-{ar,nm,ranlib}, but as all OpenWrt toolchains are based on GCC, this isn't
a real issue.)

Completely cleaning the tree (or at least `make clean toolchain/clean`) is
necessary to get a consistent state after the binutils plugins support patch and
this one (as trying to use gcc-{ar,nm,ranlib} with a binutils built without
plugin support will definitely lead to a build failure).

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>

SVN-Revision: 43784
2014-12-27 12:59:59 +00:00
Felix Fietkau
ca6ba637cd include/cmake.mk: fix indentation
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 41144
2014-06-11 17:01:15 +00:00
Felix Fietkau
0e9245c19f include/cmake.mk: define CMAKE_AR and CMAKE_RANLIB to fix build errors
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 40885
2014-05-30 11:58:54 +00:00
Felix Fietkau
9706d4e00e cmake.mk: fix support for ccache
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 38853
2013-11-18 14:10:12 +00:00
Jo-Philipp Wich
73a584f912 include: cmake: pass toolchain directory to default root find path as well
SVN-Revision: 37737
2013-08-07 13:54:51 +00:00
Felix Fietkau
f3d5f6ccb0 cmake.mk: add support for overriding the source dir, and define the cmake prefix path to avoid picking up host libraries for target builds (patch by Henning Rogge)
SVN-Revision: 34914
2012-12-29 11:12:31 +00:00
Felix Fietkau
b648860f9c cmake: add support for V=cs
SVN-Revision: 31485
2012-04-26 17:54:03 +00:00
Jo-Philipp Wich
9054bc91b3 cmake.mk: fix passing of LDFLAGS
SVN-Revision: 29701
2012-01-09 05:42:04 +00:00
Felix Fietkau
0d0915d168 cmake: fix ccache command when using host ccache (patch from #9611)
SVN-Revision: 27742
2011-07-24 08:34:08 +00:00
Jo-Philipp Wich
cda35d2ef2 cmake.mk: fix bogus values for FIND_ROOT_PATH_MODE_*; kept plplot from compiling (#9573)
SVN-Revision: 27256
2011-06-22 11:02:00 +00:00
Felix Fietkau
aea6afefe6 add LD_LIBRARY to cmake.mk
Otherwise cmake programs try to link with host ld.so

Signed-off-by: Jan Willies <jan@willies.info>

SVN-Revision: 26963
2011-05-20 16:21:30 +00:00
Jo-Philipp Wich
0f13d0a068 cmake.mk: don't assume toolchain binaries in .../bin/ if an external toolchain is used, rely on which instead
SVN-Revision: 26584
2011-04-11 02:11:11 +00:00
Michael Büsch
9e7801b913 cmake: Fix ccache
SVN-Revision: 25878
2011-03-05 10:36:52 +00:00
Michael Büsch
6da37f79c5 cmake: Pass VERBOSE=1 to the generated makefile to reveal flags and commands in a verbose openwrt build.
SVN-Revision: 25376
2011-02-05 19:50:54 +00:00
Michael Büsch
21e2dcd199 cmake: Remove -O3 from release CFLAGS. Honor the OpenWRT -Os flag instead.
SVN-Revision: 25372
2011-02-05 19:39:48 +00:00
Felix Fietkau
c4d2dde396 add a template for cmake packages
SVN-Revision: 25265
2011-01-31 20:16:01 +00:00