summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorred1939 <bielecki.b@gmail.com>2017-11-16 21:51:25 +0100
committerWouter van Oortmerssen <aardappel@gmail.com>2017-11-16 12:51:25 -0800
commit7e803c410cba954bd8a4b968a27e822f2a3fcf52 (patch)
tree0607067cbfbd183d7611ba30d63ef967de26f111
parent1336d2625284b4e91ba30264b6ae060e84eb1ebf (diff)
downloadflatbuffers-7e803c410cba954bd8a4b968a27e822f2a3fcf52.tar.gz
flatbuffers-7e803c410cba954bd8a4b968a27e822f2a3fcf52.tar.bz2
flatbuffers-7e803c410cba954bd8a4b968a27e822f2a3fcf52.zip
Add exports for all targets (#4491)
Each target that will be installed will also generate a target that will be included by CMake config file.
-rw-r--r--CMake/FlatbuffersConfig.cmake4
-rw-r--r--CMakeLists.txt50
2 files changed, 51 insertions, 3 deletions
diff --git a/CMake/FlatbuffersConfig.cmake b/CMake/FlatbuffersConfig.cmake
new file mode 100644
index 00000000..107d78e9
--- /dev/null
+++ b/CMake/FlatbuffersConfig.cmake
@@ -0,0 +1,4 @@
+include("${CMAKE_CURRENT_LIST_DIR}/FlatbuffersTargets.cmake" OPTIONAL)
+include("${CMAKE_CURRENT_LIST_DIR}/FlatcTargets.cmake" OPTIONAL)
+include("${CMAKE_CURRENT_LIST_DIR}/FlatbuffersSharedTargets.cmake" OPTIONAL)
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7c029476..98e76296 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -249,15 +249,59 @@ endif()
if(FLATBUFFERS_INSTALL)
include(GNUInstallDirs)
+
install(DIRECTORY include/flatbuffers DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+
+ set(FB_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/flatbuffers")
+
+ install(
+ FILES "CMake/FlatbuffersConfig.cmake"
+ DESTINATION ${FB_CMAKE_DIR}
+ )
+
if(FLATBUFFERS_BUILD_FLATLIB)
- install(TARGETS flatbuffers DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ install(
+ TARGETS flatbuffers EXPORT FlatbuffersTargets
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ )
+
+ install(EXPORT FlatbuffersTargets
+ FILE FlatbuffersTargets.cmake
+ NAMESPACE flatbuffers::
+ DESTINATION ${FB_CMAKE_DIR}
+ )
endif()
+
if(FLATBUFFERS_BUILD_FLATC)
- install(TARGETS flatc DESTINATION ${CMAKE_INSTALL_BINDIR})
+ install(
+ TARGETS flatc EXPORT FlatcTargets
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ CONFIGURATIONS Release
+ )
+
+ install(
+ EXPORT FlatcTargets
+ FILE FlatcTargets.cmake
+ NAMESPACE flatbuffers::
+ DESTINATION ${FB_CMAKE_DIR}
+ CONFIGURATIONS Release
+ )
endif()
+
if(FLATBUFFERS_BUILD_SHAREDLIB)
- install(TARGETS flatbuffers_shared DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ install(
+ TARGETS flatbuffers_shared EXPORT FlatbuffersSharedTargets
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ )
+
+ install(
+ EXPORT FlatbuffersSharedTargets
+ FILE FlatbuffersSharedTargets.cmake
+ NAMESPACE flatbuffers::
+ DESTINATION ${FB_CMAKE_DIR}
+ )
endif()
endif()