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

# Conflicts:
#	src/lib/marble/CMakeLists.txt
parent 49600e1b
......@@ -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)
......
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/@ASTRO_CMAKECONFIGNAME@Targets.cmake")
......@@ -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}
)
......@@ -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.80")
set(GENERIC_LIB_SOVERSION "25")
endif()
set(MARBLE_LIB_VERSION "0.24.80")
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}
)
@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")
......@@ -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\( ".*" \);'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment