cmake include dependencies using find_package from installed targetCMake: How do I add a function to an installed config?How to build and install cmake targets only if the other targets depend on them?Cmake install target triggeringcmake add_library, followed by install library destinationCMake project shared dependenciesinstalling a cmake target in two different foldersDepending on the INSTALL target of a CMake External ProjectCMake target depends on installed targetExecute output of cmake target as dependency for anotherInstall shared libraries only if required with cmakeAre exported (installed) cmake targets distributable?

How would I as a DM create a smart phone-like spell/device my players could use?

What is my malfunctioning AI harvesting from humans?

Is refreshing multiple times a test case for web applications?

In a topological space if there exists a loop that cannot be contracted to a point does there exist a simple loop that cannot be contracted also?

Is TA-ing worth the opportunity cost?

How can I iterate this process?

How many different ways are there to checkmate in the early game?

What happen to those who died but not from the snap?

Is it incorrect to write "I rate this book a 3 out of 4 stars?"

What game uses dice with sides powers of 2?

Is it okay for a ticket seller to grab a tip in the USA?

Different inverter (logic gate) symbols

Does a code snippet compile? Or does it get compiled?

Christian apologetics regarding the killing of innocent children during the Genesis flood

MinionPro is erroneous

Generating function of ordered partitions

Why does Intel's Haswell chip allow FP multiplication to be twice as fast as addition?

Which I-94 date do I believe?

Understanding the point of a kölsche Witz

Should I ask for permission to write an expository post about someone's else research?

How does "Te vas a cansar" mean "You're going to get tired"?

Dropdowns & Chevrons for Right to Left languages

AsyncDictionary - Can you break thread safety?

Why did Gandalf use a sword against the Balrog?



cmake include dependencies using find_package from installed target


CMake: How do I add a function to an installed config?How to build and install cmake targets only if the other targets depend on them?Cmake install target triggeringcmake add_library, followed by install library destinationCMake project shared dependenciesinstalling a cmake target in two different foldersDepending on the INSTALL target of a CMake External ProjectCMake target depends on installed targetExecute output of cmake target as dependency for anotherInstall shared libraries only if required with cmakeAre exported (installed) cmake targets distributable?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I am currently migrating a couple of CodeBlock projects to use CMake and Visual Studio Code. I am facing an issue related to the include directory not being known by the consuming target.



I followed a guide so far as I was not aware of the "modern CMake way" using targets at all until yet. Mainly referring to here: https://rix0r.nl/blog/2015/08/13/cmake-guide/ and the official CMake docs.
There are two libraries (.so). One of them needs to other one to be there (build) when it get's loaded by the application later on.
I am not sure if everything is even intended to work like I assume it to work so I will just continue with the code and the expected result.



Library A (which is needed by Library B) has following CMakeLists



cmake_minimum_required(VERSION 3.0.0)
project(A)

set(SOURCE somesource.c)

include(GNUInstallDirs)

find_package(JNI REQUIRED)
add_library(JNI SHARED IMPORTED)
set_property(TARGET JNI PROPERTY INTERFACE_INCLUDE_DIRECTORIES $ENVJAVA_HOME/include $ENVJAVA_HOME/include/linux)
set_property(TARGET JNI PROPERTY IMPORTED_LOCATION $JNI_LIBRARIES)

add_library($PROJECT_NAME SHARED $SOURCE)

target_include_directories($PROJECT_NAME
PUBLIC
$<BUILD_INTERFACE:$CMAKE_CURRENT_SOURCE_DIR/include $ENVJAVA_HOME/include $ENVJAVA_HOME/include/linux>
$<INSTALL_INTERFACE:include>
)

install(DIRECTORY include/ DESTINATION $CMAKE_INSTALL_INCLUDEDIR)

install(TARGETS $PROJECT_NAME EXPORT $PROJECT_NAMEConfig
LIBRARY DESTINATION $CMAKE_INSTALL_LIBDIR)

install(EXPORT $PROJECT_NAMEConfig DESTINATION $CMAKE_INSTALL_PREFIX/cmake)


