From: James Turner Date: Fri, 29 Jan 2016 09:39:08 +0000 (+0000) Subject: Work on CMake export of targets. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9d7402242a88fcad21d66a3672a20cf2a2f78994;p=simgear.git Work on CMake export of targets. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index f7220c57..7609844a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 index 00000000..165468c3 --- /dev/null +++ b/SimGearConfig.cmake.in @@ -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") diff --git a/simgear/CMakeLists.txt b/simgear/CMakeLists.txt index 37ef4fdc..59768334 100644 --- a/simgear/CMakeLists.txt +++ b/simgear/CMakeLists.txt @@ -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)