Tinyxml2: CMakeLists.txt 不导出包含路径。

创建于 2016-06-21  ·  5评论  ·  资料来源: leethomason/tinyxml2

请添加类似于以下内容的内容:
target_include_directories(tinyxml2 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/.)

target_include_directories(tinyxml2_static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/.)

到 CMakeLists.txt。 这将允许在单个构建树中构建和链接 tinyxml2。 使用 cmake 的应用程序将能够: add_subdirectory(tinyxml2) 然后使用 tinyxml2 目标。

最有用的评论

使用 target_include_directories 需要至少 2.8.11 的 cmake 版本。 如果您想保持与 cmake 2.6 的兼容性,可以在 googletest 的 CMakeLists 中看到处理此问题的好方法:

# 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()

所有5条评论

这正是我在项目中所需要的。 大拇指!

是的,这将是一个非常方便的功能。

很棒的功能提案! 我也期待在我的项目中使用它。

使用 target_include_directories 需要至少 2.8.11 的 cmake 版本。 如果您想保持与 cmake 2.6 的兼容性,可以在 googletest 的 CMakeLists 中看到处理此问题的好方法:

# 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()

合并。 谢谢@kurylo

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

KerstinKeller picture KerstinKeller  ·  5评论

ajtruckle picture ajtruckle  ·  9评论

vigneshrams picture vigneshrams  ·  3评论

leethomason picture leethomason  ·  4评论

MortenMacFly picture MortenMacFly  ·  18评论