Notice I only have one include file which is public and located in "include", so its used by the library itself but should also be part of the install interface
used by the "consuming" target.



Library B (which uses Library A and its header)



cmake_minimum_required(VERSION 3.0)
project(B)

set(SOURCE somesource.c)

add_library($PROJECT_NAME SHARED $SOURCE)

find_package(A REQUIRED)

target_include_directories($PROJECT_NAME
PRIVATE $PROJECT_SOURCE_DIR
)


So in Library B I assume that I do not need to add the include_directories from Library A again. This is why I actually did the target approach so there is no need to keep track of linker/include dependencies. "find_package" should handle these on it's own right? I do not link neither because it is a shared object, not a static library.
Both libraries use the same CMAKE_INSTALL_PREFIX ofc and library A has been installed (make install). I double-checked on this. In case of using a different prefix or not doing the install, CMake already complains about not finding it.



So considering the issue now:
Within a source file from library B, I am using



#include <libcobjava.h>


resulting in an error when building as the compiler complains about "No such file or directory" Am I missing something? The file is definitely located at
CMAKE_INSTALL_PREFIX/include.



Apart from that as I am still new to CMake: Is this even the way you would do things if you own all the source?



Edit: Some more details on the follow-up issue as discussed in comments. Library A is libcobjava.



First I had the target_include_directories part as following (including the path where jni.h is located in $<INSTALL_INTERFACE:)



target_include_directories($PROJECT_NAME 
PUBLIC
$<BUILD_INTERFACE:$CMAKE_CURRENT_SOURCE_DIR/include $ENVJAVA_HOME/include $ENVJAVA_HOME/include/linux>
$<INSTALL_INTERFACE:include $ENVJAVA_HOME/include $ENVJAVA_HOME/include/linux>
)


results in following error:



[cmake] Configuring done
[cmake] CMake Error in CMakeLists.txt:
[cmake] Target "libcobjava" INTERFACE_INCLUDE_DIRECTORIES property contains path:
[cmake]
[cmake] "/media/rbs42/data/Gebos/RBS42/tools/libcobjava/$_IMPORT_PREFIX/include"
[cmake]
[cmake] which is prefixed in the source directory.
[cmake]
[cmake]
[cmake] Generating done
[cms-driver] Error during CMake configure: [cmake-server] Failed to compute build system.


This is why I removed $ENVJAVA_HOME/include $ENVJAVA_HOME/include/linux> from $<INSTALL_INTERFACE again.



The actual error I am getting in library B now is during compiling:



[build] /media/rbs42/data/rbs42/usr/include/libcobjava.h:1:10: fatal error: jni.h: No such file or directory
[build] #include <jni.h>


because library B does not have the include directories from library A that are not included in the $<INSTALL_INTERFACE. This is what one would expect. And thats the reason I added the following code before in library A.



set_property(TARGET JNI PROPERTY INTERFACE_INCLUDE_DIRECTORIES $ENVJAVA_HOME/include $ENVJAVA_HOME/include/linux)


which I assumed is taking care of propagating the include dependencies from library A to the "consuming" library B, although they are not part of the $<INSTALL_INTERFACE.










share|improve this question





















  • 2





    In the project B you have find_package(A REQUIRED) but never uses results of this call. It should be target_link_libraries(B A) for link the B library with A and "consume" its include directories.

    – Tsyvarev
    Mar 27 at 8:42












  • Thanks! I was misunderstanding target_link_libraries. That fixed the issue. However, now I get an error about a missing include library A uses (not part of the public header) in library B. More specific it is JNI which is not a project I have the source/cmake for. I tried adding find_package(JNI REQUIRED) add_library(JNI SHARED IMPORTED) set_property(TARGET JNI PROPERTY INTERFACE_INCLUDE_DIRECTORIES $JNI_INCLUDE_DIRS) set_property(TARGET JNI PROPERTY IMPORTED_LOCATION $JNI_LIBRARIES) (similar to the sample) in library A, but this did not solve the issue unfortunately.

    – Paxi1337
    Mar 27 at 9:50











  • Check content of $JNI_INCLUDE_DIRS, and check that given directory actually contains required headers.

    – Tsyvarev
    Mar 27 at 10:04











  • I made sure and using the hardcoded path again. The path is used in lib A for building and working fine there so I can exclude the path for being incorrect. I updated the CMakeLists.txt for Library A. Library B is unchanged. Library B now complains about #include <jni.h>, which is the first line in headerFromA.hpp (which was unknown before). Thanks for your time, would be really glad if we can work this out.

    – Paxi1337
    Mar 27 at 10:22












  • I am not sure, but construction $<BUILD_INTERFACE:XXX> should be repeated for every include directory; you cannot use single construction for several include directories.

    – Tsyvarev
    Mar 27 at 11:03

















