Module: kamailio
Branch: master
Commit: abb0448c11812d9f11529a70303348474eed19de
URL:
https://github.com/kamailio/kamailio/commit/abb0448c11812d9f11529a703033484…
Author: Xenofon Karamanos <xk(a)gilawa.com>
Committer: Xenofon Karamanos <xk(a)gilawa.com>
Date: 2024-12-03T15:14:56Z
cmake: Add support for custom binary and cfg name
---
Modified: CMakeLists.txt
Modified: src/CMakeLists.txt
Modified: utils/kamctl/CMakeLists.txt
---
Diff:
https://github.com/kamailio/kamailio/commit/abb0448c11812d9f11529a703033484…
Patch:
https://github.com/kamailio/kamailio/commit/abb0448c11812d9f11529a703033484…
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 55923560477..f7270f0abc3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,9 +27,15 @@ set(CMAKE_C_STANDARD_REQUIRED True)
# Main project name
# -----------------------
# main binary name
-set(MAIN_NAME "kamailio")
+set(MAIN_NAME
+ "kamailio"
+ CACHE STRING "Main binary name"
+)
# use kamailio config
-set(CFG_NAME "kamailio")
+set(CFG_NAME
+ "kamailio"
+ CACHE STRING "Config name"
+)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2d236ff9200..ccafefaefb2 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -100,7 +100,9 @@ add_dependencies(kamailio GenerateParser)
# Enable ENABLE_EXPORTS property so modules can link from symbols found in
# main.c and core/*.
-set_target_properties(kamailio PROPERTIES ENABLE_EXPORTS TRUE)
+set_target_properties(
+ kamailio PROPERTIES ENABLE_EXPORTS TRUE OUTPUT_NAME ${MAIN_NAME}
+)
# Add the MODS_DIR definition required by main.c ---
target_compile_definitions(
@@ -117,25 +119,26 @@ install(
COMPONENT kamailio-core
)
-# Install the configuration file (kamailio.cfg) using a CODE block to check
+# Install the configuration file (kamailio.cfg) ${CFG_NAME} using a CODE block to check
# existence at install time instead of configure time
# If(EXISTS ..) require full path
install(
CODE "
- if(EXISTS
\"\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_SYSCONFDIR}/${MAIN_NAME}/kamailio.cfg\")
- message(STATUS \"kamailio.cfg already exists in
\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_SYSCONFDIR}/${MAIN_NAME}/kamailio.cfg. Installing
as kamailio.cfg.sample\")
+ if(EXISTS
\"\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_SYSCONFDIR}/${MAIN_NAME}/${CFG_NAME}.cfg\")
+ message(STATUS \"${CFG_NAME} already exists in
\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_SYSCONFDIR}/${MAIN_NAME}/${CFG_NAME}. Installing
as ${CFG_NAME}.sample\")
file(INSTALL \"${CMAKE_SOURCE_DIR}/etc/kamailio.cfg\"
DESTINATION
\"\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_SYSCONFDIR}/${MAIN_NAME}\"
- RENAME \"kamailio.cfg.sample\"
+ RENAME \"${CFG_NAME}.cfg.sample\"
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
else()
file(INSTALL \"${CMAKE_SOURCE_DIR}/etc/kamailio.cfg\"
DESTINATION
\"\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_SYSCONFDIR}/${MAIN_NAME}\"
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
+ RENAME \"${CFG_NAME}.cfg\"
)
endif()
"
- COMPONENT kamailio-cfg
+ COMPONENT kamailio-utils-cfg
)
diff --git a/utils/kamctl/CMakeLists.txt b/utils/kamctl/CMakeLists.txt
index 3d3a7fe717f..1ba5087d407 100644
--- a/utils/kamctl/CMakeLists.txt
+++ b/utils/kamctl/CMakeLists.txt
@@ -6,9 +6,7 @@ project(kamailio_utils)
# "${basedir}") endif()
set(KAMCTL_TMP_DIR "${CMAKE_BINARY_DIR}/kamctltmp")
-message(
- STATUS "kamctltmpdir: ${KAMCTL_TMP_DIR} BINARY_DIR: ${CMAKE_BINARY_DIR}"
-)
+message(STATUS "Temporary kamctl.{db} files in : ${KAMCTL_TMP_DIR}")
file(MAKE_DIRECTORY ${KAMCTL_TMP_DIR})
@@ -17,9 +15,8 @@ set(BIN_DIR
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_SBINDIR}")
set(LIB_DIR
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${MAIN_NAME}/kamctl"
)
-set(CFG_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_SYSCONFDIR}/kamailio")
+set(CFG_DIR
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_SYSCONFDIR}/${MAIN_NAME}")
set(SHARE_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/${MAIN_NAME}")
-message(STATUS "BIN_DIR: ${BIN_DIR} LIB_DIR: ${LIB_DIR} CFG_DIR: ${CFG_DIR}")
# Install kamctl
add_custom_command(