Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get variables and options from external project

Tags:

cmake

I'd like to know how to get variables and options from an external project. For example, I'm using ExternalProject_Add to add a library that my project depends on, the thing is that this dependency has some variables and options - some of them are on by default - I'm wondering, how to get them from my CMakeLists.txt.

like image 303
Secafo Avatar asked Oct 30 '22 20:10

Secafo


1 Answers

All commands related with ExternalProject_Add are executed at build stage, but your CMakeLists.txt is interpreted at configure stage, when external library hasn't configured yet, so its variables and options are not defined.

More general, cmake variable from the external project can be extracted in two cases:

  1. External project is included into main project via add_subdirectory.
  2. External project provides packaging file, which define needed variable. In that case external project should be installed before or at configuration stage of main project. You can read about packaging in CMake tutorial.
like image 124
Tsyvarev Avatar answered Jan 04 '23 14:01

Tsyvarev