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 804179E034A; Wed, 31 Jan 2024 14:25:50 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 804179E034A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1706700350; bh=/5xJNlL6TCvZqU7lVnPnSI29l9ryJy0OUbutjLvpsV0=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=R6uh/pySW9a0xcHoM6SraDKix7yk++By+UrG05x/uEV9tY32Ydj//Fa+JJF5/+j+d t/cNJGQ4OleZDDPgwVe6JhzrZAeS0Tr0nzCvZyNSbCexvVvLEuC2WeOv5Ymkz7S9p+ N+HDr4VO4K6UD0dnDLLD7EItUell6egQLr99Bppk= 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 8994A76B512 for ; Wed, 31 Jan 2024 14:25:48 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8994A76B512 Received: by smtp32.i.mail.ru with esmtpa (envelope-from ) id 1rV8ix-00000007oyN-2cEv; Wed, 31 Jan 2024 14:25:48 +0300 Date: Wed, 31 Jan 2024 14:25:47 +0300 To: Sergey Kaplun Message-ID: <5iuttl6zigwuep2rvkmt7e6e5fnl47j22mzwrz2lr36pradelz@ti7zceeeqmcn> References: <9075481da3fd5f4d2d4f7b5bb99eb3590b104693.1706520765.git.skaplun@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9075481da3fd5f4d2d4f7b5bb99eb3590b104693.1706520765.git.skaplun@tarantool.org> X-Mailru-Src: smtp X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9DF1FFD52FB7F4A9551979D35EDE55D8102EF6ED2D8D1DC5E00894C459B0CD1B90FA6B5ECD6448EAB54213B91BF88983295F3B19CEEA395CDAD811DBBDC7CAAF4CE06B70447BA4CE8 X-C1DE0DAB: 0D63561A33F958A58039E9C3574BB6155002B1117B3ED69680CD2BCB4F71DADCCA7E60A991436CA2823CB91A9FED034534781492E4B8EEAD1A3F3A3731258CC5BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF77DD89D51EBB7742D3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF7C0B9CCD87BE4FAFE40C666DEF15CEA432D0A9D28CC9F9D8AEE1B6B27AAA69B7DAFD28DA9052916ABAF4CF3B87E910B146F1C01A4857EAE99FD6EC2FB14F3E96889C6F1F29360D3F5F4332CA8FE04980913E6812662D5F2A54F6898A6FDCBDC72A617DFBE5FEC2C6383653B6C8D9AE0FD16FCAA6493B703A X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojqJaWtPsRtylHy/rzMr3UfA== X-Mailru-Sender: 11C2EC085EDE56FA38FD4C59F7EFE4076DD365711FCA4A4AB951B70A5BD4BD8E95AA15CBD10176E8CA71892AC981DD5F04C9FB44FCBCE9EE92D99EB8CC7091A7ECEABDC5717908DEF544888E8238EB4872D6B4FCE48DF648AE208404248635DF X-Mras: OK Subject: Re: [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: Maxim Kokryashkin via Tarantool-patches Reply-To: Maxim Kokryashkin Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, Sergey! Thanks for the patch! Please consider my comments below. On Mon, Jan 29, 2024 at 01:45:01PM +0300, Sergey Kaplun wrote: > 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() This macro now seems redundant, maybe we should get rid of it. > > 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 Typo: s/cmake/CMake/ Typo: s/scope and/scope,/ > + # so a user should care to don't use it in a top level scope. Typo: s/should care to don't use/shouldn't use/ Typo: s/top level/top-level/ > + # 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}" > + ) I wonder why you've omitted the condition along with the comment here. > + 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}) Same comments as for the above section. > # 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 >