CMake cleanup
v2 cover CMake cleanup
Hi all,
Quick respin of this series cleaning up the {host-,}cmake-package infrastructure (more specifically how the {C,CXX,LD}FLAGS are handled) and fix the bug #7280.
For this round, I have discarded the 6th patch which is an RFC. The only others changes are typo fixes in the commit message of the patch 5/5
Cheers,
Samuel Martin (5):
package/pkg-cmake.mk: remove the USE_CCACHE CMake flag for
host-package
package/pkg-cmake.mk: set the {C,CXX,LD}FLAGS for host packages toolchainfile.cmake.in: set linker flags
package/cdrkit: clean {HOST_,}CDRKIT_CONF_OPT toolchainfile.cmake.in: do not force the CMAKE_{C,CXX}_FLAGS to the
cache
package/cdrkit/cdrkit.mk | 7 ------- package/pkg-cmake.mk | 5 ++++- support/misc/toolchainfile.cmake.in | 5 +++-- 3 files changed, 7 insertions(+), 10 deletions(-)
--
2.1.0
PATCH v2 1/5 package/pkg-cmake.mk: remove the USE_CCACHE CMake flag for host-package
The USE_CCACHE CMake flag is only useful when building target package (only the toolchainfile.cmake uses it).
---
changes v1 -> v2:
- no change
--- package/pkg-cmake.mk | 1 - 1 file changed, 1 deletion(-)
package/pkg-cmake.mk +0 -1
@@ -86,7 +86,6 @@ define $(2)_CONFIGURE_CMDS -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY="BOTH" \ -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE="BOTH" \ -DCMAKE_INSTALL_PREFIX="$$(HOST_DIR)/usr" \ - -DUSE_CCACHE=$$(if $$(BR2_CCACHE),ON,OFF) \ -DBUILD_TESTING=OFF \ $$($$(PKG)_CONF_OPT) \ )
Signature · 1 line
2.1.0
PATCH v2 1/5 package/pkg-cmake.mk: remove the USE_CCACHE CMake flag for host-package
Samuel, All,
On 2014-08-21 22:45 +0200, Samuel Martin spake thusly:
Quoted 4 lines
The
USE_CCACHECMake flag is only useful when building target package (only the toolchainfile.cmake uses it).Signed-off-by Samuel Martin <[email protected]>
Regards,
Yann E. MORIN.
Quoted 26 lines
---
changes v1 -> v2:
- no change--- package/pkg-cmake.mk | 1 - 1 file changed, 1 deletion(-)package/pkg-cmake.mk +0
-1@@ -86,7 +86,6 @@ define $(2)_CONFIGURE_CMDS -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY="BOTH" \ -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE="BOTH" \ -DCMAKE_INSTALL_PREFIX="$$(HOST_DIR)/usr" \ - -DUSE_CCACHE=$$(if $$(BR2_CCACHE),ON,OFF) \ -DBUILD_TESTING=OFF \ $$($$(PKG)_CONF_OPT) \ )Signature · 6 lines
2.1.0 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH v2 1/5 package/pkg-cmake.mk: remove the USE_CCACHE CMake flag for host-package
In reply to Samuel MartinQuoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Samuel" == Samuel Martin <[email protected]> writes:
The
USE_CCACHECMake flag is only useful when building target package (only the toolchainfile.cmake uses it).Signed-off-by Samuel Martin <[email protected]>
Committed, thanks.
Signature · 1 line
Bye, Peter Korsgaard
PATCH v2 2/5 package/pkg-cmake.mk: set the {C, CXX, LD}FLAGS for host packages
In reply to Samuel Martin---
changes v1 -> v2:
- no change
--- package/pkg-cmake.mk | 3 +++ 1 file changed, 3 insertions(+)
package/pkg-cmake.mk +3 -0
@@ -86,6 +86,9 @@ define $(2)_CONFIGURE_CMDS -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY="BOTH" \ -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE="BOTH" \ -DCMAKE_INSTALL_PREFIX="$$(HOST_DIR)/usr" \ + -DCMAKE_C_FLAGS="$$(HOST_CFLAGS)" \ + -DCMAKE_CXX_FLAGS="$$(HOST_CXXFLAGS)" \ + -DCMAKE_EXE_LINKER_FLAGS="$$(HOST_LDFLAGS)" \ -DBUILD_TESTING=OFF \ $$($$(PKG)_CONF_OPT) \ )
Signature · 1 line
2.1.0
PATCH v2 2/5 package/pkg-cmake.mk: set the {C, CXX, LD}FLAGS for host packages
Samuel, All,
On 2014-08-21 22:45 +0200, Samuel Martin spake thusly:
Quoted 1 line
Signed-off-by Samuel Martin <[email protected]>
As I am not a cmake expert, I'd like a bit more explanations in the commit log.
What puzzles me is that, for the target case, these flags are passed via support/misc/toolchainfile.cmake.in, while for the host, we pass them on the command line. This is not consistent.
Why don't we also use a host.cmake.in file like we have for the target?
Note that us having support/misc/toolchainfile.cmake.in does not even help for building a cmake package outside of Buildroot (but still using our toolchain), since the user may forget to define CMAKE_TOOLCHAIN_FILE when calling cmake on his own.
Note: I know you have a good answer, but I'm a bit lost as to all those special-casing in cmake, which makes reviewing a bit difficult, and a bit of comments in the commit log (a pointer to the cmake doc would be enough!) would make it easier.
Regards,
Yann E. MORIN.
Quoted 28 lines
---
changes v1 -> v2:
- no change--- package/pkg-cmake.mk | 3 +++ 1 file changed, 3 insertions(+)package/pkg-cmake.mk +3
-0@@ -86,6 +86,9 @@ define $(2)_CONFIGURE_CMDS -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY="BOTH" \ -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE="BOTH" \ -DCMAKE_INSTALL_PREFIX="$$(HOST_DIR)/usr" \ + -DCMAKE_C_FLAGS="$$(HOST_CFLAGS)" \ + -DCMAKE_CXX_FLAGS="$$(HOST_CXXFLAGS)" \ + -DCMAKE_EXE_LINKER_FLAGS="$$(HOST_LDFLAGS)" \ -DBUILD_TESTING=OFF \ $$($$(PKG)_CONF_OPT) \ )Signature · 6 lines
2.1.0 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH v2 2/5 package/pkg-cmake.mk: set the {C, CXX, LD}FLAGS for host packages
In reply to Samuel MartinQuoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Samuel" == Samuel Martin <[email protected]> writes:
Signed-off-by Samuel Martin <[email protected]>
Committed, thanks.
I do agree with Yann though that it would be good if the commit messages were more detailed. Why do we use a toolchain files for target, but not for host?
Signature · 1 line
Bye, Peter Korsgaard
PATCH v2 3/5 toolchainfile.cmake.in: set linker flags
In reply to Samuel MartinThe linker flags are part of the toolchain configuration, so set them for the CMake-based packages.
---
changes v1 -> v2:
- no change
--- package/pkg-cmake.mk | 1 + support/misc/toolchainfile.cmake.in | 1 + 2 files changed, 2 insertions(+)
package/pkg-cmake.mk +1 -0
@@ -177,6 +177,7 @@ $(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake: -e 's:@@STAGING_SUBDIR@@:$(call qstrip,$(STAGING_SUBDIR)):' \ -e 's:@@TARGET_CFLAGS@@:$(call qstrip,$(TARGET_CFLAGS)):' \ -e 's:@@TARGET_CXXFLAGS@@:$(call qstrip,$(TARGET_CXXFLAGS)):' \ + -e 's:@@TARGET_LDFLAGS@@:$(call qstrip,$(TARGET_LDFLAGS)):' \ -e 's:@@TARGET_CC_NOCCACHE@@:$(subst $(HOST_DIR)/,,$(call qstrip,$(TARGET_CC_NOCCACHE))):' \ -e 's:@@TARGET_CXX_NOCCACHE@@:$(subst $(HOST_DIR)/,,$(call qstrip,$(TARGET_CXX_NOCCACHE))):' \ $(TOPDIR)/support/misc/toolchainfile.cmake.in \
support/misc/toolchainfile.cmake.in +1 -0
@@ -14,6 +14,7 @@ set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_C_FLAGS "@@TARGET_CFLAGS@@ ${CMAKE_C_FLAGS}" CACHE STRING "Buildroot CFLAGS" FORCE) set(CMAKE_CXX_FLAGS "@@TARGET_CXXFLAGS@@ ${CMAKE_CXX_FLAGS}" CACHE STRING "Buildroot CXXFLAGS" FORCE) +set(CMAKE_EXE_LINKER_FLAGS "@@TARGET_LDFLAGS@@ ${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "Buildroot LDFLAGS") set(CMAKE_INSTALL_SO_NO_EXE 0) set(CMAKE_PROGRAM_PATH "${RELOCATED_HOST_DIR}/usr/bin")
Signature · 1 line
2.1.0
PATCH v2 3/5 toolchainfile.cmake.in: set linker flags
Samuel, All,
On 2014-08-21 22:45 +0200, Samuel Martin spake thusly:
Quoted 4 lines
The linker flags are part of the toolchain configuration, so set them for the CMake-based packages.
Signed-off-by Samuel Martin <[email protected]>
This patch does not add the FORCE option, like for CFLAGS and CXXFLAGS, which make it a bit incoherent. But since we're removing in the following patch, that's OK.
Regards,
Yann E. MORIN.
Quoted 39 lines
---
changes v1 -> v2:
- no change--- package/pkg-cmake.mk | 1 + support/misc/toolchainfile.cmake.in | 1 + 2 files changed, 2 insertions(+)package/pkg-cmake.mk +1
-0@@ -177,6 +177,7 @@ $(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake: -e 's:@@STAGING_SUBDIR@@:$(call qstrip,$(STAGING_SUBDIR)):' \ -e 's:@@TARGET_CFLAGS@@:$(call qstrip,$(TARGET_CFLAGS)):' \ -e 's:@@TARGET_CXXFLAGS@@:$(call qstrip,$(TARGET_CXXFLAGS)):' \ + -e 's:@@TARGET_LDFLAGS@@:$(call qstrip,$(TARGET_LDFLAGS)):' \ -e 's:@@TARGET_CC_NOCCACHE@@:$(subst $(HOST_DIR)/,,$(call qstrip,$(TARGET_CC_NOCCACHE))):' \ -e 's:@@TARGET_CXX_NOCCACHE@@:$(subst $(HOST_DIR)/,,$(call qstrip,$(TARGET_CXX_NOCCACHE))):' \ $(TOPDIR)/support/misc/toolchainfile.cmake.in \support/misc/toolchainfile.cmake.in +1
-0@@ -14,6 +14,7 @@ set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_C_FLAGS "@@TARGET_CFLAGS@@ ${CMAKE_C_FLAGS}" CACHE STRING "Buildroot CFLAGS" FORCE) set(CMAKE_CXX_FLAGS "@@TARGET_CXXFLAGS@@ ${CMAKE_CXX_FLAGS}" CACHE STRING "Buildroot CXXFLAGS" FORCE) +set(CMAKE_EXE_LINKER_FLAGS "@@TARGET_LDFLAGS@@ ${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "Buildroot LDFLAGS") set(CMAKE_INSTALL_SO_NO_EXE 0) set(CMAKE_PROGRAM_PATH "${RELOCATED_HOST_DIR}/usr/bin")Signature · 6 lines
2.1.0 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH v2 3/5 toolchainfile.cmake.in: set linker flags
In reply to Samuel MartinQuoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Samuel" == Samuel Martin <[email protected]> writes:
The linker flags are part of the toolchain configuration, so set them for the CMake-based packages.
Signed-off-by Samuel Martin <[email protected]>
Committed, thanks.
Signature · 1 line
Bye, Peter Korsgaard
PATCH v2 4/5 package/cdrkit: clean {HOST_, }CDRKIT_CONF_OPT
In reply to Samuel MartinExtending {C,LD}FLAGS for both host and target cdrkit package is not needed because it is already handled by the {host-,}cmake-package infrastructure.
---
changes v1 -> v2:
- no change
--- package/cdrkit/cdrkit.mk | 7 ------- 1 file changed, 7 deletions(-)
package/cdrkit/cdrkit.mk +0 -7
@@ -18,12 +18,5 @@ endif CDRKIT_CONF_OPT += $(CMAKE_ENDIAN_OPT) -## 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 $(cmake-package)) $(eval $(host-cmake-package))
Signature · 1 line
2.1.0
PATCH v2 4/5 package/cdrkit: clean {HOST_, }CDRKIT_CONF_OPT
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Samuel" == Samuel Martin <[email protected]> writes:
Extending {C,LD}FLAGS for both host and target cdrkit package is not needed because it is already handled by the {host-,}cmake-package infrastructure.
Signed-off-by Samuel Martin <[email protected]>
No longer applied, but I've fixed it up and committed, thanks.
Signature · 1 line
Bye, Peter Korsgaard
PATCH v2 5/5 toolchainfile.cmake.in: do not force the CMAKE_{C, CXX}_FLAGS to the cache
In reply to Samuel MartinFix #7280 [1]
When the FORCE option is passed to the set command, the variable is added/updated in the CMake cache every single time CMake processes this command.
Because the toolchainfile.cmake prepends architecture/toolchain flags to the CMAKE_{C,CXX}_FLAGS, this makes the CFLAGS being updated in the generated Makefiles each time one reconfigures its project. So it forces the compilation of everything, even when nothing has changed.
[1] https://bugs.busybox.net/show_bug.cgi?id=7280
(tested the SimpleApp reproduction scenario described in the bug report)
---
changes v1 -> v2:
- fix typoes in commit log (ThomasDS)
- update A/R/T tags
--- support/misc/toolchainfile.cmake.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
support/misc/toolchainfile.cmake.in +2 -2
@@ -12,8 +12,8 @@ string(REPLACE "/usr/share/buildroot" "" RELOCATED_HOST_DIR ${CMAKE_CURRENT_LIST set(CMAKE_SYSTEM_NAME Linux) -set(CMAKE_C_FLAGS "@@TARGET_CFLAGS@@ ${CMAKE_C_FLAGS}" CACHE STRING "Buildroot CFLAGS" FORCE) -set(CMAKE_CXX_FLAGS "@@TARGET_CXXFLAGS@@ ${CMAKE_CXX_FLAGS}" CACHE STRING "Buildroot CXXFLAGS" FORCE) +set(CMAKE_C_FLAGS "@@TARGET_CFLAGS@@ ${CMAKE_C_FLAGS}" CACHE STRING "Buildroot CFLAGS") +set(CMAKE_CXX_FLAGS "@@TARGET_CXXFLAGS@@ ${CMAKE_CXX_FLAGS}" CACHE STRING "Buildroot CXXFLAGS") set(CMAKE_EXE_LINKER_FLAGS "@@TARGET_LDFLAGS@@ ${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "Buildroot LDFLAGS") set(CMAKE_INSTALL_SO_NO_EXE 0)
Signature · 1 line
2.1.0
PATCH v2 5/5 toolchainfile.cmake.in: do not force the CMAKE_{C, CXX}_FLAGS to the cache
Quoted 12 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Samuel" == Samuel Martin <[email protected]> writes:
Fix #7280 [1]
When the FORCE option is passed to the set command, the variable is added/updated in the CMake cache every single time CMake processes this command.Because the toolchainfile.cmake prepends architecture/toolchain flags to the CMAKE_{C,CXX}_FLAGS, this makes the CFLAGS being updated in the generated Makefiles each time one reconfigures its project. So it forces the compilation of everything, even when nothing has changed.
Quoted 5 lines
[1] https://bugs.busybox.net/show_bug.cgi?id=7280
Signed-off-by Samuel Martin <[email protected]>(tested the SimpleApp reproduction scenario described in the bug report)
Committed, thanks.
Signature · 1 line
Bye, Peter Korsgaard