buildroot.busybox.net archive mirror
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v2] package/ninja: fix build for cmake 3.10
@ 2020-02-06 13:21 yegorslists at googlemail.com
  2020-02-07 14:59 ` Peter Korsgaard
  0 siblings, 1 reply; 2+ messages in thread
From: yegorslists at googlemail.com @ 2020-02-06 13:21 UTC (permalink / raw)
  To: buildroot

From: Yegor Yefremov <yegorslists@googlemail.com>

If the host cmake is 3.10, the configuration step produces
the following error:

CMake Error at CMakeLists.txt:87 (target_link_libraries):
Target "libninja" of type OBJECT_LIBRARY may not be linked into another
target. One may link only to STATIC or SHARED libraries, or to executables
with the ENABLE_EXPORTS property set.

This patch fixes CMakeLists.txt to use the object library as it was intended
in cmake 3.10.

Fixes:
https://bugs.busybox.net/show_bug.cgi?id=12546

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Tested-by: Damian Tometzki <dti@familie-tometzki.de>
---
Changes v1 -> v2:
    - add Tested-by tag from Damian
    - mention bug report

 .../0003-CMake-fix-object-library-usage.patch | 56 +++++++++++++++++++
 1 file changed, 56 insertions(+)
 create mode 100644 package/ninja/0003-CMake-fix-object-library-usage.patch

diff --git a/package/ninja/0003-CMake-fix-object-library-usage.patch b/package/ninja/0003-CMake-fix-object-library-usage.patch
new file mode 100644
index 0000000000..af69837c08
--- /dev/null
+++ b/package/ninja/0003-CMake-fix-object-library-usage.patch
@@ -0,0 +1,56 @@
+From 7982ecebe1c1c41e82779a65fa2d93f19ffd755f Mon Sep 17 00:00:00 2001
+From: Yegor Yefremov <yegorslists@googlemail.com>
+Date: Wed, 5 Feb 2020 12:28:44 +0100
+Subject: [PATCH 3/3] CMake: fix object library usage
+
+Object libraries cannot be use in target_link_libraries() command
+as they are no normal binary files like *.a or *.so but a collection
+of object files.
+
+See add_library() definition for details.
+
+Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
+---
+ CMakeLists.txt | 9 ++++-----
+ 1 file changed, 4 insertions(+), 5 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index af8010f..028a7bb 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -83,8 +83,7 @@ target_compile_definitions(libninja PRIVATE _WIN32_WINNT=0x0601 __USE_MINGW_ANSI
+ endif()
+
+ # Main executable is library plus main() function.
+-add_executable(ninja src/ninja.cc)
+-target_link_libraries(ninja PRIVATE libninja libninja-re2c)
++add_executable(ninja src/ninja.cc $<TARGET_OBJECTS:libninja> $<TARGET_OBJECTS:libninja-re2c>)
+
+ # Tests all build into ninja_test executable.
+ add_executable(ninja_test
+@@ -106,11 +105,12 @@ add_executable(ninja_test
+	src/subprocess_test.cc
+	src/test.cc
+	src/util_test.cc
++	$<TARGET_OBJECTS:libninja>
++	$<TARGET_OBJECTS:libninja-re2c>
+ )
+ if(WIN32)
+	target_sources(ninja_test PRIVATE src/includes_normalize_test.cc src/msvc_helper_test.cc)
+ endif()
+-target_link_libraries(ninja_test PRIVATE libninja libninja-re2c)
+
+ foreach(perftest
+   build_log_perftest
+@@ -120,8 +120,7 @@ foreach(perftest
+   hash_collision_bench
+   manifest_parser_perftest
+ )
+-  add_executable(${perftest} src/${perftest}.cc)
+-  target_link_libraries(${perftest} PRIVATE libninja libninja-re2c)
++  add_executable(${perftest} src/${perftest}.cc $<TARGET_OBJECTS:libninja> $<TARGET_OBJECTS:libninja-re2c>)
+ endforeach()
+
+ enable_testing()
+--
+2.17.0
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [Buildroot] [PATCH v2] package/ninja: fix build for cmake 3.10
  2020-02-06 13:21 [Buildroot] [PATCH v2] package/ninja: fix build for cmake 3.10 yegorslists at googlemail.com
@ 2020-02-07 14:59 ` Peter Korsgaard
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Korsgaard @ 2020-02-07 14:59 UTC (permalink / raw)
  To: buildroot

>>>>> "yegorslists" == yegorslists  <yegorslists@googlemail.com> writes:

 > From: Yegor Yefremov <yegorslists@googlemail.com>
 > If the host cmake is 3.10, the configuration step produces
 > the following error:

 > CMake Error at CMakeLists.txt:87 (target_link_libraries):
 > Target "libninja" of type OBJECT_LIBRARY may not be linked into another
 > target. One may link only to STATIC or SHARED libraries, or to executables
 > with the ENABLE_EXPORTS property set.

 > This patch fixes CMakeLists.txt to use the object library as it was intended
 > in cmake 3.10.

 > Fixes:
 > https://bugs.busybox.net/show_bug.cgi?id=12546

 > Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
 > Tested-by: Damian Tometzki <dti@familie-tometzki.de>
 > ---
 > Changes v1 -> v2:
 >     - add Tested-by tag from Damian
 >     - mention bug report

Please use the -N option when generating patches from git (here and the
libftdi1 patch) - check-package complains:

Applying: package/ninja: fix build for cmake 3.10
package/ninja/0003-CMake-fix-object-library-usage.patch:4: generate your patches with 'git format-patch -N'

Committed with that fixed, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-02-07 14:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-06 13:21 [Buildroot] [PATCH v2] package/ninja: fix build for cmake 3.10 yegorslists at googlemail.com
2020-02-07 14:59 ` Peter Korsgaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).