[CMake] Generate headers and inherit include_directories

Michael Ellery mellery451 at gmail.com
Thu Oct 5 12:33:34 EDT 2017


> On Oct 5, 2017, at 3:50 AM, Nagy-Egri Máté Ferenc <csiga.biga at aol.com> wrote:
> 
> Hi Michael!
> 
> This is what I wanted to do (only relevant parts showing):
> 
> /// top-level CMakeLists.txt
> add_subdirectory(Gripper)
> add_subdirectory(examples)
> 
> 
> /// Gripper/CmakeLists.txt
> set(RESULT ${CMAKE_CURRENT_BINARY_DIR}/inc/Gripper/stl/stlYlms_dynamic.hpp)
> add_custom_command(COMMAND ... ARGS ...
>                   OUTPUT ${RESULT})
> add_custom_target(Ylms
>                   DEPENDS ${RESULT})
> 
> # What comes from HERE
> add_library(Gripper::Ylms INTERFACE IMPORTED GLOBAL)
> target_include_directories(Gripper::Ylms INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/inc
>                                                    ${CMAKE_CURRENT_BINARY_DIR}/inc)
> add_dependencies(Gripper::Ylms Ylms)
> # to HERE? (Note, example does not work)
> 
> /// examples/CmakeLists.txt
> add_executable(example1 main.cpp)
> 
> target_link_libraries(example1 Gripper::Ylms)
> 
> When specifying Gripper::Ylms as a link target for example1, I would like to pick up both the dependency of Ylms being processed first and also the include directory marking the location of the generated header file.
> 
> Note, the closes I got was using
> 
> set_target_properties (Gripper::Ylms PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/inc ${CMAKE_CURRENT_BINARY_DIR}/inc")
> 
> instead of
> 
> target_include_directories(Gripper::Ylms INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/inc
>                                                    ${CMAKE_CURRENT_BINARY_DIR}/inc)
> 
> because set_target_properties wouldn’t let me specify multiple entries, but target_include_directories is not allowed on IMPORTED targets (but simple INTERFACE libraries cannot be global)… no combination of commands seem to work.
> 

I think “IMPORTED” on your header library might be part of the problem…I would remove that.  I have an example I will send you privately that does what you want I think…

-Mike


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <http://public.kitware.com/pipermail/cmake/attachments/20171005/b6a5dd10/attachment.sig>


More information about the CMake mailing list