1















I am currently migrating a couple of CodeBlock projects to use CMake and Visual Studio Code. I am facing an issue related to the include directory not being known by the consuming target.



I followed a guide so far as I was not aware of the "modern CMake way" using targets at all until yet. Mainly referring to here: https://rix0r.nl/blog/2015/08/13/cmake-guide/ and the official CMake docs.
There are two libraries (.so). One of them needs to other one to be there (build) when it get's loaded by the application later on.
I am not sure if everything is even intended to work like I assume it to work so I will just continue with the code and the expected result.



Library A (which is needed by Library B) has following CMakeLists



cmake_minimum_required(VERSION 3.0.0)
project(A)

set(SOURCE somesource.c)

include(GNUInstallDirs)

find_package(JNI REQUIRED)
add_library(JNI SHARED IMPORTED)
set_property(TARGET JNI PROPERTY INTERFACE_INCLUDE_DIRECTORIES $ENVJAVA_HOME/include $ENVJAVA_HOME/include/linux)
set_property(TARGET JNI PROPERTY IMPORTED_LOCATION $JNI_LIBRARIES)

add_library($PROJECT_NAME SHARED $SOURCE)

target_include_directories($PROJECT_NAME
PUBLIC
$<BUILD_INTERFACE:$CMAKE_CURRENT_SOURCE_DIR/include $ENVJAVA_HOME/include $ENVJAVA_HOME/include/linux>
$<INSTALL_INTERFACE:include>
)

install(DIRECTORY include/ DESTINATION $CMAKE_INSTALL_INCLUDEDIR)

install(TARGETS $PROJECT_NAME EXPORT $PROJECT_NAMEConfig
LIBRARY DESTINATION $CMAKE_INSTALL_LIBDIR)

install(EXPORT $PROJECT_NAMEConfig DESTINATION $CMAKE_INSTALL_PREFIX/cmake)


Notice I only have one include file which is public and located in "include", so its used by the library itself but should also be part of the install interface
used by the "consuming" target.



Library B (which uses Library A and its header)



cmake_minimum_required(VERSION 3.0)
project(B)

set(SOURCE somesource.c)

add_library($PROJECT_NAME SHARED $SOURCE)

find_package(A REQUIRED)

target_include_directories($PROJECT_NAME
PRIVATE $PROJECT_SOURCE_DIR
)


So in Library B I assume that I do not need to add the include_directories from Library A again. This is why I actually did the target approach so there is no need to keep track of linker/include dependencies. "find_package" should handle these on it's own right? I do not link neither because it is a shared object, not a static library.
Both libraries use the same CMAKE_INSTALL_PREFIX ofc and library A has been installed (make install). I double-checked on this. In case of using a different prefix or not doing the install, CMake already complains about not finding it.



So considering the issue now:
Within a source file from library B, I am using



#include <libcobjava.h>


resulting in an error when building as the compiler complains about "No such file or directory" Am I missing something? The file is definitely located at
CMAKE_INSTALL_PREFIX/include.



Apart from that as I am still new to CMake: Is this even the way you would do things if you own all the source?



Edit: Some more details on the follow-up issue as discussed in comments. Library A is libcobjava.



First I had the target_include_directories part as following (including the path where jni.h is located in $<INSTALL_INTERFACE:)



