Browse Source

CMake: Use $<BUILD_INTERFACE:...> when referencing paths in build directory

This prevents CMake from including them in exported targets, which
allows the exported targets to be installed.
Sam Edwards 7 years ago
parent
commit
086663ef4a
2 changed files with 3 additions and 3 deletions
  1. 2 2
      dtool/src/dtoolbase/CMakeLists.txt
  2. 1 1
      dtool/src/prc/CMakeLists.txt

+ 2 - 2
dtool/src/dtoolbase/CMakeLists.txt

@@ -87,8 +87,8 @@ add_component_library(p3dtoolbase NOINIT SYMBOL BUILDING_DTOOL_DTOOLBASE
   ${P3DTOOLBASE_HEADERS} ${P3DTOOLBASE_SOURCES})
 # Help other libraries find the autogenerated headers
 target_include_directories(p3dtoolbase PUBLIC
-  ${CMAKE_CURRENT_BINARY_DIR}
-  ${PROJECT_BINARY_DIR}/include/${CMAKE_CFG_INTDIR})
+  $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
+  $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/${CMAKE_CFG_INTDIR}>)
 target_link_libraries(p3dtoolbase PKG::EIGEN)
 target_interrogate(p3dtoolbase ${P3DTOOLBASE_SOURCES} EXTENSIONS ${P3DTOOLBASE_IGATEEXT})
 

+ 1 - 1
dtool/src/prc/CMakeLists.txt

@@ -72,7 +72,7 @@ composite_sources(p3prc P3PRC_SOURCES)
 
 add_component_library(p3prc NOINIT SYMBOL BUILDING_DTOOL_PRC
   ${P3PRC_HEADERS} ${P3PRC_SOURCES})
-target_include_directories(p3prc PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
+target_include_directories(p3prc PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
 target_link_libraries(p3prc p3dtool PKG::OPENSSL)
 target_interrogate(p3prc ALL EXTENSIONS ${P3PRC_IGATEEXT})