Re: [PATCH 3/3] cmake: set up proper dependencies for generated clar headers
- From
Taylor Blau <me@ttaylorr.com>
- Date
- Oct 14, 2024, 21:47 UTC
- Message-ID
- <Zw2RaUNoQz+OTcKZ@nand.local>
- In-Reply-To
- <129d28ae48ad984e9fae8bf803ae50a390b15a46.1728914219.git.ps@pks.im>
On Mon, Oct 14, 2024 at 04:06:47PM +0200, Patrick Steinhardt wrote:
> The auto-generated headers used by clar are written at configure time > and thus do not get regenerated automatically. Refactor the build > recipes such that we use custom commands instead, which also has the > benefit that we can reuse the same infrastructure as our Makefile.
OK.
Show 15 quoted lines
> +add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h"
> + COMMAND ${CMAKE_SOURCE_DIR}/t/unit-tests/generate-clar-decls.sh "${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h" ${clar_test_SUITES}
> + DEPENDS ${CMAKE_SOURCE_DIR}/t/unit-tests/generate-clar-decls.sh ${clar_test_SUITES})
> +add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite"
> + COMMAND awk -f "${CMAKE_SOURCE_DIR}/t/unit-tests/clar-generate.awk" "${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h" > "${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite"
> + DEPENDS "${CMAKE_SOURCE_DIR}/t/unit-tests/clar-generate.awk" "${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h")
> +
> +add_library(unit-tests-lib ${clar_test_SUITES}
> + "${CMAKE_SOURCE_DIR}/t/unit-tests/clar/clar.c"
> + "${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h"
> + "${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite"
> +)
> 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)Ahh. The post-image is a definite improvement ;-).
Thanks, Taylor