target_include_directories($PROJECT_NAME 
PUBLIC
$<BUILD_INTERFACE:$CMAKE_CURRENT_SOURCE_DIR/include $ENVJAVA_HOME/include $ENVJAVA_HOME/include/linux>
$<INSTALL_INTERFACE:include $ENVJAVA_HOME/include $ENVJAVA_HOME/include/linux>
)


results in following error:



[cmake] Configuring done
[cmake] CMake Error in CMakeLists.txt:
[cmake] Target "libcobjava" INTERFACE_INCLUDE_DIRECTORIES property contains path:
[cmake]
[cmake] "/media/rbs42/data/Gebos/RBS42/tools/libcobjava/$_IMPORT_PREFIX/include"
[cmake]
[cmake] which is prefixed in the source directory.
[cmake]
[cmake]
[cmake] Generating done
[cms-driver] Error during CMake configure: [cmake-server] Failed to compute build system.


This is why I removed $ENVJAVA_HOME/include $ENVJAVA_HOME/include/linux> from $<INSTALL_INTERFACE again.



The actual error I am getting in library B now is during compiling:



[build] /media/rbs42/data/rbs42/usr/include/libcobjava.h:1:10: fatal error: jni.h: No such file or directory
[build] #include <jni.h>


because library B does not have the include directories from library A that are not included in the $<INSTALL_INTERFACE. This is what one would expect. And thats the reason I added the following code before in library A.



set_property(TARGET JNI PROPERTY INTERFACE_INCLUDE_DIRECTORIES $ENVJAVA_HOME/include $ENVJAVA_HOME/include/linux)


which I assumed is taking care of propagating the include dependencies from library A to the "consuming" library B, although they are not part of the $<INSTALL_INTERFACE.










share|improve this question





















  • 2





    In the project B you have find_package(A REQUIRED) but never uses results of this call. It should be target_link_libraries(B A) for link the B library with A and "consume" its include directories.

    – Tsyvarev
    Mar 27 at 8:42












  • Thanks! I was misunderstanding target_link_libraries. That fixed the issue. However, now I get an error about a missing include library A uses (not part of the public header) in library B. More specific it is JNI which is not a project I have the source/cmake for. I tried adding find_package(JNI REQUIRED) add_library(JNI SHARED IMPORTED) set_property(TARGET JNI PROPERTY INTERFACE_INCLUDE_DIRECTORIES $JNI_INCLUDE_DIRS) set_property(TARGET JNI PROPERTY IMPORTED_LOCATION $JNI_LIBRARIES) (similar to the sample) in library A, but this did not solve the issue unfortunately.

    – Paxi1337
    Mar 27 at 9:50











  • Check content of $JNI_INCLUDE_DIRS, and check that given directory actually contains required headers.

    – Tsyvarev
    Mar 27 at 10:04











  • I made sure and using the hardcoded path again. The path is used in lib A for building and working fine there so I can exclude the path for being incorrect. I updated the CMakeLists.txt for Library A. Library B is unchanged. Library B now complains about #include <jni.h>, which is the first line in headerFromA.hpp (which was unknown before). Thanks for your time, would be really glad if we can work this out.

    – Paxi1337
    Mar 27 at 10:22












  • I am not sure, but construction $<BUILD_INTERFACE:XXX> should be repeated for every include directory; you cannot use single construction for several include directories.

    – Tsyvarev
    Mar 27 at 11:03













1












1








1








I am currently migrating a couple of CodeBlock projects to use CMake and Visual Studio Code. I am facing an issue related to the include directory not being known by the consuming target.



I followed a guide so far as I was not aware of the "modern CMake way" using targets at all until yet. Mainly referring to here: https://rix0r.nl/blog/2015/08/13/cmake-guide/ and the official CMake docs.
There are two libraries (.so). One of them needs to other one to be there (build) when it get's loaded by the application later on.
I am not sure if everything is even intended to work like I assume it to work so I will just continue with the code and the expected result.



Library A (which is needed by Library B) has following CMakeLists



cmake_minimum_required(VERSION 3.0.0)
project(A)

