Module: kamailio
Branch: master
Commit: ac74fd01fade29b433eb45966a0ed5e222614318
URL:
https://github.com/kamailio/kamailio/commit/ac74fd01fade29b433eb45966a0ed5e…
Author: Xenofon Karamanos <xk(a)gilawa.com>
Committer: Xenofon Karamanos <xk(a)gilawa.com>
Date: 2024-12-12T11:19:48Z
cmake: Generete parser files in build folder
---
Modified: src/CMakeLists.txt
Modified: src/core/CMakeLists.txt
---
Diff:
https://github.com/kamailio/kamailio/commit/ac74fd01fade29b433eb45966a0ed5e…
Patch:
https://github.com/kamailio/kamailio/commit/ac74fd01fade29b433eb45966a0ed5e…
---
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 867f7508f26..30f80f0db32 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -70,8 +70,9 @@ if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.20)
cmake_policy(SET CMP0118 NEW)
else()
set_source_files_properties(
- ${CMAKE_SOURCE_DIR}/src/core/lex.yy.c ${CMAKE_SOURCE_DIR}/src/core/cfg.tab.c
- ${CMAKE_SOURCE_DIR}/src/core/cfg.tab.h PROPERTIES GENERATED TRUE
+ ${CMAKE_CURRENT_BINARY_DIR}/core/lex.yy.c
+ ${CMAKE_CURRENT_BINARY_DIR}/core/cfg.tab.c
+ ${CMAKE_CURRENT_BINARY_DIR}/core/cfg.tab.h PROPERTIES GENERATED TRUE
)
endif()
# -----------------------
@@ -98,9 +99,11 @@ add_subdirectory(modules)
# from their own CMakeLists.txt
# Module subdiretory does not contribute to the Kamailio executable.
target_sources(
- kamailio PRIVATE ${kamailio_SRC_FILES} ${CMAKE_SOURCE_DIR}/src/core/lex.yy.c
- ${CMAKE_SOURCE_DIR}/src/core/cfg.tab.c
+ kamailio
+ PRIVATE ${kamailio_SRC_FILES} ${CMAKE_CURRENT_BINARY_DIR}/core/lex.yy.c
+ ${CMAKE_CURRENT_BINARY_DIR}/core/cfg.tab.c
)
+target_include_directories(kamailio PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/core)
# Debuggng the sources of kamailio executable.
# get_property(
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index e72cca6fa61..cbda772884a 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -20,19 +20,19 @@ find_package(BISON REQUIRED)
# Generate lex.yy.c from cfg.lex
add_custom_command(
- OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/lex.yy.c
- COMMAND ${FLEX_EXECUTABLE} -o ${CMAKE_CURRENT_SOURCE_DIR}/lex.yy.c
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lex.yy.c
+ COMMAND ${FLEX_EXECUTABLE} -o ${CMAKE_CURRENT_BINARY_DIR}/lex.yy.c
${CMAKE_CURRENT_SOURCE_DIR}/cfg.lex
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cfg.lex
- ${CMAKE_CURRENT_SOURCE_DIR}/cfg.tab.h
+ ${CMAKE_CURRENT_BINARY_DIR}/cfg.tab.h
COMMENT "Generating lex.yy.c from cfg.lex"
)
# Generate cfg.tab.c and cfg.tab.h from cfg.y
add_custom_command(
- OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/cfg.tab.c
- ${CMAKE_CURRENT_SOURCE_DIR}/cfg.tab.h
- COMMAND ${BISON_EXECUTABLE} -d -b cfg -o ${CMAKE_CURRENT_SOURCE_DIR}/cfg.tab.c
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cfg.tab.c
+ ${CMAKE_CURRENT_BINARY_DIR}/cfg.tab.h
+ COMMAND ${BISON_EXECUTABLE} -d -b cfg -o ${CMAKE_CURRENT_BINARY_DIR}/cfg.tab.c
${CMAKE_CURRENT_SOURCE_DIR}/cfg.y
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cfg.y
COMMENT "Generating cfg.tab.c and cfg.tab.h from cfg.y"
@@ -41,9 +41,9 @@ add_custom_command(
# Add custom target for generating the 3 source files mentioned above
add_custom_target(
GenerateParser ALL
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lex.yy.c
- ${CMAKE_CURRENT_SOURCE_DIR}/cfg.tab.c
- ${CMAKE_CURRENT_SOURCE_DIR}/cfg.tab.h
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/lex.yy.c
+ ${CMAKE_CURRENT_BINARY_DIR}/cfg.tab.c
+ ${CMAKE_CURRENT_BINARY_DIR}/cfg.tab.h
COMMENT "Generating parser source files"
)