0003-CMake-fix-object-library-usage.patch 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. From 17539ae9d09ded695167911f9e3ec0cf4bc9fed9 Mon Sep 17 00:00:00 2001
  2. From: Yegor Yefremov <yegorslists@googlemail.com>
  3. Date: Wed, 5 Feb 2020 12:28:44 +0100
  4. Subject: [PATCH] CMake: fix object library usage
  5. Object libraries cannot be use in target_link_libraries() command
  6. as they are no normal binary files like *.a or *.so but a collection
  7. of object files.
  8. See add_library() definition for details.
  9. Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
  10. [Rebased for for ninja-1.10.2]
  11. Signed-off-by: Peter Seiderer <ps.report@gmx.net>
  12. ---
  13. CMakeLists.txt | 9 ++++-----
  14. 1 file changed, 4 insertions(+), 5 deletions(-)
  15. diff --git a/CMakeLists.txt b/CMakeLists.txt
  16. index 4b61479..3701f3a 100644
  17. --- a/CMakeLists.txt
  18. +++ b/CMakeLists.txt
  19. @@ -132,8 +132,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "OS400" OR CMAKE_SYSTEM_NAME STREQUAL "AIX")
  20. endif()
  21. # Main executable is library plus main() function.
  22. -add_executable(ninja src/ninja.cc)
  23. -target_link_libraries(ninja PRIVATE libninja libninja-re2c)
  24. +add_executable(ninja src/ninja.cc $<TARGET_OBJECTS:libninja> $<TARGET_OBJECTS:libninja-re2c>)
  25. # Adds browse mode into the ninja binary if it's supported by the host platform.
  26. if(platform_supports_ninja_browse)
  27. @@ -183,11 +182,12 @@ if(BUILD_TESTING)
  28. src/subprocess_test.cc
  29. src/test.cc
  30. src/util_test.cc
  31. + $<TARGET_OBJECTS:libninja>
  32. + $<TARGET_OBJECTS:libninja-re2c>
  33. )
  34. if(WIN32)
  35. target_sources(ninja_test PRIVATE src/includes_normalize_test.cc src/msvc_helper_test.cc)
  36. endif()
  37. - target_link_libraries(ninja_test PRIVATE libninja libninja-re2c)
  38. foreach(perftest
  39. build_log_perftest
  40. @@ -197,8 +197,7 @@ if(BUILD_TESTING)
  41. hash_collision_bench
  42. manifest_parser_perftest
  43. )
  44. - add_executable(${perftest} src/${perftest}.cc)
  45. - target_link_libraries(${perftest} PRIVATE libninja libninja-re2c)
  46. + add_executable(${perftest} src/${perftest}.cc $<TARGET_OBJECTS:libninja> $<TARGET_OBJECTS:libninja-re2c>)
  47. endforeach()
  48. if(CMAKE_SYSTEM_NAME STREQUAL "AIX" AND CMAKE_SIZEOF_VOID_P EQUAL 4)
  49. --
  50. 2.29.2