Introducing CMAKETARGETS infrastructure
v3 cover Introducing CMAKETARGETS infrastructure
This patch series adds a new infrastructure for CMake packages called CMAKETARGETS. It is based on the AUTOTARGETS infrastructure.
Changes in v3:
* Fix host-cdrkit build failure (thanks Thomas)
* Set PKG_CONFIG_SYSROOT_DIR in toolchain file
* CMAKE_INSTALL_PREFIX + DESTDIR modification for host packages
* Properly escape CMAKE_C/CXX_FLAGS when writing the toolchain file (so that the variables are not expanded immediately). Without this, flags set in package.mk would be ignored.
* Disable ccache as it seems to break CMake compiler detection.
Bj?rn Forsman (4):
Makefile: generate CMake toolchain-file in $(O) Add CMAKETARGETS infrastructure for CMake packages
doc: add CMAKETARGETS documentation
cdrkit: convert to CMAKETARGETS infrastructure
Makefile | 17 ++++- docs/buildroot.html | 151 +++++++++++++++++++++++++++++++++- package/Makefile.cmake.in | 197 +++++++++++++++++++++++++++++++++++++++++++++ package/Makefile.in | 9 ++ package/cdrkit/cdrkit.mk | 66 ++------------- 5 files changed, 378 insertions(+), 62 deletions(-) create mode 100644 package/Makefile.cmake.in
PATCH v3 1/4 Makefile: generate CMake toolchain-file in $(O)
A CMake toolchain-file makes it easy to develop CMake-based packages outside of Buildroot. Just give the toolchain-file to CMake via the -DCMAKE_TOOLCHAIN_FILE=... option.
--- Makefile | 17 ++++++++++++++++- package/Makefile.in | 8 ++++++++ 2 files changed, 24 insertions(+), 1 deletions(-)
Makefile +16 -1
@@ -363,7 +363,7 @@ $(TARGETS_ALL): __real_tgt_%: $(BASE_TARGETS) % dirs: $(DL_DIR) $(TOOLCHAIN_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \ $(HOST_DIR) $(BR2_DEPENDS_DIR) $(BINARIES_DIR) $(STAMP_DIR) -$(BASE_TARGETS): dirs +$(BASE_TARGETS): dirs $(O)/toolchainfile.cmake $(BUILD_DIR)/buildroot-config/auto.conf: $(CONFIG_DIR)/.config $(MAKE) $(EXTRAMAKEARGS) silentoldconfig
@@ -372,6 +372,21 @@ prepare: $(BUILD_DIR)/buildroot-config/auto.conf world: prepare dependencies dirs $(BASE_TARGETS) $(TARGETS_ALL) +$(O)/toolchainfile.cmake: + @echo -en "\ + set(CMAKE_SYSTEM_NAME Linux)\n\ + set(CMAKE_C_COMPILER $(CMAKE_TARGET_CC))\n\ + set(CMAKE_CXX_COMPILER $(CMAKE_TARGET_CXX))\n\ + set(CMAKE_C_FLAGS \"\$${CMAKE_C_FLAGS} $(CMAKE_TARGET_CFLAGS)\" CACHE STRING \"Buildroot CFLAGS\" FORCE)\n\ + set(CMAKE_CXX_FLAGS \"\$${CMAKE_CXX_FLAGS} $(CMAKE_TARGET_CXXFLAGS)\" CACHE STRING \"Buildroot CXXFLAGS\" FORCE)\n\ + set(CMAKE_INSTALL_SO_NO_EXE 0)\n\ + set(CMAKE_PROGRAM_PATH \"$(HOST_DIR)/usr/bin\")\n\ + set(CMAKE_FIND_ROOT_PATH \"$(STAGING_DIR)\")\n\ + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)\n\ + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)\n\ + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)\n\ + set(ENV{PKG_CONFIG_SYSROOT_DIR} \"$(STAGING_DIR)\")\n\ + " > $@ .PHONY: all world dirs clean distclean source outputmakefile \ $(BASE_TARGETS) $(TARGETS) $(TARGETS_ALL) \
package/Makefile.in +8 -0
@@ -143,6 +143,14 @@ TARGET_CC := $(CCACHE) $(TARGET_CC) TARGET_CXX := $(CCACHE) $(TARGET_CXX) endif +# * CMake doesn't support having the --sysroot option directly in the +# compiler path, so move this option to CFLAGS/CXXFLAGS variables. +# * Don't use ccache because then CMake will fail to detect compiler. +CMAKE_TARGET_CC = $(filter-out --sysroot=%,$(TARGET_CC_NOCCACHE)) +CMAKE_TARGET_CXX = $(filter-out --sysroot=%,$(TARGET_CXX_NOCCACHE)) +CMAKE_TARGET_CFLAGS = $(filter --sysroot=%,$(TARGET_CC_NOCCACHE)) $(TARGET_CFLAGS) +CMAKE_TARGET_CXXFLAGS = $(filter --sysroot=%,$(TARGET_CXX_NOCCACHE)) $(TARGET_CXXFLAGS) + ifeq ($(BR2_STRIP_strip),y) STRIP_DISCARD_ALL:=--discard-all STRIP_STRIP_UNNEEDED:=--strip-unneeded
Signature · 1 line
1.7.1
PATCH v3 2/4 Add CMAKETARGETS infrastructure for CMake packages
In reply to Bjørn ForsmanThe CMAKETARGETS infrastructure makes adding CMake-based packages to Buildroot easy. It uses the same set of variables as the autotools infrastructure, except for autoreconf and libtool stuff which is not needed. Usage: just call CMAKETARGETS instead of AUTOTARGETS.
--- package/Makefile.cmake.in | 197 +++++++++++++++++++++++++++++++++++++++++++++ package/Makefile.in | 1 + 2 files changed, 198 insertions(+), 0 deletions(-) create mode 100644 package/Makefile.cmake.in
package/Makefile.cmake.in new file +197 -0
@@ -0,0 +1,197 @@ +################################################################################ +# CMake package infrastructure +# +# This file implements an infrastructure that eases development of +# package .mk files for CMake packages. It should be used for all +# packages that use CMake as their build system. +# +# See the Buildroot documentation for details on the usage of this +# infrastructure +# +# In terms of implementation, this CMake infrastructure requires +# the .mk file to only specify metadata informations about the +# package: name, version, download URL, etc. +# +# We still allow the package .mk file to override what the different +# steps are doing, if needed. For example, if <PKG>_BUILD_CMDS is +# already defined, it is used as the list of commands to perform to +# build the package, instead of the default CMake behaviour. The +# package can also define some post operation hooks. +# +################################################################################ + +################################################################################ +# CMAKETARGETS_INNER -- defines how the configuration, compilation and +# installation of a CMake package should be done, implements a few hooks to +# tune the build process and calls the generic package infrastructure to +# generate the necessary make targets +# +# argument 1 is the lowercase package name +# argument 2 is the uppercase package name, including an HOST_ prefix +# for host packages +# argument 3 is the uppercase package name, without the HOST_ prefix +# for host packages +# argument 4 is the package directory prefix +# argument 5 is the type (target or host) +################################################################################ + +define CMAKETARGETS_INNER + +# define package-specific variables to default values +ifndef $(2)_SUBDIR + ifdef $(3)_SUBDIR + $(2)_SUBDIR = $($(3)_SUBDIR) + else + $(2)_SUBDIR ?= + endif +endif + +$(2)_CONF_ENV ?= +$(2)_CONF_OPT ?= +$(2)_MAKE ?= $(MAKE) +$(2)_MAKE_ENV ?= +$(2)_MAKE_OPT ?= +$(2)_INSTALL_HOST_OPT ?= install +$(2)_INSTALL_STAGING_OPT ?= DESTDIR=$$(STAGING_DIR) install +$(2)_INSTALL_TARGET_OPT ?= DESTDIR=$$(TARGET_DIR) install +$(2)_CLEAN_OPT ?= clean + +$(2)_SRCDIR = $$($(2)_DIR)/$($(2)_SUBDIR) +$(2)_BUILDDIR = $$($(2)_SRCDIR) + +# +# Configure step. Only define it if not already defined by the package +# .mk file. And take care of the differences between host and target +# packages. +# +ifndef $(2)_CONFIGURE_CMDS +ifeq ($(5),target) + +# Configure package for target +define $(2)_CONFIGURE_CMDS + (cd $$($$(PKG)_BUILDDIR) && \ + rm -f CMakeCache.txt && \ + $$($$(PKG)_CONF_ENV) $(HOST_DIR)/usr/bin/cmake $$($$(PKG)_SRCDIR) \ + -DCMAKE_TOOLCHAIN_FILE="$$(BASE_DIR)/toolchainfile.cmake" \ + -DCMAKE_INSTALL_PREFIX="/usr" \ + $$($$(PKG)_CONF_OPT) \ + ) +endef +else + +# Configure package for host +define $(2)_CONFIGURE_CMDS + (cd $$($$(PKG)_BUILDDIR) && \ + rm -f CMakeCache.txt && \ + $(HOST_DIR)/usr/bin/cmake $$($$(PKG)_SRCDIR) \ + -DCMAKE_INSTALL_SO_NO_EXE=0 \ + -DCMAKE_FIND_ROOT_PATH="$$(HOST_DIR)" \ + -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM="BOTH" \ + -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY="BOTH" \ + -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE="BOTH" \ + -DCMAKE_INSTALL_PREFIX="$$(HOST_DIR)/usr" \ + $$($$(PKG)_CONF_OPT) \ + ) +endef +endif +endif + +$(2)_DEPENDENCIES += host-cmake + +# +# Build step. Only define it if not already defined by the package .mk +# file. +# +ifndef $(2)_BUILD_CMDS +ifeq ($(5),target) +define $(2)_BUILD_CMDS + $(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPT) -C $$($$(PKG)_BUILDDIR) +endef +else +define $(2)_BUILD_CMDS + $(HOST_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPT) -C $$($$(PKG)_BUILDDIR) +endef +endif +endif + +# +# Host installation step. Only define it if not already defined by the +# package .mk file. +# +ifndef $(2)_INSTALL_CMDS +define $(2)_INSTALL_CMDS + $(HOST_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPT) $$($$(PKG)_INSTALL_HOST_OPT) -C $$($$(PKG)_BUILDDIR) +endef +endif + +# +# Staging installation step. Only define it if not already defined by +# the package .mk file. +# +ifndef $(2)_INSTALL_STAGING_CMDS +define $(2)_INSTALL_STAGING_CMDS + $(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPT) $$($$(PKG)_INSTALL_STAGING_OPT) -C $$($$(PKG)_BUILDDIR) +endef +endif + +# +# Target installation step. Only define it if not already defined by +# the package .mk file. +# +ifndef $(2)_INSTALL_TARGET_CMDS +define $(2)_INSTALL_TARGET_CMDS + $(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPT) $$($$(PKG)_INSTALL_TARGET_OPT) -C $$($$(PKG)_BUILDDIR) +endef +endif + +# +# Clean step. Only define it if not already defined by +# the package .mk file. +# +ifndef $(2)_CLEAN_CMDS +define $(2)_CLEAN_CMDS + -$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPT) $$($$(PKG)_CLEAN_OPT) -C $$($$(PKG)_BUILDDIR) +endef +endif + +# +# Uninstall from staging step. Only define it if not already defined by +# the package .mk file. +# +ifndef $(2)_UNINSTALL_STAGING_CMDS +define $(2)_UNINSTALL_STAGING_CMDS + (cd $$($$(PKG)_BUILDDIR) && sed "s:\(.*\):$$(STAGING_DIR)\1:" install_manifest.txt | xargs rm -f) +endef +endif + +# +# Uninstall from target step. Only define it if not already defined +# by the package .mk file. +# +ifndef $(2)_UNINSTALL_TARGET_CMDS +define $(2)_UNINSTALL_TARGET_CMDS + (cd $$($$(PKG)_BUILDDIR) && sed "s:\(.*\):$$(TARGET_DIR)\1:" install_manifest.txt | xargs rm -f) +endef +endif + +# Call the generic package infrastructure to generate the necessary +# make targets +$(call GENTARGETS_INNER,$(1),$(2),$(3),$(4),$(5)) + +endef + +################################################################################ +# CMAKETARGETS -- the target generator macro for CMake packages +# +# Argument 1 is the package directory prefix [mandatory] +# Argument 2 is the lowercase package name [mandatory] +# Argument 3 is "target" or "host" [optional, default: "target"] +################################################################################ + +define CMAKETARGETS +ifeq ($(3),host) +$(call CMAKETARGETS_INNER,$(3)-$(2),$(call UPPERCASE,$(3)-$(2)),$(call UPPERCASE,$(2)),$(1),host) +else +$(call CMAKETARGETS_INNER,$(2),$(call UPPERCASE,$(2)),$(call UPPERCASE,$(2)),$(1),target) +endif +endef
package/Makefile.in +1 -0
@@ -319,4 +319,5 @@ ENABLE_DEBUG:= endif include package/Makefile.autotools.in +include package/Makefile.cmake.in include package/Makefile.package.in
Signature · 1 line
1.7.1
PATCH v3 3/4 doc: add CMAKETARGETS documentation
In reply to Bjørn Forsman--- docs/buildroot.html | 151 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 147 insertions(+), 4 deletions(-)
docs/buildroot.html +147 -4
@@ -756,6 +756,8 @@ $(ZLIB_DIR)/libz.a: $(ZLIB_DIR)/.configured <li><a href="#generic-reference">Makefile for generic packages : reference</a></li> <li><a href="#autotools-tutorial">Makefile for autotools-based packages : tutorial</a></li> <li><a href="#autotools-reference">Makefile for autotools-based packages : reference</a></li> + <li><a href="#cmake-tutorial">Makefile for CMake-based packages : tutorial</a></li> + <li><a href="#cmake-reference">Makefile for CMake-based packages : reference</a></li> <li><a href="#manual-tutorial">Manual Makefile : tutorial</a></li> </ul> </li>
@@ -1331,13 +1333,154 @@ LIBFOO_POST_PATCH_HOOKS += LIBFOO_POST_PATCH_FIXUP general case.</li> </ul> + <h4 id="cmake-tutorial">Makefile for CMake-based packages : tutorial</h4> + + <p>First, let's see how to write a <code>.mk</code> file for a CMake-based + package, with an example :</p> + +<pre> +<span style="color: #000000">01:</span><span style="font-style: italic; color: #9A1900"> #############################################################</span> +<span style="color: #000000">02:</span><span style="font-style: italic; color: #9A1900"> #</span> +<span style="color: #000000">03:</span><span style="font-style: italic; color: #9A1900"> # libfoo</span> +<span style="color: #000000">04:</span><span style="font-style: italic; color: #9A1900"> #</span> +<span style="color: #000000">05:</span><span style="font-style: italic; color: #9A1900"> #############################################################</span> +<span style="color: #000000">06:</span><span style="color: #009900"> LIBFOO_VERSION</span> = 1.0 +<span style="color: #000000">07:</span><span style="color: #009900"> LIBFOO_SOURCE</span> = libfoo-<span style="color: #009900">$(LIBFOO_VERSION)</span>.tar.gz +<span style="color: #000000">08:</span><span style="color: #009900"> LIBFOO_SITE</span> = http://www.foosoftware.org/download +<span style="color: #000000">09:</span><span style="color: #009900"> LIBFOO_INSTALL_STAGING</span> = YES +<span style="color: #000000">10:</span><span style="color: #009900"> LIBFOO_INSTALL_TARGET</span> = YES +<span style="color: #000000">11:</span><span style="color: #009900"> LIBFOO_CONF_OPT</span> = -DBUILD_DEMOS=ON +<span style="color: #000000">12:</span><span style="color: #009900"> LIBFOO_DEPENDENCIES</span> = libglib2 host-pkg-config +<span style="color: #000000">13:</span> +<span style="color: #000000">14:</span><span style="color: #009900"> $(eval $(call CMAKETARGETS,package,libfoo))</span> +</pre> + + <p>On line 6, we declare the version of the package.</p> + + <p>On line 7 and 8, we declare the name of the tarball and the location + of the tarball on the Web. Buildroot will automatically download the + tarball from this location.</p> + + <p>On line 9, we tell Buildroot to install the package to the staging + directory. The staging directory, located in <code>output/staging/</code> + is the directory where all the packages are installed, including their + development files, etc. By default, packages are not installed to the + staging directory, since usually, only libraries need to be installed in + the staging directory: their development files are needed to compile + other libraries or applications depending on them. Also by default, when + staging installation is enabled, packages are installed in this location + using the <code>make install</code> command.</p> + + <p>On line 10, we tell Buildroot to also install the package to the + target directory. This directory contains what will become the root + filesystem running on the target. Usually, we try not to install header + files and to install stripped versions of the binary. By default, target + installation is enabled, so in fact, this line is not strictly + necessary. Also by default, packages are installed in this location + using the <code>make install</code> command.</p> + + <p>On line 11, we tell Buildroot to pass custom options to CMake when it is + configuring the package.</p> + + <p>On line 12, we declare our dependencies, so that they are built + before the build process of our package starts.</p> + + <p>Finally, on line line 14, we invoke the <code>CMAKETARGETS</code> + macro that generates all the Makefile rules that actually allows the + package to be built.</p> + + <h4 id="cmake-reference">Makefile for CMake packages : reference</h4> + + <p>The main macro of the CMake package infrastructure is + <code>CMAKETARGETS</code>. It has the same number of arguments and the + same semantic as the <code>GENTARGETS</code> macro, which is the main + macro of the generic package infrastructure. For CMake packages, the + ability to have target and host packages is also available.</p> + + <p>Just like the generic infrastructure, the CMake infrastructure + works by defining a number of variables before calling the + <code>CMAKETARGETS</code> macro.</p> + + <p>First, all the package metadata information variables that exist in the + generic infrastructure also exist in the CMake infrastructure: + <code>LIBFOO_VERSION</code>, <code>LIBFOO_SOURCE</code>, + <code>LIBFOO_PATCH</code>, <code>LIBFOO_SITE</code>, + <code>LIBFOO_SUBDIR</code>, <code>LIBFOO_DEPENDENCIES</code>, + <code>LIBFOO_INSTALL_STAGING</code>, <code>LIBFOO_INSTALL_TARGET</code>.</p> + + <p>A few additional variables, specific to the CMake infrastructure, + can also be defined. Many of them are only useful in very specific + cases, typical packages will therefore only use a few of them.</p> + + <ul> + <li><code>LIBFOO_SUBDIR</code> may contain the name of a subdirectory + inside the package that contains the main CMakeLists.txt file. This is + useful, if for example, the main CMakeLists.txt file is not at the root + of the tree extracted by the tarball. If <code>HOST_LIBFOO_SUBDIR</code> + is not specified, it defaults to <code>LIBFOO_SUBDIR</code>.</li> + + <li><code>LIBFOO_CONF_ENV</code>, to specify additional environment + variables to pass to CMake. By default, empty.</li> + + <li><code>LIBFOO_CONF_OPT</code>, to specify additional configure + options to pass to CMake. By default, empty.</li> + + <li><code>LIBFOO_MAKE</code>, to specify an alternate <code>make</code> + command. This is typically useful when parallel make is enabled in + the configuration (using <code>BR2_JLEVEL</code>) but that this + feature should be disabled for the given package, for one reason or + another. By default, set to <code>$(MAKE)</code>. If parallel building + is not supported by the package, then it should be set to + <code>LIBFOO_MAKE=$(MAKE1)</code>.</li> + + <li><code>LIBFOO_MAKE_ENV</code>, to specify additional environment + variables to pass to make in the build step. These are passed before + the <code>make</code> command. By default, empty.</li> + + <li><code>LIBFOO_MAKE_OPT</code>, to specify additional variables to + pass to make in the build step. These are passed after the + <code>make</code> command. By default, empty.</li> + + <li><code>LIBFOO_INSTALL_STAGING_OPT</code> contains the make options + used to install the package to the staging directory. By default, the + value is <code>DESTDIR=$$(STAGING_DIR) install</code>, which is + correct for most CMake packages. It is still possible to override + it.</li> + + <li><code>LIBFOO_INSTALL_TARGET_OPT</code> contains the make options + used to install the package to the target directory. By default, the + value is <code>DESTDIR=$$(TARGET_DIR) install</code>. The default + value is correct for most CMake packages, but it is still possible + to override it if needed.</li> + + <li><code>LIBFOO_CLEAN_OPT</code> contains the make options used to + clean the package. By default, the value is <code>clean</code>.</li> + </ul> + + <p>With the CMake infrastructure, all the steps required to build + and install the packages are already defined, and they generally work + well for most CMake-based packages. However, when required, it is + still possible to customize what is done in any particular step:</p> + + <ul> + <li>By adding a post-operation hook (after extract, patch, configure, + build or install). See the reference documentation of the generic + infrastructure for details.</li> + + <li>By overriding one of the steps. For example, even if the CMake + infrastructure is used, if the package <code>.mk</code> file defines its + own <code>LIBFOO_CONFIGURE_CMDS</code> variable, it will be used + instead of the default CMake one. However, using this method + should be restricted to very specific cases. Do not use it in the + general case.</li> + </ul> + <h4 id ="manual-tutorial">Manual Makefile : tutorial</h4> <p><b>NOTE: new manual makefiles should not be created, and existing - manual makefiles should be converted either to the generic - infrastructure or the autotools infrastructure. This section is only - kept to document the existing manual makefiles and to help understand - how they work.</b></p> + manual makefiles should be converted either to the generic, autotools + or cmake infrastructure. This section is only kept to document the existing + manual makefiles and to help understand how they work.</b></p> <pre> 01: #############################################################
Signature · 1 line
1.7.1
PATCH v3 4/4 cdrkit: convert to CMAKETARGETS infrastructure
In reply to Bjørn Forsman--- package/cdrkit/cdrkit.mk | 66 ++++++--------------------------------------- 1 files changed, 9 insertions(+), 57 deletions(-)
package/cdrkit/cdrkit.mk +9 -57
@@ -11,62 +11,14 @@ else CMAKE_ENDIAN_OPT=-DBITFIELDS_HTOL=0 endif -# CMake doesn't support having the --sysroot option directly in the -# compiler path, so move this option to the CFLAGS/CXXFLAGS variables. -# It also gets confused by ccache, so don't use ccache here. -CDRKIT_TARGET_CC = $(filter-out --sysroot=%,$(TARGET_CC_NOCCACHE)) -CDRKIT_TARGET_CXX = $(filter-out --sysroot=%,$(TARGET_CXX_NOCCACHE)) -CDRKIT_TARGET_CFLAGS = $(filter --sysroot=%,$(TARGET_CC)) $(TARGET_CFLAGS) -CDRKIT_TARGET_CXXFLAGS = $(filter --sysroot=%,$(TARGET_CXX)) $(TARGET_CXXFLAGS) +CDRKIT_CONF_OPT += $(CMAKE_ENDIAN_OPT) -define CDRKIT_CONFIGURE_CMDS - -mkdir $(@D)/build - (cd $(@D)/build ; \ - $(HOST_DIR)/usr/bin/cmake .. \ - -Wno-dev \ - -DCMAKE_SYSTEM_NAME:STRING="Linux" \ - -DCMAKE_C_COMPILER:FILEPATH="$(CDRKIT_TARGET_CC)" \ - -DCMAKE_CXX_COMPILER:FILEPATH="$(CDRKIT_TARGET_CXX)" \ - -DCMAKE_C_FLAGS:STRING="$(CDRKIT_TARGET_CFLAGS)" \ - -DCMAKE_CXX_FLAGS:STRING="$(CDRKIT_TARGET_CXXFLAGS)" \ - -DCMAKE_EXE_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS)" \ - -DCMAKE_MODULE_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS)" \ - -DCMAKE_SHARED_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS)" \ - -DCMAKE_FIND_ROOT_PATH:PATH="$(STAGING_DIR)" \ - -DCMAKE_INSTALL_PREFIX:PATH="$(TARGET_DIR)/usr" \ - $(CMAKE_ENDIAN_OPT) \ - ) -endef - -define CDRKIT_BUILD_CMDS - $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/build -endef - -define CDRKIT_INSTALL_TARGET_CMDS - $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/build install -endef - -define HOST_CDRKIT_CONFIGURE_CMDS - -mkdir $(@D)/build - (cd $(@D)/build ; \ - $(HOST_DIR)/usr/bin/cmake .. \ - -Wno-dev \ - -DCMAKE_C_FLAGS="$(HOST_CFLAGS)" \ - -DCMAKE_EXE_LINKER_FLAGS:STRING="$(HOST_LDFLAGS)" \ - -DCMAKE_MODULE_LINKER_FLAGS:STRING="$(HOST_LDFLAGS)" \ - -DCMAKE_SHARED_LINKER_FLAGS:STRING="$(HOST_LDFLAGS)" \ - -DCMAKE_INSTALL_PREFIX:STRING="$(HOST_DIR)/usr" \ - ) -endef - -define HOST_CDRKIT_BUILD_CMDS - $(HOST_MAKE_ENV) $(MAKE) -C $(@D)/build -endef - -define HOST_CDRKIT_INSTALL_CMDS - $(HOST_MAKE_ENV) $(MAKE) -C $(@D)/build install -endef - -$(eval $(call GENTARGETS,package,cdrkit)) -$(eval $(call GENTARGETS,package,cdrkit,host)) +## cdrkit isn't completely re-rooted by CMAKE_FIND_ROOT_PATH, so add +## some extra flags so it finds needed libs and headers. +CDRKIT_CONF_OPT += -DCMAKE_C_FLAGS="-I$(STAGING_DIR)/usr/include" +CDRKIT_CONF_OPT += -DCMAKE_EXE_LINKER_FLAGS="$(TARGET_LDFLAGS)" +HOST_CDRKIT_CONF_OPT += -DCMAKE_C_FLAGS="-I$(HOST_DIR)/usr/include" +HOST_CDRKIT_CONF_OPT += -DCMAKE_EXE_LINKER_FLAGS="$(HOST_LDFLAGS)" +$(eval $(call CMAKETARGETS,package,cdrkit)) +$(eval $(call CMAKETARGETS,package,cdrkit,host))
Signature · 1 line
1.7.1
v3 cover Introducing CMAKETARGETS infrastructure
In reply to Bjørn ForsmanQuoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Bj?rn" == Bj?rn Forsman <[email protected]> writes:
Bj?rn> This patch series adds a new infrastructure for CMake packages called Bj?rn> CMAKETARGETS. It is based on the AUTOTARGETS infrastructure.
Bj?rn> Changes in v3:
Committed, thanks!
Signature · 1 line
Bye, Peter Korsgaard