From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id A45399DC601; Mon, 29 Jan 2024 13:49:55 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A45399DC601 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1706525395; bh=bucn4ljFTmBR2kcR1dyn7pwLcXE87eZqI0N/vk/iMK0=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=qZQsysf2wyDEMkDAD2ef+qpyulZ7xi8+HZ6RLrYyeOt+LjjwFTUMYUh2KWRGi4ZE2 jowNNxYILOjhHuTAp0kxMfikxrEiWtE9nYKO4znwK45GjyL3xuR6mrAJ4Jgk1jkZyT MCMx5m2tiOvgiD2LMeMslvzqdF6RuGT+OAZXQveI= Received: from smtp32.i.mail.ru (smtp32.i.mail.ru [95.163.41.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id C877D9C201B for ; Mon, 29 Jan 2024 13:49:23 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C877D9C201B Received: by smtp32.i.mail.ru with esmtpa (envelope-from ) id 1rUPCc-0000000BQ6r-489B; Mon, 29 Jan 2024 13:49:23 +0300 To: Maxim Kokryashkin , Sergey Bronnikov Date: Mon, 29 Jan 2024 13:45:01 +0300 Message-ID: <9075481da3fd5f4d2d4f7b5bb99eb3590b104693.1706520765.git.skaplun@tarantool.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD96A58C36AA2E9964961C035FBEF5806C782512F712DED10CE182A05F538085040EE46B7E9E85ADBF333594132A326AF8B28D0D92ECBD97992DCA417647058147805836D1F9953231F X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7FBCED7D376B82B5EEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063738C1CCEC8FAC1CB98638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D826598E25F7AC2FF9BE1BF1E404F07B8E809954F8565C5179CC7F00164DA146DAFE8445B8C89999728AA50765F7900637FD2911E685725BF8389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC86089696B24BB1D19F6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947CABB3490C75E89280302FCEF25BFAB3454AD6D5ED66289B523666184CF4C3C14F6136E347CC761E07725E5C173C3A84C31D04D3D2E8C2E24EBA3038C0950A5D36B5C8C57E37DE458B330BD67F2E7D9AF16D1867E19FE14079C09775C1D3CA48CFE478A468B35FE7671DD303D21008E298D5E8D9A59859A8B6B372FE9A2E580EFC725E5C173C3A84C37727919777A35F2B35872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-C1DE0DAB: 0D63561A33F958A5D864FD01ECBEB91F5002B1117B3ED696CEFCDD16369E81EE406406D89DD9EB8A823CB91A9FED034534781492E4B8EEADECBEDCEC3CCF9A28C79554A2A72441328621D336A7BC284946AD531847A6065A535571D14F44ED41 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF1D4364583537BD070C92F895A1379BA273FB89BC50837EDEDE04B9B22F7B3510486D6DC23143AA0E8FB01E7B8BF01A69BBC4750359A92D6AB718120DE96C5CC5DA6D66D0AE85CD08C226CC413062362A913E6812662D5F2A5EAB5682573093F7837F15F2B5E4A70B33F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojmd9AG1X07oSSCCjgcUtQ+Q== X-Mailru-Sender: 11C2EC085EDE56FAC07928AF2646A7698D0B66CC06C7420933594132A326AF8B28D0D92ECBD97992B7CBEF92542CD7C88B0A2698F12F5C9EC77752E0C033A69E86920BD37369036789A8C6A0E60D2BB63A5DB60FBEB33A8A0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATCH v2 luajit 01/26] cmake: introduce AddTestLib macro X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Kaplun via Tarantool-patches Reply-To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This patch removes copy-pasting in macros used to add a new library for testing and places this in the include test file. Needed for tarantool/tarantool#9398 --- test/CMakeLists.txt | 3 ++ .../PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt | 25 +---------------- test/cmake/AddTestLib.cmake | 28 +++++++++++++++++++ test/tarantool-tests/CMakeLists.txt | 27 +----------------- 4 files changed, 33 insertions(+), 50 deletions(-) create mode 100644 test/cmake/AddTestLib.cmake diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8afc42df..3ad5d15f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -74,6 +74,9 @@ add_custom_target(${PROJECT_NAME}-lint DEPENDS set(LUAJIT_TEST_COMMAND "${LUAJIT_TEST_BINARY} -e dofile[[${LUAJIT_TEST_INIT}]]") separate_arguments(LUAJIT_TEST_COMMAND) +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +include(AddTestLib) + add_subdirectory(LuaJIT-tests) add_subdirectory(PUC-Rio-Lua-5.1-tests) add_subdirectory(lua-Harness-tests) 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 8501b767..e68e6aef 100644 --- a/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt +++ b/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt @@ -6,30 +6,7 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR) # Build additional C libraries for tests. macro(BuildTestCLib lib sources) - add_library(${lib} SHARED EXCLUDE_FROM_ALL ${sources}) - target_include_directories(${lib} PRIVATE - ${LUAJIT_SOURCE_DIR} - ) - set_target_properties(${lib} PROPERTIES - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" - PREFIX "" - ) - # XXX: The dynamic libraries are loaded with LuaJIT binary and - # use symbols from it. So it is totally OK to have unresolved - # symbols at build time. - if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - set_target_properties(${lib} PROPERTIES - LINK_FLAGS "-undefined dynamic_lookup" - ) - elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") - # XXX: This is necessary mostly for openSUSE builds, see also - # https://bugzilla.suse.com/show_bug.cgi?id=1012388. - # Just strip out the linker flag to suppress this linker - # option. - string(REPLACE "-Wl,--no-undefined" "" - CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}" - ) - endif() + AddTestLib(${lib} ${sources}) list(APPEND TESTLIBS ${lib}) endmacro() diff --git a/test/cmake/AddTestLib.cmake b/test/cmake/AddTestLib.cmake new file mode 100644 index 00000000..3764ee5c --- /dev/null +++ b/test/cmake/AddTestLib.cmake @@ -0,0 +1,28 @@ +macro(AddTestLib lib sources) + add_library(${lib} SHARED EXCLUDE_FROM_ALL ${sources}) + target_include_directories(${lib} PRIVATE + ${LUAJIT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ) + set_target_properties(${lib} PROPERTIES + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + PREFIX "" + ) + + # XXX: This change affects the current cmake variable scope and + # so a user should care to don't use it in a top level scope. + # The dynamic libraries are loaded with LuaJIT binary and use + # symbols from it. So it is totally OK to have unresolved + # symbols at build time. + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set_target_properties(${lib} PROPERTIES + LINK_FLAGS "-undefined dynamic_lookup" + ) + else() + # FIXME: Unfortunately, there is no another way to suppress + # this linker option, so just strip it out from the flags. + string(REPLACE "-Wl,--no-undefined" "" + CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}" + ) + endif() +endmacro() diff --git a/test/tarantool-tests/CMakeLists.txt b/test/tarantool-tests/CMakeLists.txt index 6d686876..80d94a78 100644 --- a/test/tarantool-tests/CMakeLists.txt +++ b/test/tarantool-tests/CMakeLists.txt @@ -11,32 +11,7 @@ if(NOT PROVE) endif() macro(BuildTestCLib lib sources) - add_library(${lib} SHARED EXCLUDE_FROM_ALL ${sources}) - target_include_directories(${lib} PRIVATE - ${LUAJIT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} - ) - set_target_properties(${lib} PROPERTIES - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" - PREFIX "" - ) - - # XXX: This change affects the current cmake variable scope and - # so a user should care to don't use it in a top level scope. - # The dynamic libraries are loaded with LuaJIT binary and use - # symbols from it. So it is totally OK to have unresolved - # symbols at build time. - if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - set_target_properties(${lib} PROPERTIES - LINK_FLAGS "-undefined dynamic_lookup" - ) - else() - # FIXME: Unfortunately, there is no another way to suppress - # this linker option, so just strip it out from the flags. - string(REPLACE "-Wl,--no-undefined" "" - CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}" - ) - endif() + AddTestLib(${lib} ${sources}) # 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 -- 2.43.0