]> git.mxchange.org Git - simgear.git/commitdiff
Work on CMake export of targets.
authorJames Turner <zakalawe@mac.com>
Fri, 29 Jan 2016 09:39:08 +0000 (09:39 +0000)
committerJames Turner <zakalawe@mac.com>
Fri, 29 Jan 2016 23:15:07 +0000 (23:15 +0000)
CMakeLists.txt
SimGearConfig.cmake.in [new file with mode: 0644]
simgear/CMakeLists.txt

index f7220c5734a71523795c26e64c95c0d61df51a5e..7609844ab40f18a7737d610707f284f42b0d738a 100644 (file)
@@ -14,6 +14,7 @@ include (CheckIncludeFile)
 include (CheckLibraryExists)
 include (CheckCXXSourceCompiles)
 include (CheckCXXCompilerFlag)
+include (GenerateExportHeader)
 
 # using 10.7 because boost requires libc++ and 10.6 doesn't include it
 set(CMAKE_OSX_DEPLOYMENT_TARGET 10.7)
@@ -423,6 +424,43 @@ include_directories(3rdparty/utf8/source)
 add_subdirectory(3rdparty)
 add_subdirectory(simgear)
 
+#-----------------------------------------------------------------------------
+### Export stuff, see https://cmake.org/cmake/help/v3.2/manual/cmake-packages.7.html#creating-packages
+#-----------------------------------------------------------------------------
+
+generate_export_header(SimGearCore)
+generate_export_header(SimGearScene)
+
+include(CMakePackageConfigHelpers)
+
+write_basic_package_version_file(
+  "${CMAKE_CURRENT_BINARY_DIR}/SimGear/SimGearConfigVersion.cmake"
+  VERSION ${SIMGEAR_VERSION}
+  COMPATIBILITY AnyNewerVersion
+)
+
+export(EXPORT SimGearTargets
+  FILE "${CMAKE_CURRENT_BINARY_DIR}/SimGear/SimGearTargets.cmake"
+  NAMESPACE Upstream::
+)
+
+configure_file(SimGearConfig.cmake.in
+  "${CMAKE_CURRENT_BINARY_DIR}/SimGear/SimGearConfig.cmake"
+  @ONLY
+)
+
+set(ConfigPackageLocation lib/cmake/SimGear)
+install(EXPORT SimGearTargets
+  DESTINATION ${ConfigPackageLocation}
+)
+install(
+  FILES
+    "${CMAKE_CURRENT_BINARY_DIR}/SimGear/SimGearConfig.cmake"
+    "${CMAKE_CURRENT_BINARY_DIR}/SimGear/SimGearConfigVersion.cmake"
+  DESTINATION ${ConfigPackageLocation}
+  COMPONENT Devel
+)
+
 #-----------------------------------------------------------------------------
 ### uninstall target
 #-----------------------------------------------------------------------------
diff --git a/SimGearConfig.cmake.in b/SimGearConfig.cmake.in
new file mode 100644 (file)
index 0000000..165468c
--- /dev/null
@@ -0,0 +1,16 @@
+include(CMakeFindDependencyMacro)
+
+find_dependency(ZLIB)
+find_dependency(Threads)
+
+# OSG
+
+set(SIMGEAR_HEADLESS @SIMGEAR_HEADLESS@)
+set(SIMGEAR_SOUND @ENABLE_SOUND@)
+
+# OpenAL isn't a public dependency, so maybe not needed
+#if (SIMGEAR_SOUND)
+#  find_dependency(OpenAL)
+#endif()
+
+include("${CMAKE_CURRENT_LIST_DIR}/SimGearTargets.cmake")
index 37ef4fdc6c3291a45012725edf600f4a20cfb0d3..59768334b9880a5b8a88242c08868ce0073f4cf4 100644 (file)
@@ -54,8 +54,10 @@ if(SIMGEAR_SHARED)
     set_property(TARGET SimGearCore PROPERTY LINKER_LANGUAGE CXX)
     set_property(TARGET SimGearCore PROPERTY VERSION   ${SIMGEAR_VERSION})
     set_property(TARGET SimGearCore PROPERTY SOVERSION ${SIMGEAR_SOVERSION})
-    install(TARGETS SimGearCore EXPORT SimGearCoreConfig LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-    install(EXPORT SimGearCoreConfig DESTINATION share/SimGearCore)
+    install(TARGETS SimGearCore
+            EXPORT SimGearTargets
+            LIBRARY DESTINATION
+            ${CMAKE_INSTALL_LIBDIR})
 
     if(NOT SIMGEAR_HEADLESS)
         add_library(SimGearScene SHARED ${sceneSources})
@@ -64,8 +66,10 @@ if(SIMGEAR_SHARED)
         set_property(TARGET SimGearScene PROPERTY SOVERSION ${SIMGEAR_SOVERSION})
 
         # EXPORT SimGearSceneConfig
-        install(TARGETS SimGearScene LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
-    #    install(EXPORT SimGearSceneConfig DESTINATION share/SimGearScene)
+        install(TARGETS SimGearScene
+                EXPORT SimGearTargets
+                LIBRARY
+                DESTINATION ${CMAKE_INSTALL_LIBDIR} )
     endif()
 
 else()
@@ -90,7 +94,9 @@ else()
        endforeach()
 
     add_library(SimGearCore STATIC ${coreSources} ${localExpatSources})
-    install(TARGETS SimGearCore ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+    install(TARGETS SimGearCore
+            EXPORT SimGearTargets
+            ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
 
     if(NOT SIMGEAR_HEADLESS)
                get_property(FG_GROUPS_SCENE_SOURCES_C GLOBAL PROPERTY FG_GROUPS_SCENE_SOURCES_C)
@@ -112,7 +118,9 @@ else()
                endforeach()
 
         add_library(SimGearScene STATIC ${sceneSources})
-        install(TARGETS SimGearScene ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+        install(TARGETS SimGearScene
+                EXPORT SimGearTargets
+                ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
     endif(NOT SIMGEAR_HEADLESS)
 endif(SIMGEAR_SHARED)