summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedrich W. H. Kossebau <kossebau@kde.org>2016-08-07 13:01:30 (GMT)
committerFriedrich W. H. Kossebau <kossebau@kde.org>2016-08-07 13:02:15 (GMT)
commitb40c2cba738dc1a659440587939791b7ffcbb138 (patch)
tree3ca763b6bb67d1d5363e9a61847fa4202534dc9e
parent79d257698fcc791611f4d4260b8c9c313ad064f3 (diff)
Create and install CMake Config file for marble & astro libraries
Summary: * use "Marble" and "Astro" as cmake target names, so 3rd-party lib users would do: find_package(Marble REQUIRED) find_package(Astro REQUIRED) target_link_libraries(foo Marble Astro) # include dirs imported by target * only install headers & cmake config files on unbundled platforms for now Reviewers: rahn, sanjibanb, shentey, nienhueser, #marble Reviewed By: nienhueser, #marble Differential Revision: https://phabricator.kde.org/D2364
-rw-r--r--CMakeLists.txt4
-rw-r--r--src/lib/astro/AstroConfig.cmake.in3
-rw-r--r--src/lib/astro/CMakeLists.txt61
-rw-r--r--src/lib/marble/CMakeLists.txt66
-rw-r--r--src/lib/marble/MarbleConfig.cmake.in21
-rwxr-xr-xtools/version/update-version-number.py8
6 files changed, 140 insertions, 23 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 092c033..1ce5a96 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -193,6 +193,10 @@ if(NOT APPS_INSTALL_DIR)
set(APPS_INSTALL_DIR ${CMAKE_INSTALL_FULL_DATAROOTDIR}/applications)
endif(NOT APPS_INSTALL_DIR)
+if(NOT INCLUDE_INSTALL_DIR)
+ set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include")
+endif()
+
if (NOT MARBLE_DATA_PATH)
set (MARBLE_DATA_PATH ${data_dir})
endif (NOT MARBLE_DATA_PATH)
diff --git a/src/lib/astro/AstroConfig.cmake.in b/src/lib/astro/AstroConfig.cmake.in
new file mode 100644
index 0000000..14c59d9
--- /dev/null
+++ b/src/lib/astro/AstroConfig.cmake.in
@@ -0,0 +1,3 @@
+@PACKAGE_INIT@
+
+include("${CMAKE_CURRENT_LIST_DIR}/@ASTRO_CMAKECONFIGNAME@Targets.cmake")
diff --git a/src/lib/astro/CMakeLists.txt b/src/lib/astro/CMakeLists.txt
index 64cfaa5..be20b26 100644
--- a/src/lib/astro/CMakeLists.txt
+++ b/src/lib/astro/CMakeLists.txt
@@ -6,8 +6,8 @@ INCLUDE_DIRECTORIES(
)
if(NOT CMAKE_SYSTEM_NAME STREQUAL Android)
- SET(GENERIC_LIB_VERSION "0.17.20")
- SET(GENERIC_LIB_SOVERSION "1")
+ set(ASTRO_LIB_VERSION "0.17.20")
+ set(ASTRO_LIB_SOVERSION "1")
endif()
ADD_DEFINITIONS(-O3)
@@ -41,21 +41,38 @@ endif(WIN32)
if(NOT CMAKE_SYSTEM_NAME STREQUAL Android)
SET_TARGET_PROPERTIES(astro PROPERTIES
- VERSION ${GENERIC_LIB_VERSION}
- SOVERSION ${GENERIC_LIB_SOVERSION}
+ VERSION ${ASTRO_LIB_VERSION}
+ SOVERSION ${ASTRO_LIB_SOVERSION}
)
endif()
+set_target_properties(astro PROPERTIES
+ EXPORT_NAME "Astro"
+)
+
+target_include_directories(astro
+ INTERFACE "$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}>"
+)
+
# choose the correct target install library path
if(WIN32)
INSTALL(TARGETS astro RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX} ARCHIVE DESTINATION lib)
elseif(APPLE)
INSTALL(TARGETS astro LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/Marble.app/Contents/MacOS/lib)
else()
- INSTALL(TARGETS astro LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ install(TARGETS astro
+ EXPORT AstroTargets
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ )
+endif()
+
+########### install headers & cmake config files ###############
+
+if (WIN32 OR APPLE)
+ # TODO: find how to install & deploy library, headers and config files as bundle for development
+ return()
endif()
-########### install files ###############
INSTALL(FILES
astrolib.h
@@ -66,5 +83,35 @@ endif()
solarsystem.h
${CMAKE_CURRENT_BINARY_DIR}/astrolib_export.h
- DESTINATION ${CMAKE_INSTALL_PREFIX}/include/astro
+ DESTINATION ${INCLUDE_INSTALL_DIR}/astro
+)
+
+########### CMake Config files ###############
+
+include(CMakePackageConfigHelpers)
+
+set(ASTRO_CMAKECONFIGNAME Astro)
+set(ASTRO_INSTALL_CMAKECONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${ASTRO_CMAKECONFIGNAME})
+
+configure_package_config_file(AstroConfig.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${ASTRO_CMAKECONFIGNAME}Config.cmake
+ INSTALL_DESTINATION ${ASTRO_INSTALL_CMAKECONFIGDIR}
+)
+
+write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${ASTRO_CMAKECONFIGNAME}ConfigVersion.cmake
+ VERSION ${ASTRO_LIB_VERSION}
+ COMPATIBILITY SameMajorVersion
+)
+
+install(FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/${ASTRO_CMAKECONFIGNAME}Config.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/${ASTRO_CMAKECONFIGNAME}ConfigVersion.cmake
+
+ DESTINATION ${ASTRO_INSTALL_CMAKECONFIGDIR}
+)
+
+install(
+ EXPORT AstroTargets
+ FILE ${ASTRO_CMAKECONFIGNAME}Targets.cmake
+ DESTINATION ${ASTRO_INSTALL_CMAKECONFIGDIR}
)
diff --git a/src/lib/marble/CMakeLists.txt b/src/lib/marble/CMakeLists.txt
index 37db8d4..850680a 100644
--- a/src/lib/marble/CMakeLists.txt
+++ b/src/lib/marble/CMakeLists.txt
@@ -7,6 +7,8 @@ marble_set_package_properties( Phonon PROPERTIES TYPE OPTIONAL PURPOSE "Support
if(PHONON_FOUND)
set(HAVE_PHONON TRUE)
endif()
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config-phonon.h.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/config-phonon.h)
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}
@@ -35,10 +37,8 @@ INCLUDE(graphicsview/CMakeLists.txt)
INCLUDE(layers/CMakeLists.txt)
INCLUDE(osm/CMakeLists.txt)
-if(NOT CMAKE_SYSTEM_NAME STREQUAL Android)
-set(GENERIC_LIB_VERSION "0.24.21")
-set(GENERIC_LIB_SOVERSION "25")
-endif()
+set(MARBLE_LIB_VERSION "0.24.21")
+set(MARBLE_ABI_VERSION "25")
########### next target ###############
@@ -423,12 +423,19 @@ endif(WIN32)
if(NOT CMAKE_SYSTEM_NAME STREQUAL Android)
set_target_properties(${MARBLEWIDGET} PROPERTIES
- VERSION ${GENERIC_LIB_VERSION}
- SOVERSION ${GENERIC_LIB_SOVERSION})
+ VERSION ${MARBLE_LIB_VERSION}
+ SOVERSION ${MARBLE_ABI_VERSION}
+ )
endif()
set_target_properties(${MARBLEWIDGET} PROPERTIES
- COMPILE_FLAGS "-DKML_LAZY_IMP")
+ EXPORT_NAME "Marble"
+ COMPILE_FLAGS "-DKML_LAZY_IMP"
+)
+
+target_include_directories(${MARBLEWIDGET}
+ INTERFACE "$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}>"
+)
# choose the correct target install library path
if(WIN32)
@@ -436,11 +443,18 @@ if(WIN32)
elseif(APPLE)
install(TARGETS ${MARBLEWIDGET} LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/Marble.app/Contents/MacOS/lib)
else()
- install(TARGETS ${MARBLEWIDGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ install(TARGETS ${MARBLEWIDGET}
+ EXPORT MarbleTargets
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
-########### install files ###############
+########### install headers & cmake config files ###############
+
+if (WIN32 OR APPLE)
+ # TODO: find how to install & deploy library, headers and config files as bundle for development
+ return()
+endif()
if (MARBLE_NO_WEBKITWIDGETS)
set(marble_WebKit
@@ -603,8 +617,36 @@ install( FILES
routing/RoutingModel.h
routing/RoutingProfile.h
- DESTINATION ${CMAKE_INSTALL_PREFIX}/include/marble
+ DESTINATION ${INCLUDE_INSTALL_DIR}/marble
)
-CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config-phonon.h.cmake
- ${CMAKE_CURRENT_BINARY_DIR}/config-phonon.h)
+
+########### CMake Config files ###############
+
+include(CMakePackageConfigHelpers)
+
+set(MARBLE_CMAKECONFIGNAME Marble)
+set(MARBLE_INSTALL_CMAKECONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${MARBLE_CMAKECONFIGNAME})
+
+configure_package_config_file(MarbleConfig.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${MARBLE_CMAKECONFIGNAME}Config.cmake
+ INSTALL_DESTINATION ${MARBLE_INSTALL_CMAKECONFIGDIR}
+)
+
+write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${MARBLE_CMAKECONFIGNAME}ConfigVersion.cmake
+ VERSION ${MARBLE_LIB_VERSION}
+ COMPATIBILITY SameMajorVersion
+)
+
+install(FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/${MARBLE_CMAKECONFIGNAME}Config.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/${MARBLE_CMAKECONFIGNAME}ConfigVersion.cmake
+
+ DESTINATION ${MARBLE_INSTALL_CMAKECONFIGDIR}
+)
+
+install(
+ EXPORT MarbleTargets
+ FILE ${MARBLE_CMAKECONFIGNAME}Targets.cmake
+ DESTINATION ${MARBLE_INSTALL_CMAKECONFIGDIR}
+)
diff --git a/src/lib/marble/MarbleConfig.cmake.in b/src/lib/marble/MarbleConfig.cmake.in
new file mode 100644
index 0000000..6e56a74
--- /dev/null
+++ b/src/lib/marble/MarbleConfig.cmake.in
@@ -0,0 +1,21 @@
+@PACKAGE_INIT@
+
+set(MARBLE_NO_WEBKITWIDGETS @MARBLE_NO_WEBKITWIDGETS@)
+
+if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.13)
+ find_dependency(Qt5Quick @REQUIRED_QT_VERSION@)
+ find_dependency(Qt5Xml @REQUIRED_QT_VERSION@)
+ find_dependency(Qt5Widgets @REQUIRED_QT_VERSION@)
+ if (NOT MARBLE_NO_WEBKITWIDGETS)
+ find_dependency(Qt5WebKitWidgets @REQUIRED_QT_VERSION@)
+ endif()
+else()
+ find_package(Qt5Quick REQUIRED)
+ find_package(Qt5Xml REQUIRED)
+ find_package(Qt5Widgets REQUIRED)
+ if (NOT MARBLE_NO_WEBKITWIDGETS)
+ find_package(Qt5WebKitWidgets REQUIRED)
+ endif()
+endif()
+
+include("${CMAKE_CURRENT_LIST_DIR}/@MARBLE_CMAKECONFIGNAME@Targets.cmake")
diff --git a/tools/version/update-version-number.py b/tools/version/update-version-number.py
index 3d2881a..90dad06 100755
--- a/tools/version/update-version-number.py
+++ b/tools/version/update-version-number.py
@@ -93,12 +93,12 @@ appVersionFile = os.path.join(rootDir, 'src', 'apps', 'marble-ui', 'ControlView.
ensureCleanOrExit(rootDir, appVersionFile)
replaceInFile(libFileName,
- 'set\\(GENERIC_LIB_VERSION "[0-9]\\.[0-9]+\\.[0-9]+"\\)',
- 'set(GENERIC_LIB_VERSION "{}.{}.{}")'.format(major, minor, patch))
+ 'set\\(MARBLE_LIB_VERSION "[0-9]\\.[0-9]+\\.[0-9]+"\\)',
+ 'set(MARBLE_LIB_VERSION "{}.{}.{}")'.format(major, minor, patch))
soVersion = minor + 1 if patch > 19 else minor
replaceInFile(libFileName,
- 'set\\(GENERIC_LIB_SOVERSION "[0-9]+"\\)',
- 'set(GENERIC_LIB_SOVERSION "{}")'.format(soVersion))
+ 'set\\(MARBLE_ABI_VERSION "[0-9]+"\\)',
+ 'set(MARBLE_ABI_VERSION "{}")'.format(soVersion))
# We have version constants in MarbleGlobal.h
libVersionOld = 'const QString MARBLE_VERSION_STRING = QString::fromLatin1\( ".*" \);'