* [Tarantool-patches] [PATCH] build: fix CMP0175 warnings
@ 2026-09-12 23:49 Alexander Turenko via Tarantool-patches
2026-09-14 8:24 ` Sergey Kaplun via Tarantool-patches
2026-09-14 12:34 ` Sergey Bronnikov via Tarantool-patches
0 siblings, 2 replies; 3+ messages in thread
From: Alexander Turenko via Tarantool-patches @ 2026-09-12 23:49 UTC (permalink / raw)
To: Sergey Kaplun; +Cc: tarantool-patches, Alexander Turenko
The following pattern was used to add custom `make LuaJIT-foo` commands:
```cmake
add_custom_target(${PROJECT_NAME}-foo DEPENDS <...>)
add_custom_command(TARGET ${PROJECT_NAME}-foo
COMMAND <...>
)
```
However, recent cmake versions (verified on 4.3.4) warns about the
`add_custom_command` syntax (quoted [1]):
> `add_custom_command()` rejects invalid arguments.
>
> <...>
>
> The `TARGET` form requires exactly one of `PRE_BUILD`, `PRE_LINK`, or
> `POST_BUILD` to be given. Previously, if none were given, `POST_BUILD`
> was assumed, or if multiple keywords were given, the last one was
> used.
The fix could be add the `POST_BUILD` keyword. However, it is more
natural to just use `add_custom_target` with `COMMAND` instead:
```cmake
add_custom_target(${PROJECT_NAME}-foo
COMMAND <...>
DEPENDS <...>
)
```
The same change is proposed to tarantool: [2].
[1]: https://cmake.org/cmake/help/latest/policy/CMP0175.html
[2]: https://github.com/tarantool/tarantool/pull/13177
---
cmake/CodeCoverage.cmake | 3 +--
cmake/CodeSpell.cmake | 5 ++---
test/CMakeLists.txt | 14 ++++----------
test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt | 4 ++--
4 files changed, 9 insertions(+), 17 deletions(-)
diff --git a/cmake/CodeCoverage.cmake b/cmake/CodeCoverage.cmake
index 51345f1f..5c45bd11 100644
--- a/cmake/CodeCoverage.cmake
+++ b/cmake/CodeCoverage.cmake
@@ -16,8 +16,7 @@ if(NOT GCOVR OR NOT GCOV)
endif()
file(MAKE_DIRECTORY ${COVERAGE_DIR})
-add_custom_target(${PROJECT_NAME}-coverage)
-add_custom_command(TARGET ${PROJECT_NAME}-coverage
+add_custom_target(${PROJECT_NAME}-coverage
COMMENT "Building coverage report"
COMMAND
${GCOVR}
diff --git a/cmake/CodeSpell.cmake b/cmake/CodeSpell.cmake
index 31aa0a02..8592551a 100644
--- a/cmake/CodeSpell.cmake
+++ b/cmake/CodeSpell.cmake
@@ -35,9 +35,8 @@ set(CODESPELL_WHITELIST
set(IGNORE_WORDS ${PROJECT_SOURCE_DIR}/.codespell-ignore-words.txt)
-add_custom_target(${PROJECT_NAME}-codespell)
if(CODESPELL)
- add_custom_command(TARGET ${PROJECT_NAME}-codespell
+ add_custom_target(${PROJECT_NAME}-codespell
COMMENT "Running codespell"
COMMAND
${CODESPELL}
@@ -51,7 +50,7 @@ else()
set(STR1 "codespell is not found,")
set(STR2 "so ${PROJECT_NAME}-codespell target is dummy")
string(CONCAT WARN_MSG "${STR1} ${STR2}")
- add_custom_command(TARGET ${PROJECT_NAME}-codespell
+ add_custom_target(${PROJECT_NAME}-codespell
COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red ${WARN_MSG}
COMMENT ${WARN_MSG}
)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 26b15892..efdfa3d5 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -15,9 +15,6 @@ if(LUACHECK)
set(LUACHECK_RC ${LUACHECK_SOURCE_DIR}/.luacheckrc)
file(GLOB_RECURSE LUACHECK_DEPS ${LUACHECK_SOURCE_DIR}/*.lua)
add_custom_target(${PROJECT_NAME}-luacheck
- DEPENDS ${LUACHECK_RC} ${LUACHECK_DEPS}
- )
- add_custom_command(TARGET ${PROJECT_NAME}-luacheck
COMMENT "Running luacheck static analysis"
COMMAND
${LUACHECK} ${LUACHECK_SOURCE_DIR}
@@ -31,10 +28,10 @@ if(LUACHECK)
# the working directory, hence luacheck should be run in the
# project root directory.
WORKING_DIRECTORY ${LUACHECK_SOURCE_DIR}
+ DEPENDS ${LUACHECK_RC} ${LUACHECK_DEPS}
)
else()
- add_custom_target(${PROJECT_NAME}-luacheck)
- add_custom_command(TARGET ${PROJECT_NAME}-luacheck
+ add_custom_target(${PROJECT_NAME}-luacheck
COMMENT "`luacheck' is not found, so ${PROJECT_NAME}-luacheck target is dummy"
)
endif()
@@ -45,19 +42,16 @@ if(FLAKE8)
set(FLAKE8_RC ${FLAKE8_SOURCE_DIR}/.flake8rc)
file(GLOB_RECURSE FLAKE8_DEPS ${FLAKE8_SOURCE_DIR}/*.py)
add_custom_target(${PROJECT_NAME}-flake8
- DEPENDS ${FLAKE8_DEPS}
- )
- add_custom_command(TARGET ${PROJECT_NAME}-flake8
COMMENT "Running flake8 static analysis"
COMMAND
${FLAKE8} ${FLAKE8_DEPS}
--config ${FLAKE8_RC}
--jobs ${CMAKE_BUILD_PARALLEL_LEVEL}
WORKING_DIRECTORY ${FLAKE8_SOURCE_DIR}
+ DEPENDS ${FLAKE8_DEPS}
)
else()
- add_custom_target(${PROJECT_NAME}-flake8)
- add_custom_command(TARGET ${PROJECT_NAME}-flake8
+ add_custom_target(${PROJECT_NAME}-flake8
COMMENT "`flake8' is not found, so ${PROJECT_NAME}-flake8 target is dummy"
)
endif()
diff --git a/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt b/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt
index d4eb365a..e75b9e6d 100644
--- a/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt
+++ b/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt
@@ -24,11 +24,11 @@ list(APPEND TESTLIBS ${LIB2COPY})
# subdirectory "libs/P1", to be used by tests.
# Instead of tracking empty directory with some anchor-file for
# git, create this directory via CMake.
-add_custom_target(PUC-Rio-Lua-5.1-tests-prepare DEPENDS ${TESTLIBS})
-add_custom_command(TARGET PUC-Rio-Lua-5.1-tests-prepare
+add_custom_target(PUC-Rio-Lua-5.1-tests-prepare
COMMENT "Create directory for PUC-Rio Lua 5.1 tests"
COMMAND ${CMAKE_COMMAND} -E make_directory P1
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS ${TESTLIBS}
)
# vim: expandtab tabstop=2 shiftwidth=2
--
2.55.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Tarantool-patches] [PATCH] build: fix CMP0175 warnings
2026-09-12 23:49 [Tarantool-patches] [PATCH] build: fix CMP0175 warnings Alexander Turenko via Tarantool-patches
@ 2026-09-14 8:24 ` Sergey Kaplun via Tarantool-patches
2026-09-14 12:34 ` Sergey Bronnikov via Tarantool-patches
1 sibling, 0 replies; 3+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2026-09-14 8:24 UTC (permalink / raw)
To: Alexander Turenko; +Cc: tarantool-patches
Hi, Alexander!
Thanks for the patch!
LGTM!
I've asked Sergey to take a look as well, so CC him here.
Side note:
Branch: https://github.com/tarantool/luajit/tree/fix-cmp-0175-cmake-warnings
--
Best regards,
Sergey Kaplun
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Tarantool-patches] [PATCH] build: fix CMP0175 warnings
2026-09-12 23:49 [Tarantool-patches] [PATCH] build: fix CMP0175 warnings Alexander Turenko via Tarantool-patches
2026-09-14 8:24 ` Sergey Kaplun via Tarantool-patches
@ 2026-09-14 12:34 ` Sergey Bronnikov via Tarantool-patches
1 sibling, 0 replies; 3+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2026-09-14 12:34 UTC (permalink / raw)
To: Alexander Turenko, Sergey Kaplun; +Cc: tarantool-patches
Hi, Alexander!
thanks for the patch! LGTM
Sergey
On 9/13/26 02:49, Alexander Turenko via Tarantool-patches wrote:
> The following pattern was used to add custom `make LuaJIT-foo` commands:
>
> ```cmake
> add_custom_target(${PROJECT_NAME}-foo DEPENDS <...>)
> add_custom_command(TARGET ${PROJECT_NAME}-foo
> COMMAND <...>
> )
> ```
>
> However, recent cmake versions (verified on 4.3.4) warns about the
> `add_custom_command` syntax (quoted [1]):
>
>> `add_custom_command()` rejects invalid arguments.
>>
>> <...>
>>
>> The `TARGET` form requires exactly one of `PRE_BUILD`, `PRE_LINK`, or
>> `POST_BUILD` to be given. Previously, if none were given, `POST_BUILD`
>> was assumed, or if multiple keywords were given, the last one was
>> used.
> The fix could be add the `POST_BUILD` keyword. However, it is more
> natural to just use `add_custom_target` with `COMMAND` instead:
>
> ```cmake
> add_custom_target(${PROJECT_NAME}-foo
> COMMAND <...>
> DEPENDS <...>
> )
> ```
>
> The same change is proposed to tarantool: [2].
>
> [1]: https://cmake.org/cmake/help/latest/policy/CMP0175.html
> [2]: https://github.com/tarantool/tarantool/pull/13177
> ---
> cmake/CodeCoverage.cmake | 3 +--
> cmake/CodeSpell.cmake | 5 ++---
> test/CMakeLists.txt | 14 ++++----------
> test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt | 4 ++--
> 4 files changed, 9 insertions(+), 17 deletions(-)
>
> diff --git a/cmake/CodeCoverage.cmake b/cmake/CodeCoverage.cmake
> index 51345f1f..5c45bd11 100644
> --- a/cmake/CodeCoverage.cmake
> +++ b/cmake/CodeCoverage.cmake
> @@ -16,8 +16,7 @@ if(NOT GCOVR OR NOT GCOV)
> endif()
>
> file(MAKE_DIRECTORY ${COVERAGE_DIR})
> -add_custom_target(${PROJECT_NAME}-coverage)
> -add_custom_command(TARGET ${PROJECT_NAME}-coverage
> +add_custom_target(${PROJECT_NAME}-coverage
> COMMENT "Building coverage report"
> COMMAND
> ${GCOVR}
> diff --git a/cmake/CodeSpell.cmake b/cmake/CodeSpell.cmake
> index 31aa0a02..8592551a 100644
> --- a/cmake/CodeSpell.cmake
> +++ b/cmake/CodeSpell.cmake
> @@ -35,9 +35,8 @@ set(CODESPELL_WHITELIST
>
> set(IGNORE_WORDS ${PROJECT_SOURCE_DIR}/.codespell-ignore-words.txt)
>
> -add_custom_target(${PROJECT_NAME}-codespell)
> if(CODESPELL)
> - add_custom_command(TARGET ${PROJECT_NAME}-codespell
> + add_custom_target(${PROJECT_NAME}-codespell
> COMMENT "Running codespell"
> COMMAND
> ${CODESPELL}
> @@ -51,7 +50,7 @@ else()
> set(STR1 "codespell is not found,")
> set(STR2 "so ${PROJECT_NAME}-codespell target is dummy")
> string(CONCAT WARN_MSG "${STR1} ${STR2}")
> - add_custom_command(TARGET ${PROJECT_NAME}-codespell
> + add_custom_target(${PROJECT_NAME}-codespell
> COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red ${WARN_MSG}
> COMMENT ${WARN_MSG}
> )
> diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
> index 26b15892..efdfa3d5 100644
> --- a/test/CMakeLists.txt
> +++ b/test/CMakeLists.txt
> @@ -15,9 +15,6 @@ if(LUACHECK)
> set(LUACHECK_RC ${LUACHECK_SOURCE_DIR}/.luacheckrc)
> file(GLOB_RECURSE LUACHECK_DEPS ${LUACHECK_SOURCE_DIR}/*.lua)
> add_custom_target(${PROJECT_NAME}-luacheck
> - DEPENDS ${LUACHECK_RC} ${LUACHECK_DEPS}
> - )
> - add_custom_command(TARGET ${PROJECT_NAME}-luacheck
> COMMENT "Running luacheck static analysis"
> COMMAND
> ${LUACHECK} ${LUACHECK_SOURCE_DIR}
> @@ -31,10 +28,10 @@ if(LUACHECK)
> # the working directory, hence luacheck should be run in the
> # project root directory.
> WORKING_DIRECTORY ${LUACHECK_SOURCE_DIR}
> + DEPENDS ${LUACHECK_RC} ${LUACHECK_DEPS}
> )
> else()
> - add_custom_target(${PROJECT_NAME}-luacheck)
> - add_custom_command(TARGET ${PROJECT_NAME}-luacheck
> + add_custom_target(${PROJECT_NAME}-luacheck
> COMMENT "`luacheck' is not found, so ${PROJECT_NAME}-luacheck target is dummy"
> )
> endif()
> @@ -45,19 +42,16 @@ if(FLAKE8)
> set(FLAKE8_RC ${FLAKE8_SOURCE_DIR}/.flake8rc)
> file(GLOB_RECURSE FLAKE8_DEPS ${FLAKE8_SOURCE_DIR}/*.py)
> add_custom_target(${PROJECT_NAME}-flake8
> - DEPENDS ${FLAKE8_DEPS}
> - )
> - add_custom_command(TARGET ${PROJECT_NAME}-flake8
> COMMENT "Running flake8 static analysis"
> COMMAND
> ${FLAKE8} ${FLAKE8_DEPS}
> --config ${FLAKE8_RC}
> --jobs ${CMAKE_BUILD_PARALLEL_LEVEL}
> WORKING_DIRECTORY ${FLAKE8_SOURCE_DIR}
> + DEPENDS ${FLAKE8_DEPS}
> )
> else()
> - add_custom_target(${PROJECT_NAME}-flake8)
> - add_custom_command(TARGET ${PROJECT_NAME}-flake8
> + add_custom_target(${PROJECT_NAME}-flake8
> COMMENT "`flake8' is not found, so ${PROJECT_NAME}-flake8 target is dummy"
> )
> endif()
> diff --git a/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt b/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt
> index d4eb365a..e75b9e6d 100644
> --- a/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt
> +++ b/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt
> @@ -24,11 +24,11 @@ list(APPEND TESTLIBS ${LIB2COPY})
> # subdirectory "libs/P1", to be used by tests.
> # Instead of tracking empty directory with some anchor-file for
> # git, create this directory via CMake.
> -add_custom_target(PUC-Rio-Lua-5.1-tests-prepare DEPENDS ${TESTLIBS})
> -add_custom_command(TARGET PUC-Rio-Lua-5.1-tests-prepare
> +add_custom_target(PUC-Rio-Lua-5.1-tests-prepare
> COMMENT "Create directory for PUC-Rio Lua 5.1 tests"
> COMMAND ${CMAKE_COMMAND} -E make_directory P1
> WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
> + DEPENDS ${TESTLIBS}
> )
>
> # vim: expandtab tabstop=2 shiftwidth=2
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-14 12:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-12 23:49 [Tarantool-patches] [PATCH] build: fix CMP0175 warnings Alexander Turenko via Tarantool-patches
2026-09-14 8:24 ` Sergey Kaplun via Tarantool-patches
2026-09-14 12:34 ` Sergey Bronnikov via Tarantool-patches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox