git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cmake: accommodate for `UNIT_TEST_SOURCES`
@ 2025-08-03 21:24 Johannes Schindelin via GitGitGadget
  2025-08-16 17:09 ` Johannes Schindelin
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2025-08-03 21:24 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Johannes Schindelin

From: Johannes Schindelin <johannes.schindelin@gmx.de>

As part of 9bbc981c6f2 (t/unit-tests: finalize migration of
reftable-related tests, 2025-07-24), the explicit list of
`UNIT_TEST_PROGRAMS` was turned into a wildcard pattern-derived list.

Let's do the same in the CMake definition.

This fixes build errors with symptoms like this:

  CMake Error at CMakeLists.txt:132 (string):
    string sub-command REPLACE requires at least four arguments.
  Call Stack (most recent call first):
    CMakeLists.txt:1037 (parse_makefile_for_scripts)

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
    cmake: accommodate for UNIT_TEST_SOURCES
    
    This fix is needed to build Git using CMake in the wake of the recent
    migration of the reftable tests from being regression tests written in
    Unix shell script to being unit tests in pure C.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1947%2Fdscho%2Freftable-vs-cmake-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1947/dscho/reftable-vs-cmake-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1947

 contrib/buildsystems/CMakeLists.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 25b495fa737..edb0fc04ad7 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -1005,7 +1005,9 @@ parse_makefile_for_sources(clar-test_SOURCES ${CMAKE_SOURCE_DIR}/Makefile "CLAR_
 list(TRANSFORM clar-test_SOURCES REPLACE "\\$\\(UNIT_TEST_DIR\\)/" "${CMAKE_SOURCE_DIR}/t/unit-tests/")
 add_library(clar-test-lib STATIC ${clar-test_SOURCES})
 
-parse_makefile_for_scripts(unit_test_PROGRAMS "UNIT_TEST_PROGRAMS" "")
+file(GLOB unit_test_PROGRAMS "${CMAKE_SOURCE_DIR}/t/unit-tests/t-*.c")
+list(TRANSFORM unit_test_PROGRAMS REPLACE "${CMAKE_SOURCE_DIR}/" "")
+list(TRANSFORM unit_test_PROGRAMS REPLACE ".c" "")
 foreach(unit_test ${unit_test_PROGRAMS})
 	add_executable("${unit_test}" "${CMAKE_SOURCE_DIR}/t/unit-tests/${unit_test}.c")
 	target_link_libraries("${unit_test}" unit-test-lib clar-test-lib common-main)

base-commit: 866e6a391f466baeeb98bc585845ea638322c04b
-- 
gitgitgadget

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

* Re: [PATCH] cmake: accommodate for `UNIT_TEST_SOURCES`
  2025-08-03 21:24 [PATCH] cmake: accommodate for `UNIT_TEST_SOURCES` Johannes Schindelin via GitGitGadget
@ 2025-08-16 17:09 ` Johannes Schindelin
  2025-08-17 16:12   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Schindelin @ 2025-08-16 17:09 UTC (permalink / raw)
  To: Johannes Schindelin via GitGitGadget; +Cc: git, gitster

Hi Junio,

this patch is still required; I sent this before -rc0 was released so that
it could be included in v2.51.0 final. Could you please still merge it?

Thanks,
Johannes

On Sun, 3 Aug 2025, Johannes Schindelin via GitGitGadget wrote:

> From: Johannes Schindelin <johannes.schindelin@gmx.de>
> 
> As part of 9bbc981c6f2 (t/unit-tests: finalize migration of
> reftable-related tests, 2025-07-24), the explicit list of
> `UNIT_TEST_PROGRAMS` was turned into a wildcard pattern-derived list.
> 
> Let's do the same in the CMake definition.
> 
> This fixes build errors with symptoms like this:
> 
>   CMake Error at CMakeLists.txt:132 (string):
>     string sub-command REPLACE requires at least four arguments.
>   Call Stack (most recent call first):
>     CMakeLists.txt:1037 (parse_makefile_for_scripts)
> 
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>     cmake: accommodate for UNIT_TEST_SOURCES
>     
>     This fix is needed to build Git using CMake in the wake of the recent
>     migration of the reftable tests from being regression tests written in
>     Unix shell script to being unit tests in pure C.
> 
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1947%2Fdscho%2Freftable-vs-cmake-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1947/dscho/reftable-vs-cmake-v1
> Pull-Request: https://github.com/gitgitgadget/git/pull/1947
> 
>  contrib/buildsystems/CMakeLists.txt | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
> index 25b495fa737..edb0fc04ad7 100644
> --- a/contrib/buildsystems/CMakeLists.txt
> +++ b/contrib/buildsystems/CMakeLists.txt
> @@ -1005,7 +1005,9 @@ parse_makefile_for_sources(clar-test_SOURCES ${CMAKE_SOURCE_DIR}/Makefile "CLAR_
>  list(TRANSFORM clar-test_SOURCES REPLACE "\\$\\(UNIT_TEST_DIR\\)/" "${CMAKE_SOURCE_DIR}/t/unit-tests/")
>  add_library(clar-test-lib STATIC ${clar-test_SOURCES})
>  
> -parse_makefile_for_scripts(unit_test_PROGRAMS "UNIT_TEST_PROGRAMS" "")
> +file(GLOB unit_test_PROGRAMS "${CMAKE_SOURCE_DIR}/t/unit-tests/t-*.c")
> +list(TRANSFORM unit_test_PROGRAMS REPLACE "${CMAKE_SOURCE_DIR}/" "")
> +list(TRANSFORM unit_test_PROGRAMS REPLACE ".c" "")
>  foreach(unit_test ${unit_test_PROGRAMS})
>  	add_executable("${unit_test}" "${CMAKE_SOURCE_DIR}/t/unit-tests/${unit_test}.c")
>  	target_link_libraries("${unit_test}" unit-test-lib clar-test-lib common-main)
> 
> base-commit: 866e6a391f466baeeb98bc585845ea638322c04b
> -- 
> gitgitgadget
> 
> 

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

* Re: [PATCH] cmake: accommodate for `UNIT_TEST_SOURCES`
  2025-08-16 17:09 ` Johannes Schindelin
@ 2025-08-17 16:12   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2025-08-17 16:12 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Johannes Schindelin via GitGitGadget, git

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> Hi Junio,
>
> this patch is still required; I sent this before -rc0 was released so that
> it could be included in v2.51.0 final. Could you please still merge it?
>
> Thanks,
> Johannes

Thanks for pinging.  With so much traffic, a single patch without
any discussion thread went completely under the rader.

Will apply directly to 'master'.


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

end of thread, other threads:[~2025-08-17 16:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-03 21:24 [PATCH] cmake: accommodate for `UNIT_TEST_SOURCES` Johannes Schindelin via GitGitGadget
2025-08-16 17:09 ` Johannes Schindelin
2025-08-17 16:12   ` Junio C Hamano

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).