set(SOURCE somesource.c)

include(GNUInstallDirs)

find_package(JNI REQUIRED)
add_library(JNI SHARED IMPORTED)
set_property(TARGET JNI PROPERTY INTERFACE_INCLUDE_DIRECTORIES $ENVJAVA_HOME/include $ENVJAVA_HOME/include/linux)
set_property(TARGET JNI PROPERTY IMPORTED_LOCATION $JNI_LIBRARIES)

add_library($PROJECT_NAME SHARED $SOURCE)

target_include_directories($PROJECT_NAME
PUBLIC
$<BUILD_INTERFACE:$CMAKE_CURRENT_SOURCE_DIR/include $ENVJAVA_HOME/include $ENVJAVA_HOME/include/linux>
$<INSTALL_INTERFACE:include>
)

install(DIRECTORY include/ DESTINATION $CMAKE_INSTALL_INCLUDEDIR)

install(TARGETS $PROJECT_NAME EXPORT $PROJECT_NAMEConfig
LIBRARY DESTINATION $CMAKE_INSTALL_LIBDIR)

install(EXPORT $PROJECT_NAMEConfig DESTINATION $CMAKE_INSTALL_PREFIX/cmake)


Notice I only have one include file which is public and located in "include", so its used by the library itself but should also be part of the install interface
used by the "consuming" target.



Library B (which uses Library A and its header)



cmake_minimum_required(VERSION 3.0)
project(B)

set(SOURCE somesource.c)

add_library($PROJECT_NAME SHARED $SOURCE)

find_package(A REQUIRED)

target_include_directories($PROJECT_NAME
PRIVATE $PROJECT_SOURCE_DIR
)


So in Library B I assume that I do not need to add the include_directories from Library A again. This is why I actually did the target approach so there is no need to keep track of linker/include dependencies. "find_package" should handle these on it's own right? I do not link neither because it is a shared object, not a static library.
Both libraries use the same CMAKE_INSTALL_PREFIX ofc and library A has been installed (make install). I double-checked on this. In case of using a different prefix or not doing the install, CMake already complains about not finding it.



So considering the issue now:
Within a source file from library B, I am using



#include <libcobjava.h>


resulting in an error when building as the compiler complains about "No such file or directory" Am I missing something? The file is definitely located at
CMAKE_INSTALL_PREFIX/include.



Apart from that as I am still new to CMake: Is this even the way you would do things if you own all the source?



Edit: Some more details on the follow-up issue as discussed in comments. Library A is libcobjava.



First I had the target_include_directories part as following (including the path where jni.h is located in $<INSTALL_INTERFACE:)



target_include_directories($PROJECT_NAME 
PUBLIC
$<BUILD_INTERFACE:$CMAKE_CURRENT_SOURCE_DIR/include $ENVJAVA_HOME/include $ENVJAVA_HOME/include/linux>
$<INSTALL_INTERFACE:include $ENVJAVA_HOME/include $ENVJAVA_HOME/include/linux>
)


results in following error:



[cmake] Configuring done
[cmake] CMake Error in CMakeLists.txt:
[cmake] Target "libcobjava" INTERFACE_INCLUDE_DIRECTORIES property contains path:
[cmake]
[cmake] "/media/rbs42/data/Gebos/RBS42/tools/libcobjava/$_IMPORT_PREFIX/include"
[cmake]
[cmake] which is prefixed in the source directory.
[cmake]
[cmake]
[cmake] Generating done
[cms-driver] Error during CMake configure: [cmake-server] Failed to compute build system.


This is why I removed $ENVJAVA_HOME/include $ENVJAVA_HOME/include/linux> from $<INSTALL_INTERFACE again.



The actual error I am getting in library B now is during compiling:



[build] /media/rbs42/data/rbs42/usr/include/libcobjava.h:1:10: fatal error: jni.h: No such file or directory
[build] #include <jni.h>


because library B does not have the include directories from library A that are not included in the $<INSTALL_INTERFACE. This is what one would expect. And thats the reason I added the following code before in library A.



