Skip to content

Commit 52c42b3

Browse files
TotktonadaBuristan
authored andcommitted
build: fix CMP0175 warnings
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]: tarantool/tarantool#13177 Reviewed-by: Sergey Kaplun <skaplun@tarantool.org> Reviewed-by: Sergey Bronnikov <sergeyb@tarantool.org> Signed-off-by: Sergey Kaplun <skaplun@tarantool.org> (cherry picked from commit f3829a4)
1 parent afbb3c2 commit 52c42b3

4 files changed

Lines changed: 9 additions & 17 deletions

File tree

‎cmake/CodeCoverage.cmake‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ if(NOT GCOVR OR NOT GCOV)
1616
endif()
1717

1818
file(MAKE_DIRECTORY ${COVERAGE_DIR})
19-
add_custom_target(${PROJECT_NAME}-coverage)
20-
add_custom_command(TARGET ${PROJECT_NAME}-coverage
19+
add_custom_target(${PROJECT_NAME}-coverage
2120
COMMENT "Building coverage report"
2221
COMMAND
2322
${GCOVR}

‎cmake/CodeSpell.cmake‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ set(CODESPELL_WHITELIST
3535

3636
set(IGNORE_WORDS ${PROJECT_SOURCE_DIR}/.codespell-ignore-words.txt)
3737

38-
add_custom_target(${PROJECT_NAME}-codespell)
3938
if(CODESPELL)
40-
add_custom_command(TARGET ${PROJECT_NAME}-codespell
39+
add_custom_target(${PROJECT_NAME}-codespell
4140
COMMENT "Running codespell"
4241
COMMAND
4342
${CODESPELL}
@@ -51,7 +50,7 @@ else()
5150
set(STR1 "codespell is not found,")
5251
set(STR2 "so ${PROJECT_NAME}-codespell target is dummy")
5352
string(CONCAT WARN_MSG "${STR1} ${STR2}")
54-
add_custom_command(TARGET ${PROJECT_NAME}-codespell
53+
add_custom_target(${PROJECT_NAME}-codespell
5554
COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red ${WARN_MSG}
5655
COMMENT ${WARN_MSG}
5756
)

‎test/CMakeLists.txt‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ if(LUACHECK)
1515
set(LUACHECK_RC ${LUACHECK_SOURCE_DIR}/.luacheckrc)
1616
file(GLOB_RECURSE LUACHECK_DEPS ${LUACHECK_SOURCE_DIR}/*.lua)
1717
add_custom_target(${PROJECT_NAME}-luacheck
18-
DEPENDS ${LUACHECK_RC} ${LUACHECK_DEPS}
19-
)
20-
add_custom_command(TARGET ${PROJECT_NAME}-luacheck
2118
COMMENT "Running luacheck static analysis"
2219
COMMAND
2320
${LUACHECK} ${LUACHECK_SOURCE_DIR}
@@ -31,10 +28,10 @@ if(LUACHECK)
3128
# the working directory, hence luacheck should be run in the
3229
# project root directory.
3330
WORKING_DIRECTORY ${LUACHECK_SOURCE_DIR}
31+
DEPENDS ${LUACHECK_RC} ${LUACHECK_DEPS}
3432
)
3533
else()
36-
add_custom_target(${PROJECT_NAME}-luacheck)
37-
add_custom_command(TARGET ${PROJECT_NAME}-luacheck
34+
add_custom_target(${PROJECT_NAME}-luacheck
3835
COMMENT "`luacheck' is not found, so ${PROJECT_NAME}-luacheck target is dummy"
3936
)
4037
endif()
@@ -45,19 +42,16 @@ if(FLAKE8)
4542
set(FLAKE8_RC ${FLAKE8_SOURCE_DIR}/.flake8rc)
4643
file(GLOB_RECURSE FLAKE8_DEPS ${FLAKE8_SOURCE_DIR}/*.py)
4744
add_custom_target(${PROJECT_NAME}-flake8
48-
DEPENDS ${FLAKE8_DEPS}
49-
)
50-
add_custom_command(TARGET ${PROJECT_NAME}-flake8
5145
COMMENT "Running flake8 static analysis"
5246
COMMAND
5347
${FLAKE8} ${FLAKE8_DEPS}
5448
--config ${FLAKE8_RC}
5549
--jobs ${CMAKE_BUILD_PARALLEL_LEVEL}
5650
WORKING_DIRECTORY ${FLAKE8_SOURCE_DIR}
51+
DEPENDS ${FLAKE8_DEPS}
5752
)
5853
else()
59-
add_custom_target(${PROJECT_NAME}-flake8)
60-
add_custom_command(TARGET ${PROJECT_NAME}-flake8
54+
add_custom_target(${PROJECT_NAME}-flake8
6155
COMMENT "`flake8' is not found, so ${PROJECT_NAME}-flake8 target is dummy"
6256
)
6357
endif()

‎test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ list(APPEND TESTLIBS ${LIB2COPY})
2424
# subdirectory "libs/P1", to be used by tests.
2525
# Instead of tracking empty directory with some anchor-file for
2626
# git, create this directory via CMake.
27-
add_custom_target(PUC-Rio-Lua-5.1-tests-prepare DEPENDS ${TESTLIBS})
28-
add_custom_command(TARGET PUC-Rio-Lua-5.1-tests-prepare
27+
add_custom_target(PUC-Rio-Lua-5.1-tests-prepare
2928
COMMENT "Create directory for PUC-Rio Lua 5.1 tests"
3029
COMMAND ${CMAKE_COMMAND} -E make_directory P1
3130
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
31+
DEPENDS ${TESTLIBS}
3232
)
3333

3434
# vim: expandtab tabstop=2 shiftwidth=2

0 commit comments

Comments
 (0)