Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Third party libraries in CMake

I am using cmake for my project, but I have another library in a subdirectory ( say lib/ ) which uses a plain Makefile. How do I instruct CMake to run the Makefile in lib as part of the build process?

like image 287
Nikhil Avatar asked Sep 28 '09 06:09

Nikhil


2 Answers

The solution is to use:

execute_process ( COMMAND make WORKING_DIRECTORY ${project_SOURCE_DIR}/path/to/lib )

like image 101
Nikhil Avatar answered Nov 02 '22 23:11

Nikhil


If your /lib contains its own CMakeLists.txt, just use the add_subdirectory command:

add_subdirectory(/path/of/your/lib/that/contains/CMakeLists.txt)

Else

you have to use exec_program command:

exec_program(script.sh)

where script.sh is

#!/bin/sh
cd /path/of/your/lib/ && make

do not forget

chmod +x script.sh

In my opinion, the first solution is better !!!

like image 30
Nadir SOUALEM Avatar answered Nov 03 '22 00:11

Nadir SOUALEM