2

I have a project with cmake as its build system. I want project's dependencies to be pulled as git submodules and their build process to be integrated into one cmake build process for whole project.

If a dependency is also using cmake as it's build system it's pretty much easy - using ExternalProject_Add. I was able to integrate such a dependency already (SDL).

However what should I do if my dependency don't use cmake? In my case those would be lua and bgfx for example. What are possible ways to organize everything with such case in mind? Should I write and maintain CMakeLists.txt files for such projects myself, with somewhat ugly source references like ../../bgfx/src/main.cpp for each such dependency and making a folder for each such CMakeLists.txt file to refer to this folder with ExternalProject_Add? Or there might be some other ways?

tshepang
  • 12,111
  • 21
  • 91
  • 136
rotanov
  • 87
  • 7
  • `ExternalProject_Add` allows to specify custom commands for configure(`CONFIGURE_COMMAND`), build(`BUILD_COMMAND`) and install(`INSTALL_COMMAND`) steps. Did you try to use this feature? – Tsyvarev Jul 28 '15 at 13:58
  • @Tsyvarev you mean to execute build systems other than cmake over those external projects? Yeah I think that is a possibility, but I think that may require me to write `ExternalProject_Add` for each OS, since I want to build project on windows and GNU/Linux. – rotanov Jul 28 '15 at 14:22
  • CMake is not a magic tool, which can extract build options from package's README:) As lua requires different build options for Windows and Linux, you should check OS and provide corresponded build command. Actually, almost every cmake module which integrates 3d-party crossplatform software with CMake checks OS. – Tsyvarev Jul 28 '15 at 16:47
  • 1
    Since it is not four and a half years later... did you manage to solve this? I'm now facing the same problem and wish to have some kind of general cmake solution to incorporate git submodules into a cmake build that are build with autotools. The information such function/macro needs is: the name of the subdirectory the fetch url and branch to use, the command(s) to run after first clone (autogen.sh), and the configure arguments. Maybe also the build command (make) and/or environment variables that need to be set; everything should have defaults that can be overwritten. – Carlo Wood Dec 24 '19 at 22:26
  • 1
    @CarloWood iirc I wrote some kind of external CMakeLists.txt files for 3rd party projects. You can look at https://github.com/rotanov/engine/tree/master/3rd -- here are submodules, and https://github.com/rotanov/engine/tree/master/cmake -- all cmake files are here. It worked back then. Not sure if it still works. – rotanov Jan 16 '20 at 14:36
  • Hmm ok - so you cheated. You just wrote a CMakeLists.txt file for those projects (although outside their source tree). I'm looking for actually building it with their configure.ac and Makefile.am because they are too complex to write a CMakeLists.txt file for. Note that I did this in the mean time, here: https://github.com/CarloWood/evio/blob/master/protocol/CMakeLists.txt#L68 and everything around it, including a few bash scripts. See https://github.com/CarloWood/evio/tree/master/protocol which builds the submodule matrixssl. – Carlo Wood Jan 16 '20 at 15:30

0 Answers0