set_property(TARGET JNI PROPERTY INTERFACE_INCLUDE_DIRECTORIES $ENVJAVA_HOME/include $ENVJAVA_HOME/include/linux)


which I assumed is taking care of propagating the include dependencies from library A to the "consuming" library B, although they are not part of the $<INSTALL_INTERFACE.










share|improve this question
















I am currently migrating a couple of CodeBlock projects to use CMake and Visual Studio Code. I am facing an issue related to the include directory not being known by the consuming target.



I followed a guide so far as I was not aware of the "modern CMake way" using targets at all until yet. Mainly referring to here: https://rix0r.nl/blog/2015/08/13/cmake-guide/ and the official CMake docs.
There are two libraries (.so). One of them needs to other one to be there (build) when it get's loaded by the application later on.
I am not sure if everything is even intended to work like I assume it to work so I will just continue with the code and the expected result.



Library A (which is needed by Library B) has following CMakeLists



cmake_minimum_required(VERSION 3.0.0)
project(A)

set(SOURCE somesource.c)

include(GNUInstallDirs)

find_package(JNI REQUIRED)
add_library(JNI SHARED IMPORTED)
set_property(TARGET JNI PROPERTY INTERFACE_INCLUDE_DIRECTORIES $ENVJAVA_HOME/include $ENVJAVA_HOME/include/linux)
set_property(TARGET JNI PROPERTY IMPORTED_LOCATION $JNI_LIBRARIES)

add_library($PROJECT_NAME SHARED $SOURCE)

target_include_directories($PROJECT_NAME
PUBLIC
$<BUILD_INTERFACE:$CMAKE_CURRENT_SOURCE_DIR/include $ENVJAVA_HOME/include $ENVJAVA_HOME/include/linux>
$<INSTALL_INTERFACE:include>
)

install(DIRECTORY include/ DESTINATION $CMAKE_INSTALL_INCLUDEDIR)

install(TARGETS $PROJECT_NAME EXPORT $PROJECT_NAMEConfig
LIBRARY DESTINATION $CMAKE_INSTALL_LIBDIR)

install(EXPORT $PROJECT_NAMEConfig DESTINATION $CMAKE_INSTALL_PREFIX/cmake)


Notice I only have one include file which is public and located in "include", so its used by the library itself but should also be part of the install interface
used by the "consuming" target.



Library B (which uses Library A and its header)



cmake_minimum_required(VERSION 3.0)
project(B)

set(SOURCE somesource.c)

add_library($PROJECT_NAME SHARED $SOURCE)

find_package(A REQUIRED)

target_include_directories($PROJECT_NAME
PRIVATE $PROJECT_SOURCE_DIR
)


So in Library B I assume that I do not need to add the include_directories from Library A again. This is why I actually did the target approach so there is no need to keep track of linker/include dependencies. "find_package" should handle these on it's own right? I do not link neither because it is a shared object, not a static library.
Both libraries use the same CMAKE_INSTALL_PREFIX ofc and library A has been installed (make install). I double-checked on this. In case of using a different prefix or not doing the install, CMake already complains about not finding it.



So considering the issue now:
Within a source file from library B, I am using



#include <libcobjava.h>


resulting in an error when building as the compiler complains about "No such file or directory" Am I missing something? The file is definitely located at
CMAKE_INSTALL_PREFIX/include.



Apart from that as I am still new to CMake: Is this even the way you would do things if you own all the source?



Edit: Some more details on the follow-up issue as discussed in comments. Library A is libcobjava.



First I had the target_include_directories part as following (including the path where jni.h is located in $<INSTALL_INTERFACE:)



target_include_directories($PROJECT_NAME 
PUBLIC
$<BUILD_INTERFACE:$CMAKE_CURRENT_SOURCE_DIR/include $ENVJAVA_HOME/include $ENVJAVA_HOME/include/linux>
$<INSTALL_INTERFACE:include $ENVJAVA_HOME/include $ENVJAVA_HOME/include/linux>
)


results in following error:



