Tarantool development patches archive
 help / color / mirror / Atom feed
From: Alexander Turenko via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Sergey Kaplun <skaplun@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org,
	Alexander Turenko <alexander.turenko@tarantool.org>
Subject: [Tarantool-patches] [PATCH] build: fix CMP0175 warnings
Date: Sun, 13 Sep 2026 02:49:48 +0300	[thread overview]
Message-ID: <783b19798eebe5c8cb7406a3f0ee052fddd4c9eb.1789256599.git.alexander.turenko@tarantool.org> (raw)

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


                 reply	other threads:[~2026-09-12 23:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=783b19798eebe5c8cb7406a3f0ee052fddd4c9eb.1789256599.git.alexander.turenko@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=alexander.turenko@tarantool.org \
    --cc=skaplun@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH] build: fix CMP0175 warnings' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox