0004-cmake-fix-compilation-of-clar-based-unit-tests.patch 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. From beb7761f4fbc6b71ec6357d56575f57fd2b4c8a9 Mon Sep 17 00:00:00 2001
  2. From: Patrick Steinhardt <ps@pks.im>
  3. Date: Mon, 21 Oct 2024 12:56:41 +0200
  4. Subject: [PATCH] cmake: fix compilation of clar-based unit tests
  5. The compilation of clar-based unit tests is broken because we do not
  6. add the binary directory into which we generate the "clar-decls.h" and
  7. "clar.suite" files as include directories. Instead, we accidentally set
  8. up the source directory as include directory.
  9. Fix this by including the binary directory instead of the source
  10. directory. Furthermore, set up the include directories as PUBLIC instead
  11. of PRIVATE such that they propagate from "unit-tests.lib" to the
  12. "unit-tests" executable, which needs to include the same directory.
  13. Reported-by: Ed Reel <edreel@gmail.com>
  14. Signed-off-by: Patrick Steinhardt <ps@pks.im>
  15. Upstream: https://lore.kernel.org/r/a30017a4d8998e85915d959c16f181a8d4e813f2.1729506329.git.ps@pks.im
  16. Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
  17. ---
  18. contrib/buildsystems/CMakeLists.txt | 2 +-
  19. 1 file changed, 1 insertion(+), 1 deletion(-)
  20. diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
  21. index 62af7b33d2..093852ad9d 100644
  22. --- a/contrib/buildsystems/CMakeLists.txt
  23. +++ b/contrib/buildsystems/CMakeLists.txt
  24. @@ -1042,7 +1042,7 @@ file(WRITE "${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite" "${clar_decls}" "${clar
  25. list(TRANSFORM clar_test_SUITES PREPEND "${CMAKE_SOURCE_DIR}/t/unit-tests/")
  26. list(TRANSFORM clar_test_SUITES APPEND ".c")
  27. add_library(unit-tests-lib ${clar_test_SUITES} "${CMAKE_SOURCE_DIR}/t/unit-tests/clar/clar.c")
  28. -target_include_directories(unit-tests-lib PRIVATE "${CMAKE_SOURCE_DIR}/t/unit-tests")
  29. +target_include_directories(unit-tests-lib PUBLIC "${CMAKE_BINARY_DIR}/t/unit-tests")
  30. add_executable(unit-tests "${CMAKE_SOURCE_DIR}/t/unit-tests/unit-test.c")
  31. target_link_libraries(unit-tests unit-tests-lib common-main)
  32. set_target_properties(unit-tests
  33. --
  34. An old man doll... just what I always wanted! - Clara