[cmake] Configuring done
[cmake] CMake Error in CMakeLists.txt:
[cmake] Target "libcobjava" INTERFACE_INCLUDE_DIRECTORIES property contains path:
[cmake]
[cmake] "/media/rbs42/data/Gebos/RBS42/tools/libcobjava/$_IMPORT_PREFIX/include"
[cmake]
[cmake] which is prefixed in the source directory.
[cmake]
[cmake]
[cmake] Generating done
[cms-driver] Error during CMake configure: [cmake-server] Failed to compute build system.


This is why I removed $ENVJAVA_HOME/include $ENVJAVA_HOME/include/linux> from $<INSTALL_INTERFACE again.



The actual error I am getting in library B now is during compiling:



[build] /media/rbs42/data/rbs42/usr/include/libcobjava.h:1:10: fatal error: jni.h: No such file or directory
[build] #include <jni.h>


because library B does not have the include directories from library A that are not included in the $<INSTALL_INTERFACE. This is what one would expect. And thats the reason I added the following code before in library A.



set_property(TARGET JNI PROPERTY INTERFACE_INCLUDE_DIRECTORIES $ENVJAVA_HOME/include $ENVJAVA_HOME/include/linux)


which I assumed is taking care of propagating the include dependencies from library A to the "consuming" library B, although they are not part of the $<INSTALL_INTERFACE.







c++ c cmake






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 11:42







Paxi1337

















asked Mar 27 at 8:26









Paxi1337Paxi1337

405 bronze badges




405 bronze badges










  • 2





    In the project B you have find_package(A REQUIRED) but never uses results of this call. It should be target_link_libraries(B A) for link the B library with A and "consume" its include directories.

    – Tsyvarev
    Mar 27 at 8:42












  • Thanks! I was misunderstanding target_link_libraries. That fixed the issue. However, now I get an error about a missing include library A uses (not part of the public header) in library B. More specific it is JNI which is not a project I have the source/cmake for. I tried adding find_package(JNI REQUIRED) add_library(JNI SHARED IMPORTED) set_property(TARGET JNI PROPERTY INTERFACE_INCLUDE_DIRECTORIES $JNI_INCLUDE_DIRS) set_property(TARGET JNI PROPERTY IMPORTED_LOCATION $JNI_LIBRARIES) (similar to the sample) in library A, but this did not solve the issue unfortunately.

    – Paxi1337
    Mar 27 at 9:50











  • Check content of $JNI_INCLUDE_DIRS, and check that given directory actually contains required headers.

    – Tsyvarev
    Mar 27 at 10:04











  • I made sure and using the hardcoded path again. The path is used in lib A for building and working fine there so I can exclude the path for being incorrect. I updated the CMakeLists.txt for Library A. Library B is unchanged. Library B now complains about #include <jni.h>, which is the first line in headerFromA.hpp (which was unknown before). Thanks for your time, would be really glad if we can work this out.

    – Paxi1337
    Mar 27 at 10:22












  • I am not sure, but construction $<BUILD_INTERFACE:XXX> should be repeated for every include directory; you cannot use single construction for several include directories.

    – Tsyvarev
    Mar 27 at 11:03












  • 2





    In the project B you have find_package(A REQUIRED) but never uses results of this call. It should be target_link_libraries(B A) for link the B library with A and "consume" its include directories.

    – Tsyvarev
    Mar 27 at 8:42












  • Thanks! I was misunderstanding target_link_libraries. That fixed the issue. However, now I get an error about a missing include library A uses (not part of the public header) in library B. More specific it is JNI which is not a project I have the source/cmake for. I tried adding find_package(JNI REQUIRED) add_library(JNI SHARED IMPORTED) set_property(TARGET JNI PROPERTY INTERFACE_INCLUDE_DIRECTORIES $JNI_INCLUDE_DIRS) set_property(TARGET JNI PROPERTY IMPORTED_LOCATION $JNI_LIBRARIES) (similar to the sample) in library A, but this did not solve the issue unfortunately.

    – Paxi1337
    Mar 27 at 9:50











  • Check content of $JNI_INCLUDE_DIRS, and check that given directory actually contains required headers.

    – Tsyvarev
    Mar 27 at 10:04











  • I made sure and using the hardcoded path again. The path is used in lib A for building and working fine there so I can exclude the path for being incorrect. I updated the CMakeLists.txt for Library A. Library B is unchanged. Library B now complains about #include <jni.h>, which is the first line in headerFromA.hpp (which was unknown before). Thanks for your time, would be really glad if we can work this out.

    – Paxi1337
    Mar 27 at 10:22












  • I am not sure, but construction $<BUILD_INTERFACE:XXX> should be repeated for every include directory; you cannot use single construction for several include directories.

    – Tsyvarev
    Mar 27 at 11:03







