Third-party libraries in CMake

I use cmake for my project, but I have another library in a subdirectory (say lib /) that uses a simple Makefile. How can I get CMake to run the Makefile in lib as part of the build process?

+7
build cmake makefile
source share
2 answers

The solution is to use:

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

+5
source share

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

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

Else

you need to use the 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 !!!

+2
source share

All Articles