Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell CMake to download external projects before compiling my sources

Tags:

cmake

I have my own code which depends on third-party libraries, such as yaml-cpp for example. I want to download these third-party libraries before compiling my own sources. However, I don't manage to do it with CMake.

I managed to download yaml-cpp like this:

ExternalProject_Add(yaml-cpp
                URL https://yaml-cpp.googlecode.com/files/yaml-cpp-0.5.1.tar.gz
                PREFIX ${CMAKE_CURRENT_BINARY_DIR}/yaml-cpp
                CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>

But when I type

cmake ..
make

my sources are compiled before. Actually, yaml-cpp is downloaded at the very last step.

Do you know how to tell CMake to download third-party libraries at the very first building step?

Thanks!

like image 517
Aleph Avatar asked Mar 06 '15 13:03

Aleph


1 Answers

ExternalProject creates a target. You can make your first target, e.g. your library, dependent from that target. Then it gets downloaded before you start building your library.

like image 70
usr1234567 Avatar answered Oct 01 '22 19:10

usr1234567