2




2





In the project B you have find_package(A REQUIRED) but never uses results of this call. It should be target_link_libraries(B A) for link the B library with A and "consume" its include directories.

– Tsyvarev
Mar 27 at 8:42






In the project B you have find_package(A REQUIRED) but never uses results of this call. It should be target_link_libraries(B A) for link the B library with A and "consume" its include directories.

– Tsyvarev
Mar 27 at 8:42














Thanks! I was misunderstanding target_link_libraries. That fixed the issue. However, now I get an error about a missing include library A uses (not part of the public header) in library B. More specific it is JNI which is not a project I have the source/cmake for. I tried adding find_package(JNI REQUIRED) add_library(JNI SHARED IMPORTED) set_property(TARGET JNI PROPERTY INTERFACE_INCLUDE_DIRECTORIES $JNI_INCLUDE_DIRS) set_property(TARGET JNI PROPERTY IMPORTED_LOCATION $JNI_LIBRARIES) (similar to the sample) in library A, but this did not solve the issue unfortunately.

– Paxi1337
Mar 27 at 9:50





Thanks! I was misunderstanding target_link_libraries. That fixed the issue. However, now I get an error about a missing include library A uses (not part of the public header) in library B. More specific it is JNI which is not a project I have the source/cmake for. I tried adding find_package(JNI REQUIRED) add_library(JNI SHARED IMPORTED) set_property(TARGET JNI PROPERTY INTERFACE_INCLUDE_DIRECTORIES $JNI_INCLUDE_DIRS) set_property(TARGET JNI PROPERTY IMPORTED_LOCATION $JNI_LIBRARIES) (similar to the sample) in library A, but this did not solve the issue unfortunately.

– Paxi1337
Mar 27 at 9:50













Check content of $JNI_INCLUDE_DIRS, and check that given directory actually contains required headers.

– Tsyvarev
Mar 27 at 10:04





Check content of $JNI_INCLUDE_DIRS, and check that given directory actually contains required headers.

– Tsyvarev
Mar 27 at 10:04













I made sure and using the hardcoded path again. The path is used in lib A for building and working fine there so I can exclude the path for being incorrect. I updated the CMakeLists.txt for Library A. Library B is unchanged. Library B now complains about #include <jni.h>, which is the first line in headerFromA.hpp (which was unknown before). Thanks for your time, would be really glad if we can work this out.

– Paxi1337
Mar 27 at 10:22






I made sure and using the hardcoded path again. The path is used in lib A for building and working fine there so I can exclude the path for being incorrect. I updated the CMakeLists.txt for Library A. Library B is unchanged. Library B now complains about #include <jni.h>, which is the first line in headerFromA.hpp (which was unknown before). Thanks for your time, would be really glad if we can work this out.

– Paxi1337
Mar 27 at 10:22














I am not sure, but construction $<BUILD_INTERFACE:XXX> should be repeated for every include directory; you cannot use single construction for several include directories.

– Tsyvarev
Mar 27 at 11:03





I am not sure, but construction $<BUILD_INTERFACE:XXX> should be repeated for every include directory; you cannot use single construction for several include directories.

– Tsyvarev
Mar 27 at 11:03












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55372669%2fcmake-include-dependencies-using-find-package-from-installed-target%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55372669%2fcmake-include-dependencies-using-find-package-from-installed-target%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript