[Tarantool-patches] [PATCH luajit 2/3][v2] test: set dependencies to tarantool-tests explicitly

Sergey Bronnikov estetus at gmail.com
Thu Nov 9 16:08:38 MSK 2023


From: Sergey Bronnikov <sergeyb at tarantool.org>

In testsuite `tarantool-tests` we are using CMake macro `BuildTestCLib`
for building test C libraries. This macro builds a list `TESTLIBS` that
contains all libraries required for tarantool tests. However, CMake
skips adding C library to `TESTLIBS` on building test C library in the
following commit.

The patch removes `TESTLIBS` and adds each test C library as dependence
to CMake target `tarantool-tests` explicitly using `add_dependence`
command.
---
 test/tarantool-tests/CMakeLists.txt | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/test/tarantool-tests/CMakeLists.txt b/test/tarantool-tests/CMakeLists.txt
index c15d6037..d46e69a0 100644
--- a/test/tarantool-tests/CMakeLists.txt
+++ b/test/tarantool-tests/CMakeLists.txt
@@ -10,6 +10,10 @@ if(NOT PROVE)
   return()
 endif()
 
+add_custom_target(tarantool-tests
+  DEPENDS ${LUAJIT_TEST_BINARY}
+)
+
 macro(BuildTestCLib lib sources)
   add_library(${lib} SHARED EXCLUDE_FROM_ALL ${sources})
   target_include_directories(${lib} PRIVATE
@@ -37,12 +41,7 @@ macro(BuildTestCLib lib sources)
       CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}"
     )
   endif()
-  # XXX: Append the lib to be built to the dependency list.
-  # Unfortunately, there is no convenient way in CMake to extend
-  # the list in parent scope other than join two strings with
-  # semicolon. If one finds the normal way to make it work, feel
-  # free to reach me.
-  set(TESTLIBS "${lib};${TESTLIBS}" PARENT_SCOPE)
+  add_dependencies(tarantool-tests ${lib})
   # Add the directory where the lib is built to the list with
   # entries for LUA_CPATH environment variable, so LuaJIT can find
   # and load it. See the comment about extending the list in the
@@ -133,11 +132,6 @@ else()
   list(APPEND LUA_TEST_ENV_MORE LD_LIBRARY_PATH=${LD_LIBRARY_PATH})
 endif()
 
-# LUA_CPATH and LD_LIBRARY_PATH variables and also TESTLIBS list
-# with dependecies are set in scope of BuildTestLib macro.
-add_custom_target(tarantool-tests
-  DEPENDS ${LUAJIT_TEST_BINARY} ${TESTLIBS}
-)
 add_custom_command(TARGET tarantool-tests
   COMMENT "Running Tarantool tests"
   COMMAND
@@ -154,4 +148,3 @@ add_custom_command(TARGET tarantool-tests
       ${LUA_TEST_FLAGS}
   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
 )
-
-- 
2.34.1



More information about the Tarantool-patches mailing list