-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing BUILD/INSTALL_${TARGET}_INCLUDEDIR
in CMakeLists.txt
#6
Comments
cc @drdanz forse puoi aiutarci a venirne a capo! |
@claudiofantacci This might help... |
Indeed, you have to (for example) set_property(GLOBAL APPEND PROPERTY ${VARS_PREFIX}_TARGETS template-lib) and then get_property(${VARS_PREFIX}_TARGETS GLOBAL PROPERTY ${VARS_PREFIX}_TARGETS) before invoking But even doing that, the generated ...
set_and_check(ExportedLib_INCLUDEDIR "")
... instead of ...
set_and_check(AutoCanny_INCLUDEDIR "${PACKAGE_PREFIX_DIR}/include")
... To fix this, I also have to ...
set_property(GLOBAL PROPERTY BUILD_${LIBRARY_TARGET_NAME}_INCLUDEDIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
set_property(GLOBAL PROPERTY INSTALL_${LIBRARY_TARGET_NAME}_INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR})
... in the corresponding LIBRARY_TARGET_NAME get_property(BUILD_${LIBRARY_TARGET_NAME}_INCLUDEDIR GLOBAL PROPERTY BUILD_${LIBRARY_TARGET_NAME}_INCLUDEDIR)
get_property(INSTALL_${LIBRARY_TARGET_NAME}_INCLUDEDIR GLOBAL PROPERTY INSTALL_${LIBRARY_TARGET_NAME}_INCLUDEDIR) Have a look here (main CMakeLists.txt) and here (Lib CMakeLists.txt). |
Hi @claudiofantacci @drdanz,
So I assume this issue is not yet fixed. You can replicate this issue directly on It would be great if you could have a look into this. Thanks, Tobi |
We actually made a "fix" that also preserved some backward compatibility and that line is the price to pay, @traversaro probably knows best. The template should work fine, you just need to link your target against target_link_libraries(mytarget LibTemplateCMake::LibTemplateCMake) without doing anything else. The other config files take care of the rest. Let us know if you encounter any other problem or you have suggestions to improve usability and user experience. |
Hmmm .. sure, I can link to it, but how can I use the header files provided by the library? I.e. how can I |
Includes are part of the You can find details in set_target_properties(LibTemplateCMake::LibTemplateCMake PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "<yout_path>/how-to-export-cpp-library/src/LibTemplateCMake/include"
) So when you find the package such includes are already added. |
Great, get it, working fine, thanks a lot :)! |
No worries @Tobias-Fischer, you are welcome :-) |
I just fully understood how to use this in a dependent project .. for other CMake newbies, this line will do the trick: |
@Tobias-Fischer that will work, but the pro of using target is to avoid code verbosity and reduce mistakes 😄 |
Yes, yes .. in that specific code, I needed it for |
Some variable are missing before invoking
install_basic_package_files()
in the main CMakeLists.txt (line #70).In particular, just before line #70, a
is missing to properly use the associated global variable.
Furthermore, for
install_basic_package_files()
to work properly, the following 2 variables need to be declared:I have an implementation that seems to work fine, even though it is not a clean solution in the case a user uses
EXTRA_PATH_VARS_SUFFIX
.We should briefly discuss a solution when we have some time :-)
The text was updated successfully, but these errors were encountered: