Tinyxml2: CMakeLists.txt does not export include paths.

Created on 21 Jun 2016  路  5Comments  路  Source: leethomason/tinyxml2

Please add something similar to:
target_include_directories(tinyxml2 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/.)

target_include_directories(tinyxml2_static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/.)

to CMakeLists.txt. This will allow building and linking with tinyxml2 in a single build tree. Application using cmake would be able to just: add_subdirectory(tinyxml2) and then use tinyxml2 targets.

Most helpful comment

Using target_include_directories requires cmake version at least 2.8.11. If you want to keep compatibility with the cmake 2.6, good approach to handle this can be seen in CMakeLists of googletest:

# If the CMake version supports it, attach header directory information
# to the targets for when we are part of a parent build (ie being pulled
# in via add_subdirectory() rather than being a standalone build).
if (DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
  target_include_directories(gtest      INTERFACE "${gtest_SOURCE_DIR}/include")
  target_include_directories(gtest_main INTERFACE "${gtest_SOURCE_DIR}/include")
endif()

All 5 comments

That's excatly what I need in my project. Thumb up!

Yep, that would be a really convenient feature.

Great feature proposal! I`m also looking forward to use it in my project.

Using target_include_directories requires cmake version at least 2.8.11. If you want to keep compatibility with the cmake 2.6, good approach to handle this can be seen in CMakeLists of googletest:

# If the CMake version supports it, attach header directory information
# to the targets for when we are part of a parent build (ie being pulled
# in via add_subdirectory() rather than being a standalone build).
if (DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
  target_include_directories(gtest      INTERFACE "${gtest_SOURCE_DIR}/include")
  target_include_directories(gtest_main INTERFACE "${gtest_SOURCE_DIR}/include")
endif()

Merged. Thanks @kurylo

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KerstinKeller picture KerstinKeller  路  5Comments

MortenMacFly picture MortenMacFly  路  18Comments

ajtruckle picture ajtruckle  路  9Comments

leethomason picture leethomason  路  4Comments

vigneshrams picture vigneshrams  路  3Comments