0

I have the target Hello, which depends on Providers, both in the same build tree. I need to access the INCLUDE_DIRECTORIES property of Providers while configuring Hello. I am aware CMake handles this internally, but I need all INCLUDE_DIRECTORIES, including those of dependencies, for an external script.

My build tree:

-src
  -Providers
    -src
      -HelloProvider.cpp
      -WorldProvider.cpp
    -include/Providers
       -HelloProvider.h
       -WorldProvider.h
    -CMakeLists.txt
  -Hello
    -hello.cpp
    -CMakeLists.txt
  -CMakeLists.txt

Providers/CMakeLists.txt:

project(Providers VERSION 1.0 LANGUAGES CXX)

add_library(Providers src/HelloProvider.cpp src/WorldProvider.cpp)

target_include_directories(Providers
    PUBLIC
        include/Providers
)

Hello/CMakeLists.txt:

project(Hello VERSION 1.0 LANGUAGES CXX )

add_executable(Hello hello.cpp)

target_link_libraries(Hello
    PRIVATE
        Providers
)

In the Hello target I want to do something like

get_target_property(PROVIDERS_INCLUDES Providers INTERFACE_INCLUDE_DIRECTORIES)
message("calling doSomethingVeryImportant.py with ${PROVIDERS_INCLUDES}")
execute_process(COMMAND py doSomethingVeryImportant.py ${PROVIDERS_INCLUDES})

and expect an output of

calling doSomethingVeryImportant.py with include/Providers

but I get

get_target_property() called with non-existent target "Providers"

I think I need to import Providers into Hello. How do I do this, preferably in a way that scales for an arbitrary number of dependencies?

jai
  • 81
  • 1
  • 1
  • 8
  • Welcome to Stack Overflow. The CMake target dependencies are only evaluated on generation time and configuration time. – Florian Jun 21 '18 at 11:17
  • Thanks for pointing me to the duplicate, this was very helpful – jai Aug 13 '18 at 12:46

0 Answers0