Hello,

Regarding modules:

Currently only a subset of modules (those required for the default config to work without any extra defs) have CMakeLists.txt. I tried to follow the groups mechanism that was on Makefiles, see (modules/groups.cmake). We provide a list of names of modules and when CMake tries to config modules, it discovers them based on sub-folders with same name in the modules folder but only those that have a CMakeLists.txt and the others are ignored. In my dev environment, i produced all modules CMakelists.txt but i haven't pushed them since they most definitely need a closer look (review their dependencies, extra targets and so on). Also groups.cmake requires some cleaning and refinement and but otherwise, it tries to mimic the Makefile.groups.

Regarding Kamailio binary, this can be fixed so it's produced in the build/src/.

Regarding kamcmd, i can see it has its own Makefile, that it's included in the ctl module Makefile. That is how it will probably work in cmake as well. We will create a CmakeLists.txt for kamcmd that will be included in the ctl module Cmakelists. As you can see even the pushed CMakelists.txt of modules are not really one-to-one match with their respective Makefiles yet. They will need some review even if most of them have no extra dependencies or extra installs. 

Yes each CMakefile can have as many extra targets as its required with a simple add_custom_target(target_name) command. See kamctl CMakeLists.txt where i defined some targets about installing specific components of kamailio config files instead of building everything. 

I will push some more commits about the modules and add some targets like on TLS, to demonstrate.

Regarding some of benefits,
Drawback:
Of course, any other member can jump in the discussion and chime in,

Thanks,
Xenofon



From: Daniel-Constantin Mierla <miconda@gmail.com>
Sent: Friday, June 28, 2024 17:40
To: Xenofon Karamanos <xk@gilawa.com>; Kamailio (SER) - Development Mailing List <sr-dev@lists.kamailio.org>
Subject: Re: [sr-dev] Re: Initial Support for CMake in Kamailio - Feedback Needed!
 

Hello,


I noticed that you pushed several commits and tried again, it compiles now, but not all the modules. Is it a place where module names (or paths) have to be added or it should auto-discover based on sub-folders inside src/modules/ ?


A couple of other remarks:


  - the kamailio binary seems to be now inside src/core/, not inside src/ as it is now with the old Makefiles

  - the kamcmd is not compiled, it is done by ctl module with the old Makefiles, which seems to be compiled also with cmake


Some modules have their own local Makefile targes, like tls which has one for deploying tls.cfg and one for deploying self-signed certificates. Or, mentioned already above, ctl which compiles and deploys kamcmd. Does the new system allow a similar mechanism? Also, the old Makefiles allowed grouping modules mainly for packaging, can this be done as well with cmake?


Maybe others can jump in the discussion and add their remarks, I am not familiar with cmake, its benefits or drawbacks...


Cheers,
Daniel


On 25.06.24 15:51, Xenofon Karamanos wrote:
Hey Daniel, 

Thanks for the feedback.

You are right, since i was just trying to set CMake up, i didn't include the options necessary for aarch64 arch build steps only for x86_64.

I pushed some new commits including the one necessary to build for aarch64, modules and docs. 

I can now cross-compile to aarch64 from x86_64 system now as well. 

A big note is that no additional compile options are given nor in the Makefiles nor in CMakelists (look Makefile.defs. there are no options for aarch64). Is this intentional or not implemented by mistake?

If you can give it another try, it would be appreciated. If you have any more troubles just let me know.

Thanks,
Xenofon
Kamailio - The Open Source SIP Server for large VoIP and real-time communication platforms - - kamailio/kamailio
github.com


From: Daniel-Constantin Mierla <miconda@gmail.com>
Sent: Tuesday, June 25, 2024 14:41
To: Kamailio (SER) - Development Mailing List <sr-dev@lists.kamailio.org>
Cc: Xenofon Karamanos <xk@gilawa.com>
Subject: Re: [sr-dev] Re: Initial Support for CMake in Kamailio - Feedback Needed!
 
Hello,

got a bit of time to look at it, but it fails on Ubuntu arm64:

$ uname -a
Linux u2204 5.15.0-107-generic #117-Ubuntu SMP Mon Apr 29 14:37:09 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux

This is my usual development environment lately and it compiles fine with the usual Makefiles. The errors (after: mkdir build, cd build, cmake ..)​ are:

$ make
[  0%] Generating cfg.tab.c and cfg.tab.h from cfg.y
[  0%] Generating lex.yy.c from cfg.lex
[  0%] Built target GenerateParser
[  0%] Building C object src/core/CMakeFiles/kamailio.dir/action.c.o
cc: error: unrecognized command-line option ‘-m64’
cc: error: unrecognized command-line option ‘-minline-all-stringops’
make[2]: *** [src/core/CMakeFiles/kamailio.dir/build.make:88: src/core/CMakeFiles/kamailio.dir/action.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:887: src/core/CMakeFiles/kamailio.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

I am not familiar with cmake and no much time to dig in at this moment, so I thought to just report it.

Cheers,
Daniel

On 17.06.24 09:49, Xenofon Karamanos via sr-dev wrote:
Hey Daniel and all, 

I have updated the branch to compile some of the modules and libs, so we can have a fully runnable default configuration.

Same steps as before:
mkdir build && cd build
Then run CMake for the configuration and any options you would like.
cmake ..​  (you can also then use  ccmake .​    for a visual of the offered options).
I am currently using  the following commands to have it installed in build/kam-6 folder but you of course can use any prefix and definitions you like (hopefully):
      cmake -DCMAKE_INSTALL_PREFIX=./kam-6 -DINCLUDE_MODULES="async" ..​  
Build and install using make
     make -j4​ install

There should now be a kamailio​ binary in build/kam-6/sbin that you can run directly ./sbin/kamailio​. 
Also, you have to make sure the build/kam-6/var/run folder exists so it can run normally even no file is required to be create there with the default config.
Any reviews and feedback is deeply appreciated,

Thanks
Xenofon 



From: Xenofon Karamanos <xk@gilawa.com>
Sent: Wednesday, June 12, 2024 11:09
To: Kamailio (SER) - Development Mailing List <sr-dev@lists.kamailio.org>; miconda@gmail.com <miconda@gmail.com>
Subject: Re: [sr-dev] Initial Support for CMake in Kamailio - Feedback Needed!
 
Hey Daniel,

Thank you for your taking the time to provide feedback.
CMake is the de-facto "build" system (it's actually a generator for buildsystems like make, ninja and so on) for C and C++ programs as far as i know. There are some alternatives, like Meson i think, that i am really not familiar with and not seen it in the wild enough.
So to answer your questions:
      - CMake currently builds only the files found in the src/core folder. For the modules, we will probably have to adopt each module separately to CMake. Not something difficult, i would say but there are lots of modules. Maybe you can suggest some modules we want to get it up and running for some initial set-up and to see how to properly adjust the workflow to CMake.
      - Most probably yes, i have seen CMake build docs with doxygen. I am not really familiar with our docs generator but i think as long as we use a well-know generator, we can have seperate targets for generating the Docs and probably custom files from the xml like Readme files.
      - At the end of the CMake integration, there should be no need for any of the Makefiles. CMake will generate the appropriate ones for make, ninja, Visual Studio or whatever build you choose (as long as it's supported by CMake) and use that for building the targets. At this point also, no makefiles  from repositort where used to build the core. When you run CMake in the build folder, it creates a new set of makefiles in there, that do the job.

I hope these clear some of your questions. If you need any more information or have any suggestions regarding modules/docs please let me know,
Xenofon


From: Daniel-Constantin Mierla <miconda@gmail.com>
Sent: Wednesday, June 12, 2024 09:21
To: Kamailio (SER) - Development Mailing List <sr-dev@lists.kamailio.org>
Cc: Xenofon Karamanos <xk@gilawa.com>
Subject: Re: [sr-dev] Initial Support for CMake in Kamailio - Feedback Needed!
 

Hello,


thanks for spending time in this direction! Makefiles were for long supposed to get a review.


I am not familiar for CMake, but if it is considered a good option, I am fine with it. For now, a few questions:


  - is it already building the modules as well, or only the core for now?

  - can it be used also for building the docs (e.g., README files for modules)?

  - any of the old Makefiles need to be kept, or all of them will be replaced?


Cheers,
Daniel


On 11.06.24 18:11, Xenofon Karamanos via sr-dev wrote:
Hello all,

I've started working on integrating CMake as a build system for the Kamailio. This is an initial step towards potentially offering CMake as an alternative to the current build system across the entire Kamailio project.
Right now, the CMake configuration is quite basic and covers only the core module. It offers limited options described in Makefile.defs that are required to build the core module. 
Some notes regarding the definitions can be found also in the CMakelists.notes that made the build failed and maybe it's good to remove from current Makefiles as well, if i am not wrong.
Before we consider extending it to other modules and components, i would like some feedback whether you find it useful at all.
You can find the initial CMake files in the cmake​ branch. Please take a look and feel free to share any feedback or suggestions. Your input will be much appreciated and nessecary if we want CMake as a build system.

For anyone wanting to try and compile using cmake, here are some basic instructions on how to get you started.
Checkout the cmake​ branch of kamailio repo.
Create a new folder, let's call it build. 
mkdir build && cd build
Then run CMake for the configuration
cmake ..​ (you can also then use  ccmake .​    for a visual of the offered options)
Build and install using make
      make -j4​ 
      make install
OR
Build and install using cmake
      cmake --build . 
      cmake --install . 

You can of course use the CMake variable CMAKE_INSTALL_PREFIX​ to change the installation paths as follows and of course other preprocessor defintions:
      cmake -DCMAKE_INSTALL_PREFIX=./kamailio-cmake -DUSE_TCP=0 ..​ 
This will install it in the build/kamailio-cmake​ folder but fails to build because USE_TCP is required for kamailio to build (Check CMakelists.notes).​

Thank you all for your continuous contributions and support. Looking forward to hearing your thoughts and insights.
Best regards,
Xenofon
https://github.com/kamailio/kamailio/tree/cmake
Kamailio - The Open Source SIP Server for large VoIP and real-time communication platforms - - GitHub - kamailio/kamailio at cmake
github.com


_______________________________________________ Kamailio (SER) - Development Mailing List To unsubscribe send an email to sr-dev-leave@lists.kamailio.org
-- Daniel-Constantin Mierla (@ asipto.com) twitter.com/miconda -- linkedin.com/in/miconda Kamailio Consultancy, Training and Development Services -- asipto.com

_______________________________________________ Kamailio (SER) - Development Mailing List To unsubscribe send an email to sr-dev-leave@lists.kamailio.org


-- Daniel-Constantin Mierla (@ asipto.com) twitter.com/miconda -- linkedin.com/in/miconda Kamailio Consultancy, Training and Development Services -- asipto.com
-- Daniel-Constantin Mierla (@ asipto.com) twitter.com/miconda -- linkedin.com/in/miconda Kamailio Consultancy, Training and Development Services -- asipto.com