git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 4/5] cmake: fix compilation of clar-based unit tests

From
Patrick Steinhardt <ps@pks.im>
Date
Oct 21, 2024, 10:56 UTC
Message-ID
<a30017a4d8998e85915d959c16f181a8d4e813f2.1729506329.git.ps@pks.im>
In-Reply-To
<cover.1729506329.git.ps@pks.im>

The compilation of clar-based unit tests is broken because we do not add the binary directory into which we generate the "clar-decls.h" and "clar.suite" files as include directories. Instead, we accidentally set up the source directory as include directory.

Fix this by including the binary directory instead of the source directory. Furthermore, set up the include directories as PUBLIC instead of PRIVATE such that they propagate from "unit-tests.lib" to the "unit-tests" executable, which needs to include the same directory.

Reported-by: Ed Reel <edreel@gmail.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 contrib/buildsystems/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 62af7b33d2f..093852ad9d6 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -1042,7 +1042,7 @@ file(WRITE "${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite" "${clar_decls}" "${clar
 list(TRANSFORM clar_test_SUITES PREPEND "${CMAKE_SOURCE_DIR}/t/unit-tests/")
 list(TRANSFORM clar_test_SUITES APPEND ".c")
 add_library(unit-tests-lib ${clar_test_SUITES} "${CMAKE_SOURCE_DIR}/t/unit-tests/clar/clar.c")
-target_include_directories(unit-tests-lib PRIVATE "${CMAKE_SOURCE_DIR}/t/unit-tests")
+target_include_directories(unit-tests-lib PUBLIC "${CMAKE_BINARY_DIR}/t/unit-tests")
 add_executable(unit-tests "${CMAKE_SOURCE_DIR}/t/unit-tests/unit-test.c")
 target_link_libraries(unit-tests unit-tests-lib common-main)
 set_target_properties(unit-tests
-- 
2.47.0.72.gef8ce8f3d4.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 21 of 30 in “git no longer builds on SunOS 5.10, a report”
  1. Alejandro R. SedeñoOct 12, 2024
  2. Patrick SteinhardtOct 12, 2024
  3. Alejandro R. SedeñoOct 12, 2024
  4. Makefile: adjust sed command for generating "clar-decls.h"Alejandro R. Sedeño, Oct 12, 2024
  5. Alejandro R. SedeñoOct 12, 2024
  6. Patrick SteinhardtOct 13, 2024
  7. Alejandro R. SedeñoOct 13, 2024
  8. Patrick SteinhardtOct 14, 2024
  9. 0/2 t/unit-tests: improve clar platform compatibilityPatrick Steinhardt, Oct 14, 2024
  10. 1/2 t/unit-tests: update clar to 0810a36Patrick Steinhardt, Oct 14, 2024
  11. 2/2 Makefile: adjust sed command for generating "clar-decls.h"Patrick Steinhardt, Oct 14, 2024
  12. Toon ClaesOct 18, 2024
  13. Taylor BlauOct 18, 2024
  14. Patrick SteinhardtOct 21, 2024
  15. 0/5 t/unit-tests: improve clar platform compatibilityPatrick Steinhardt, Oct 21, 2024
  16. 1/5 t/unit-tests: update clar to 206accbPatrick Steinhardt, Oct 21, 2024
  17. 2/5 Makefile: adjust sed command for generating "clar-decls.h"Patrick Steinhardt, Oct 21, 2024
  18. Kristoffer HaugsbakkOct 21, 2024
  19. Patrick SteinhardtOct 21, 2024
  20. 3/5 Makefile: extract script to generate clar declarationsPatrick Steinhardt, Oct 21, 2024
  21. 4/5 cmake: fix compilation of clar-based unit testsPatrick Steinhardt, Oct 21, 2024
  22. 5/5 cmake: set up proper dependencies for generated clar headersPatrick Steinhardt, Oct 21, 2024
  23. Johannes SchindelinNov 5, 2024
  24. Phillip WoodNov 6, 2024
  25. Patrick SteinhardtNov 8, 2024
  26. Taylor BlauOct 21, 2024
  27. karthik nayakOct 25, 2024
  28. Bagas SanjayaOct 26, 2024
  29. Patrick SteinhardtOct 27, 2024
  30. Taylor BlauOct 27, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.