On Mon, Oct 14, 2019, at 9:13 AM, David Aldrich wrote:
> Hi

> 

> I am trying to convert a large software project from makefiles to CMake. The 
> project is organised as a set of shared ‘star’ libraries, linked to a static 
> ‘kernel’ library. The current directory arrangement is:

> 

> |--stars

> | |-- star1_lib

> | |-- source files

> | |-- makefile

> | |-- star2_lib

> | |-- source files

> | |-- makefile

> | |-- solibs

> | |-- Release

> | |-- <star>.so files

> |

> |--kernel

> | |-- source files

> | |-- makefile

> | |-- Release

> | |-- kernel.a

> |

> |--application

>  |-- makefile

>  |-- Release

>  |-- myapp.exe

> 

> In high-level terms, how could I implement this using CMake, such that 
> invoking ‘make’ in directory ‘application’ invokes a make of each shared and 
> static library, and links them to form ‘myapp.exe’?

> 

> (I understand the basics of CMake, the issue here is how to handle the make 
> of source code and libraries spread across a directory hierarchy).

> 

> Best regards

> 

> David

> 

> 
add_subdirectory() can accept relative paths to outside the "root" source tree.
So the main CMakeLists.txt would be located in ./application.
Then do:
 add_subdirectory(../kernel kernel)
add_subdirectory(../stars/stars1_lib stars1_lib)

./kernel/CMakeLists.txt would list it's files, and etcetera.

I've use this method in the past for handling applications that are meant to 
target Windows, Linux, and embedded systems.
Then by using variables to determine with platform / target ertain kernel and 
library characteristics are used.
Everything is built in the build directory for that particular platform / 
target.
This allows for app_target1, app_target2, app_target3, ..., build directories 
to be totally independent.

--
F
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

Reply via email to