<div dir="ltr">Just wondering if there's a nice way of getting a library target's includes but not linking to it, so I can use dlopen() on it instead. If I want to build a shared library that gets implicitly loaded by an executable, I would do this:<div><br></div><div>  mylib/CMakeLists.txt:</div><div>  add_library( mylib SHARED src/mylibmain.c src/mylibsomething.c )</div><div>  target_include_directories( mylib PRIVATE src PUBLIC inc )</div><div>  target_link_libraries( mylib png )</div><div><br></div><div>  myexe/CMakeLists.txt:</div><div>  add_executable( myexe src/main.c src/stuff.c )</div><div>  target_include_directories( myexe PRIVATE src )</div><div>  target_link_libraries( myexe PRIVATE mylib )</div><div><br></div><div>What I really want, though, is for mylib's public include dir to be accessible to myexe, but I don't want myexe to link to mylib - I'm going to load it with dlopen()/LoadLibrary(). Do I have to do something like this:</div><div><br></div><div><div>  myexe/CMakeLists.txt:</div><div>  get_property( mylibincs TARGET mylib PROPERTY INTERFACE_INCLUDE_DIRECTORIES )</div><div>  add_executable( myexe src/main.c src/stuff.c )</div><div>  target_include_directories( myexe PRIVATE src ${mylibincs} )</div><div>  #target_link_libraries not necessary</div></div><div><br></div><div><br></div><div>This must be really simple, but I can't seem to find anything about it on the cmake wikis or through google. There's a very old post from 2006 or so (pre target properties, it uses include_directories()). </div><div><br></div></div>