miconda left a comment (kamailio/kamailio#4578)
As I just pressed submit to my previous comment, an idea popped up, this time
targeting also the tlsa module, which I would like to simplify in a way and
another.
Any opinions in sort-of-meta/pseudo-modules? where a folder is created for such
module, like app_lua52, but then it has only the CMakeLists.txt and minimal
docs to inform about its role, then pointing to the main folder.
I played a bit with it and seems to work to some extent. At least for tlsa
compilation works ok. I removed all its `*.{c,h}` files and did the changes:
``` diff
diff --git a/src/modules/tlsa/CMakeLists.txt b/src/modules/tlsa/CMakeLists.txt
index 2527da510b..30a7fadd3d 100644
--- a/src/modules/tlsa/CMakeLists.txt
+++ b/src/modules/tlsa/CMakeLists.txt
@@ -1,4 +1,4 @@
-file(GLOB MODULE_SOURCES "*.c")
+file(GLOB MODULE_SOURCES "../tls/*.c")
```
I expected that maybe it doesn't find the `../tls/*.h` files while compiling,
but all went fine. If this proves to be a right approach, in the future, when
old makefiles are removed, I will go for it.
Similarly, I created the folder `src/modules/app_lua52` with some minimal
`doc/` subfolder and `README`, plus the `CMakeLists.txt ` with the following
content:
``` cmake
file(GLOB MODULE_SOURCES "../app_lua/*.c")
add_library(${module_name} SHARED ${MODULE_SOURCES})
unset(LUA_INCLUDE_DIR CACHE)
unset(LUA52_INCLUDE_DIRS CACHE)
unset(LUA_LIBRARIES CACHE)
unset(LUA52_LIBRARIES CACHE)
option(LUAJIT "Enable LuaJIT (for app_lua modules)" OFF)
if(LUAJIT)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LUA REQUIRED IMPORTED_TARGET luajit)
else()
find_package(Lua 5.2 EXACT REQUIRED)
# CMake FindLua defines include as LUA_INCLUDE_DIR and lib as LUA_LIBRARIES
set(LUA52_INCLUDE_DIRS ${LUA_INCLUDE_DIR})
set(LUA52_LIBRARIES ${LUA_LIBRARIES})
endif()
# the LUA_COMPAT_MODULE fixes this error: - implicit declaration of function
# luaL_openlib
target_compile_definitions(${module_name} PRIVATE LUA_COMPAT_MODULE)
target_include_directories(${module_name} PRIVATE ${LUA52_INCLUDE_DIRS})
target_link_libraries(${module_name} PRIVATE ${LUA52_LIBRARIES})
unset(LUA_INCLUDE_DIR CACHE)
unset(LUA52_INCLUDE_DIRS CACHE)
unset(LUA_LIBRARIES CACHE)
unset(LUA52_LIBRARIES CACHE)
```
When running:
``` shell
cmake -DINCLUDE_MODULES="app_lua app_lua52 tls tlsa" ..
```
I get:
```
-- Found Lua:
/usr/lib/aarch64-linux-gnu/liblua5.4.so;/usr/lib/aarch64-linux-gnu/libm.so
(found version "5.4.6")
-- Found Lua:
/usr/lib/aarch64-linux-gnu/liblua5.4.so;/usr/lib/aarch64-linux-gnu/libm.so
(found suitable exact version "5.2.4")
```
When compiling, the include dir points to lua5.2, but linking is still done
with lua5.2:
``` shell
[100%] Building C object
src/modules/app_lua52/CMakeFiles/app_lua52.dir/__/app_lua/app_lua_mod.c.o
cd /home/ubuntu/work/sip-router/buildlin/src/modules/app_lua52 && /usr/bin/cc
-DARCH=\"aarch64\" -DCC_GCC_LIKE_ASM -DCFG_DIR=\"/usr/local/etc/kamailio/\"
-DCOMPILER="\"gcc 13.3.0\"" -DDBG_SR_MEMORY -DDISABLE_NAGLE -DDNS_IP_HACK
-DF_MALLOC -DHAVE_ALLOCA_H -DHAVE_GETHOSTBYNAME2 -DHAVE_IP_MREQN
-DHAVE_MSGHDR_MSG_CONTROL -DHAVE_MSG_NOSIGNAL -DHAVE_RESOLV_RES
-DHAVE_SCHED_SETSCHEDULER -DHAVE_SCHED_YIELD -DHAVE_TIMEGM -DHAVE_UNION_SEMUN
-DKSR_PTHREAD_MUTEX_SHARED -DLUA_COMPAT_MODULE -DMALLOC_STATS -DMEM_JOIN_FREE
-DMOD_NAME=\"app_lua52\" -DMOD_NAMEID=app_lua52 -DNAME=\"kamailio\" -DOS=Linux
-DOS_QUOTED=\"Linux\" -DPKG_MALLOC -DQ_MALLOC -DRUN_DIR=\"/run/kamailio\"
-DSHARE_DIR=\"/usr/local/share/kamailio/\" -DSHM_MMAP -DSTATISTICS
-DTLSF_MALLOC -DTLS_HOOKS -DUSE_CORE_STATS -DUSE_DNS_CACHE -DUSE_DNS_FAILOVER
-DUSE_DST_BLOCKLIST -DUSE_MCAST -DUSE_NAPTR -DUSE_PTHREAD_MUTEX -DUSE_RAW_SOCKS
-DUSE_SCTP -DUSE_TCP -DUSE_TLS -DVERSION=\"6.2.0-dev0\" -DVERSIONVAL=6002000
-D__CPU_aarch64 -D__OS_linux -Dapp_lua52_EXPORTS -I/usr/include/lua5.2 -g
-std=gnu11 -fPIC
-ffile-prefix-map=/home/ubuntu/work/sip-router/src/modules/app_lua52/= -fPIC
-MD -MT
src/modules/app_lua52/CMakeFiles/app_lua52.dir/__/app_lua/app_lua_mod.c.o -MF
CMakeFiles/app_lua52.dir/__/app_lua/app_lua_mod.c.o.d -o
CMakeFiles/app_lua52.dir/__/app_lua/app_lua_mod.c.o -c
/home/ubuntu/work/sip-router/src/modules/app_lua/app_lua_mod.c
[100%] Linking C shared library app_lua52.so
cd /home/ubuntu/work/sip-router/buildlin/src/modules/app_lua52 &&
/usr/bin/cmake -E cmake_link_script CMakeFiles/app_lua52.dir/link.txt
--verbose=on
/usr/bin/cc -fPIC -g -shared -Wl,-soname,app_lua52.so -o app_lua52.so
CMakeFiles/app_lua52.dir/__/app_lua/app_lua_api.c.o
CMakeFiles/app_lua52.dir/__/app_lua/app_lua_kemi_export.c.o
CMakeFiles/app_lua52.dir/__/app_lua/app_lua_mod.c.o
-Wl,-rpath,::::::::::::::::::::::: /usr/lib/aarch64-linux-gnu/liblua5.4.so -lm
-lpthread -ldl -lresolv
```
The compile has `-I/usr/include/lua5.2`, but the linking is with
`/usr/lib/aarch64-linux-gnu/liblua5.4.so` ...
I just wanted to add these details, not to forget about this approach and have
the results here for reference.
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/4578#issuecomment-3860075299
You are receiving this because you commented.
Message ID: <kamailio/kamailio/issues/4578/[email protected]>_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the
sender!