Fix build-ability of installed examples

Summary:
* creates fake headers in marble/ prefix in the build dir for headers
  which are not in lib/marble in the sources, to simulate install paths
* update all installed CMakeLists.txt to cmake config file logic
* fix missing installed sources or CMakeLists.txt
* temporarily stop installing sources of marble-game,
  needs some work for paths of flags in qrc file

OPENCV-based examples were not touched, need a separate look

Test Plan: All installed example sources could be build with cmake & make, and ran.

Reviewers: #marble, rahn, sanjibanb, shentey, nienhueser

Differential Revision: https://phabricator.kde.org/D2373

# Conflicts:
#	examples/cpp/marble-game/GameMainWindow.cpp
parent 3e0b5ab0
# Generate fake headers
# forwarding headers to simulate installed header paths with just a marble/ prefix
# for headers which are located in other prefixes in the sources
set(FAKEHEADERS_DIR ${CMAKE_CURRENT_BINARY_DIR}/fakeheaders)
function(generateFakeHeaders basedir)
foreach(_filename ${ARGN})
set(_fileContent "#include <${basedir}/${_filename}>")
file(WRITE ${FAKEHEADERS_DIR}/marble/${_filename} ${_fileContent})
endforeach()
endfunction()
# create clean dir
file(REMOVE_RECURSE ${FAKEHEADERS_DIR})
file(MAKE_DIRECTORY ${FAKEHEADERS_DIR}/marble)
generateFakeHeaders(geodata/data
GeoDataCoordinates.h
GeoDataDocument.h
GeoDataFlyTo.h
GeoDataGeometry.h
GeoDataGroundOverlay.h
GeoDataIconStyle.h
GeoDataLatLonAltBox.h
GeoDataLinearRing.h
GeoDataLineString.h
GeoDataLookAt.h
GeoDataMultiGeometry.h
GeoDataPlacemark.h
GeoDataPlaylist.h
GeoDataPoint.h
GeoDataPolygon.h
GeoDataStyle.h
GeoDataStyleMap.h
GeoDataTour.h
)
generateFakeHeaders(geodata/parser
GeoDataTypes.h
)
generateFakeHeaders(routing
Route.h
RouteRequest.h
RoutingManager.h
RoutingModel.h
)
# TODO: Change include directories for the library not to include all subdirectories,
# and change #include statements to use <marble/...> and "..." includes only
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/lib)
include_directories(
${CMAKE_SOURCE_DIR}/src/lib
${FAKEHEADERS_DIR}
)
set( MARBLE_EXAMPLES_INSTALL_DIR ${CMAKE_INSTALL_FULL_DATAROOTDIR}/apps/marble/examples )
......
......@@ -15,11 +15,8 @@ make
You can also use a local Marble version like this:
cd hello-marble
cmake -DCMAKE_MODULE_PATH=~/marble/export/share/apps/cmake/modules \
-DCMAKE_INCLUDE_PATH=~/marble/export/include \
-DCMAKE_LIBRARY_PATH=~/marble/export/lib \
.
cmake -DCMAKE_PREFIX_PATH=~/marble/export .
make
./hello-world
./hello-marble
In the second example Marble is assumed to be installed to ~/marble/export.
......@@ -15,8 +15,8 @@
*/
#include <marble/MarbleWidget.h>
#include <GeoDataCoordinates.h>
#include <GeoDataLineString.h>
#include <marble/GeoDataCoordinates.h>
#include <marble/GeoDataLineString.h>
#include <marble/RenderPlugin.h>
#include <marble/Quaternion.h>
......
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
SET (TARGET basic-routing)
PROJECT (${TARGET})
cmake_minimum_required(VERSION 2.8.12)
FIND_PACKAGE (Qt5Widgets REQUIRED)
FIND_PACKAGE (Marble REQUIRED)
project(basic-routing)
INCLUDE_DIRECTORIES (
${Qt5Widgets_INCLUDE_DIRS}
${MARBLE_INCLUDE_DIR}
)
find_package(Qt5Widgets REQUIRED)
find_package(Marble REQUIRED)
SET (LIBS ${MARBLE_LIBRARIES} ${Qt5Widgets_LIBRARIES})
ADD_EXECUTABLE (${TARGET} main.cpp)
TARGET_LINK_LIBRARIES (${TARGET} ${LIBS})
add_executable(basic-routing main.cpp)
target_link_libraries(basic-routing Marble Qt5::Widgets)
......@@ -9,10 +9,11 @@
//
#include <QApplication>
#include <marble/MarbleWidget.h>
#include <marble/MarbleModel.h>
#include <routing/RouteRequest.h>
#include <routing/RoutingManager.h>
#include <marble/RouteRequest.h>
#include <marble/RoutingManager.h>
using namespace Marble;
......
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
SET (TARGET custom-layers)
PROJECT (${TARGET})
cmake_minimum_required(VERSION 2.8.12)
FIND_PACKAGE (Qt5Core REQUIRED)
FIND_PACKAGE (Qt5Widgets REQUIRED)
FIND_PACKAGE (Marble REQUIRED)
project(custom-layers)
INCLUDE_DIRECTORIES (
${Qt5Core_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
${MARBLE_INCLUDE_DIR}
)
find_package(Qt5Widgets REQUIRED)
find_package(Marble REQUIRED)
SET (LIBS ${MARBLE_LIBRARIES} ${Qt5Core_LIBRARIES} ${Qt5Widgets_LIBRARIES})
ADD_EXECUTABLE (${TARGET} main.cpp)
TARGET_LINK_LIBRARIES (${TARGET} ${LIBS})
add_executable(custom-layers main.cpp)
target_link_libraries(custom-layers Marble Qt5::Widgets)
......@@ -12,7 +12,7 @@
#include <marble/MarbleMap.h>
#include <marble/MarbleModel.h>
#include <marble/GeoPainter.h>
#include <GeoDataLineString.h>
#include <marble/GeoDataLineString.h>
#include <marble/LayerInterface.h>
#include <QTime>
......
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
SET (TARGET geopainter)
PROJECT (${TARGET})
cmake_minimum_required(VERSION 2.8.12)
FIND_PACKAGE (Qt5Widgets REQUIRED)
FIND_PACKAGE (Marble REQUIRED)
project(geopainter)
INCLUDE_DIRECTORIES (
${Qt5Widgets_INCLUDE_DIRS}
${MARBLE_INCLUDE_DIR}
)
find_package(Qt5Widgets REQUIRED)
find_package(Marble REQUIRED)
SET (LIBS ${MARBLE_LIBRARIES} ${Qt5Widgets_LIBRARIES})
ADD_EXECUTABLE (${TARGET} main.cpp)
TARGET_LINK_LIBRARIES (${TARGET} ${LIBS})
add_executable(geopainter main.cpp)
target_link_libraries(geopainter Marble Qt5::Widgets)
......@@ -9,6 +9,7 @@
//
#include <QApplication>
#include <marble/MarbleWidget.h>
#include <marble/GeoPainter.h>
......
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
SET (TARGET hello-marble)
PROJECT (${TARGET})
cmake_minimum_required(VERSION 2.8.12)
FIND_PACKAGE (Qt5Widgets REQUIRED)
FIND_PACKAGE (Marble REQUIRED)
project(hello-marble)
INCLUDE_DIRECTORIES (
${Qt5Widgets_INCLUDE_DIRS}
${MARBLE_INCLUDE_DIR}
)
find_package(Qt5Widgets REQUIRED)
find_package(Marble REQUIRED)
SET (LIBS ${MARBLE_LIBRARIES} ${Qt5Widgets_LIBRARIES})
ADD_EXECUTABLE (${TARGET} main.cpp)
TARGET_LINK_LIBRARIES (${TARGET} ${LIBS})
add_executable(hello-marble main.cpp)
target_link_libraries(hello-marble Marble Qt5::Widgets)
......@@ -9,6 +9,7 @@
//
#include <QApplication>
#include <marble/MarbleWidget.h>
using namespace Marble;
......
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
SET (TARGET kml-inspector)
PROJECT (${TARGET})
cmake_minimum_required(VERSION 2.8.12)
FIND_PACKAGE (Qt5Core REQUIRED)
FIND_PACKAGE (Qt5Widgets REQUIRED)
FIND_PACKAGE (Marble REQUIRED)
project(kml-inspector)
INCLUDE_DIRECTORIES (
${Qt5Core_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
${MARBLE_INCLUDE_DIR}
)
find_package(Qt5Widgets REQUIRED)
find_package(Marble REQUIRED)
SET (LIBS ${MARBLE_LIBRARIES} ${Qt5Core_LIBRARIES} ${Qt5Widgets_LIBRARIES})
ADD_EXECUTABLE (${TARGET} main.cpp)
TARGET_LINK_LIBRARIES (${TARGET} ${LIBS})
add_executable(kml-inspector main.cpp)
target_link_libraries(kml-inspector Marble Qt5::Widgets)
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
SET (TARGET map-controls)
PROJECT (${TARGET})
cmake_minimum_required(VERSION 2.8.12)
FIND_PACKAGE (Qt5Widgets REQUIRED)
FIND_PACKAGE (Marble REQUIRED)
project(map-controls)
INCLUDE_DIRECTORIES (
${Qt5Widgets_INCLUDE_DIRS}
${MARBLE_INCLUDE_DIR}
)
find_package(Qt5Widgets REQUIRED)
find_package(Marble REQUIRED)
SET (LIBS ${MARBLE_LIBRARIES} ${Qt5Widgets_LIBRARIES})
ADD_EXECUTABLE (${TARGET} main.cpp)
TARGET_LINK_LIBRARIES (${TARGET} ${LIBS})
add_executable(map-controls main.cpp)
target_link_libraries(map-controls Marble Qt5::Widgets)
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
SET (TARGET map-properties)
PROJECT (${TARGET})
cmake_minimum_required(VERSION 2.8.12)
FIND_PACKAGE (Qt5Widgets REQUIRED)
FIND_PACKAGE (Marble REQUIRED)
project(map-properties)
INCLUDE_DIRECTORIES (
${Qt5Widgets_INCLUDE_DIRS}
${MARBLE_INCLUDE_DIR}
)
find_package(Qt5Widgets REQUIRED)
find_package(Marble REQUIRED)
SET (LIBS ${MARBLE_LIBRARIES} ${Qt5Widgets_LIBRARIES})
ADD_EXECUTABLE (${TARGET} main.cpp)
TARGET_LINK_LIBRARIES (${TARGET} ${LIBS})
add_executable(map-properties main.cpp)
target_link_libraries(map-properties Marble Qt5::Widgets)
......@@ -6,6 +6,13 @@ include_directories(
${CMAKE_CURRENT_BINARY_DIR}
)
set(${TARGET}_HDRS
GameMainWindow.h
CountryByShape.h
CountryByFlag.h
ClickOnThat.h
)
set(${TARGET}_SRCS
gamemain.cpp
GameMainWindow.cpp
......@@ -30,6 +37,20 @@ target_link_libraries(
)
install( TARGETS ${TARGET} RUNTIME DESTINATION ${MARBLE_EXAMPLES_INSTALL_DIR}/${TARGET} )
install( FILES ${${TARGET}_SRCS} DESTINATION ${MARBLE_EXAMPLES_INSTALL_DIR}/${TARGET} )
install( FILES CMakeLists.txt.external DESTINATION ${MARBLE_EXAMPLES_INSTALL_DIR}/${TARGET} RENAME CMakeLists.txt )
# TODO: add to qrc and get from there
install( FILES MapTackRoundHeadRed.png MapTackRoundHeadGreen.png DESTINATION ${MARBLE_EXAMPLES_INSTALL_DIR}/${TARGET} )
return()
# TODO: qrc refers to lots of flags in marble sources
# needs a custom variant of the qrc file (-> configure_file) and reading the flags via alias
# TODO: do not install sources for now, MarblePlacemarkModel.h is not ready/good for public usages
install( FILES
${${TARGET}_HDRS}
${${TARGET}_SRCS}
${QML_FILES}
game.ui
marbleGame.qrc
DESTINATION ${MARBLE_EXAMPLES_INSTALL_DIR}/${TARGET}
)
install( FILES CMakeLists.txt.external DESTINATION ${MARBLE_EXAMPLES_INSTALL_DIR}/${TARGET} RENAME CMakeLists.txt )
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
SET (TARGET marble-game)
PROJECT (${TARGET})
cmake_minimum_required(VERSION 2.8.12)
FIND_PACKAGE (Qt5Core REQUIRED)
FIND_PACKAGE (Qt5Gui REQUIRED)
FIND_PACKAGE (Qt5Widgets REQUIRED)
FIND_PACKAGE (Marble REQUIRED)
project(marble-game)
INCLUDE_DIRECTORIES (
${Qt5Core_INCLUDE_DIRS}
${Qt5Gui_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
${MARBLE_INCLUDE_DIR}
)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Quick REQUIRED)
find_package(Marble REQUIRED)
SET (LIBS ${MARBLE_LIBRARIES} ${Qt5Core_LIBRARIES} ${Qt5Gui_Widgets} ${Qt5Widgets_LIBRARIES})
set(CMAKE_AUTOMOC TRUE)
ADD_EXECUTABLE (
${TARGET}
set(marble-game_SRCS
gamemain.cpp
GameMainWindow.cpp
CountryByShape.cpp
CountryByFlag.cpp
ClickOnThat.cpp)
ClickOnThat.cpp
)
# TODO: qrc refers to lots of flags in marble sources
# needs a custom variant of the qrc file (-> configure_file) and reading the flags via alias
qt5_add_resources(marble-game_SRCS marbleGame.qrc)
qt5_wrap_ui(marble-game_SRCS game.ui)
TARGET_LINK_LIBRARIES (${TARGET} ${LIBS})
add_executable(marble-game ${marble-game_SRCS})
target_link_libraries(marble-game
Marble
Qt5::Widgets
Qt5::Quick
)
......@@ -19,20 +19,20 @@
#include <QDir>
// Marble
#include <MarbleWidget.h>
#include <MarbleMap.h>
#include <MarbleModel.h>
#include <GeoDataTreeModel.h>
#include <MarbleDirs.h>
#include <MarblePlacemarkModel.h>
#include <GeoDataDocument.h>
#include <GeoDataPlacemark.h>
#include <GeoDataStyle.h>
#include <GeoDataStyleMap.h>
#include <GeoDataIconStyle.h>
#include <GeoDataTypes.h>
#include <marble/MarbleWidget.h>
#include <marble/MarbleMap.h>
#include <marble/MarbleModel.h>
#include <marble/GeoDataTreeModel.h>
#include <marble/MarbleDirs.h>
#include <marble/MarblePlacemarkModel.h>
#include <marble/GeoDataDocument.h>
#include <marble/GeoDataPlacemark.h>
#include <marble/GeoDataStyle.h>
#include <marble/GeoDataStyleMap.h>
#include <marble/GeoDataIconStyle.h>
#include <marble/GeoDataTypes.h>
namespace Marble
{
......
......@@ -16,7 +16,7 @@
#include <QObject>
// Marble
#include <GeoDataCoordinates.h>
#include <marble/GeoDataCoordinates.h>
namespace Marble
{
......
......@@ -20,17 +20,16 @@
#include <QVariantList>
// Marble
#include <MarbleWidget.h>
#include <MarbleModel.h>
#include <GeoDataTreeModel.h>
#include <MarbleDirs.h>
#include <MarbleDebug.h>
#include <MarblePlacemarkModel.h>
#include <GeoDataDocument.h>
#include <GeoDataPlacemark.h>
#include <GeoDataTypes.h>
#include <marble/MarbleWidget.h>
#include <marble/MarbleModel.h>
#include <marble/GeoDataTreeModel.h>
#include <marble/MarbleDirs.h>
#include <marble/MarbleDebug.h>
#include <marble/MarblePlacemarkModel.h>
#include <marble/GeoDataDocument.h>
#include <marble/GeoDataPlacemark.h>
#include <marble/GeoDataTypes.h>
namespace Marble
{
......
......@@ -20,20 +20,20 @@
#include <QFileInfo>
// Marble
#include <MarbleWidget.h>
#include <MarbleModel.h>
#include <GeoDataTreeModel.h>
#include <MarblePlacemarkModel.h>
#include <GeoDataTypes.h>
#include <GeoDataDocument.h>
#include <GeoDataPlacemark.h>
#include <GeoDataGeometry.h>
#include <GeoDataPolygon.h>
#include <GeoDataLinearRing.h>
#include <GeoDataMultiGeometry.h>
#include <GeoDataPoint.h>
#include <GeoDataCoordinates.h>
#include <marble/MarbleWidget.h>
#include <marble/MarbleModel.h>
#include <marble/GeoDataTreeModel.h>
#include <marble/MarblePlacemarkModel.h>
#include <marble/GeoDataTypes.h>
#include <marble/GeoDataDocument.h>
#include <marble/GeoDataPlacemark.h>
#include <marble/GeoDataGeometry.h>
#include <marble/GeoDataPolygon.h>
#include <marble/GeoDataLinearRing.h>
#include <marble/GeoDataMultiGeometry.h>
#include <marble/GeoDataPoint.h>
#include <marble/GeoDataCoordinates.h>
namespace Marble
{
......
......@@ -15,7 +15,7 @@
#include <QObject>
// Marble
#include <GeoDataCoordinates.h>
#include <marble/GeoDataCoordinates.h>
namespace Marble
{
......
......@@ -32,25 +32,24 @@
#include <QFileInfo>
// Marble
#include <MarbleDirs.h>
#include <MarbleWidget.h>
#include <MarbleMap.h>
#include <MarbleModel.h>
#include <GeoDataTreeModel.h>
#include <RenderPlugin.h>
#include <MarblePlacemarkModel.h>
#include <AbstractFloatItem.h>
#include <GeoDataDocument.h>
#include <GeoDataPlacemark.h>
#include <GeoDataGeometry.h>
#include <GeoDataMultiGeometry.h>
#include <GeoDataPoint.h>
#include <GeoDataCoordinates.h>
#include <GeoDataPolygon.h>
#include <GeoDataLinearRing.h>
#include <GeoDataLatLonAltBox.h>
#include <GeoDataTypes.h>
#include <marble/MarbleDirs.h>
#include <marble/MarbleWidget.h>
#include <marble/MarbleMap.h>
#include <marble/MarbleModel.h>
#include <marble/GeoDataTreeModel.h>
#include <marble/RenderPlugin.h>
#include <marble/MarblePlacemarkModel.h>
#include <marble/GeoDataDocument.h>
#include <marble/GeoDataPlacemark.h>
#include <marble/GeoDataGeometry.h>
#include <marble/GeoDataMultiGeometry.h>
#include <marble/GeoDataPoint.h>
#include <marble/GeoDataCoordinates.h>
#include <marble/GeoDataPolygon.h>
#include <marble/GeoDataLinearRing.h>
#include <marble/GeoDataLatLonAltBox.h>
#include <marble/GeoDataTypes.h>
namespace Marble {
......
......@@ -12,7 +12,7 @@
#ifndef MARBLE_GAMEMAINWINDOW_H
#define MARBLE_GAMEMAINWINDOW_H
#include <GeoDataCoordinates.h>
#include <marble/GeoDataCoordinates.h>
#include <QMainWindow>
......
......@@ -12,11 +12,10 @@
#include "GameMainWindow.h"
#include <MapThemeManager.h>
#include <MarbleDirs.h>
#include <MarbleDebug.h>
#include <MarbleLocale.h>
#include <MarbleGlobal.h>
#include <marble/MarbleDirs.h>
#include <marble/MarbleDebug.h>
#include <marble/MarbleLocale.h>
#include <marble/MarbleGlobal.h>
#include <QApplication>
#include <QDir>
......
CMAKE_MINIMUM_REQUIRED (VERSION 2.8.11)
SET (TARGET marbleQuick)
PROJECT (${TARGET})
cmake_minimum_required(VERSION 2.8.12)
FIND_PACKAGE(Qt5Core REQUIRED)
FIND_PACKAGE(Qt5Widgets REQUIRED)
FIND_PACKAGE(Qt5Quick REQUIRED)
FIND_PACKAGE (Marble REQUIRED)
project(marbleQuick)
INCLUDE_DIRECTORIES (
${MARBLE_INCLUDE_DIR}
${Qt5Core_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
${Qt5Quick_INCLUDE_DIRS}
)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Quick REQUIRED)
find_package(Marble REQUIRED)
SET (LIBS ${LIBS} ${MARBLE_LIBRARIES} ${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_LIBRARIES} ${Qt5Quick_LIBRARIES})
ADD_EXECUTABLE (${TARGET} main.cpp)
TARGET_LINK_LIBRARIES (${TARGET} ${LIBS})
add_executable(marbleQuick main.cpp)
target_link_libraries(marbleQuick Marble Qt5::Widgets Qt5::Quick)
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
SET (TARGET overlay-rendering)
PROJECT (${TARGET})
cmake_minimum_required(VERSION 2.8.12)
FIND_PACKAGE (Qt5Core REQUIRED)
FIND_PACKAGE (Qt5Gui REQUIRED)
FIND_PACKAGE (Qt5Widgets REQUIRED)
FIND_PACKAGE (Marble REQUIRED)
project(overlay-rendering)
INCLUDE_DIRECTORIES (
${Qt5Core_INCLUDE_DIRS}
${Qt5Gui_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
${MARBLE_INCLUDE_DIR}
)
find_package(Qt5Widgets REQUIRED)
find_package(Marble REQUIRED)
SET (LIBS ${MARBLE_LIBRARIES} ${Qt5Core_LIBRARIES} ${Qt5Gui_Widgets} ${Qt5Widgets_LIBRARIES})
ADD_EXECUTABLE (${TARGET} main.cpp)
TARGET_LINK_LIBRARIES (${TARGET} ${LIBS})
add_executable(overlay-rendering main.cpp)
target_link_libraries(overlay-rendering Marble Qt5::Widgets)
......@@ -4,8 +4,8 @@
#include <QImage>
#include <marble/MarbleWidget.h>
#include <GeoDataDocument.h>
#include <GeoDataGroundOverlay.h>
#include <marble/GeoDataDocument.h>
#include <marble/GeoDataGroundOverlay.h>
#include <marble/GeoDataTreeModel.h>
#include <marble/MarbleModel.h>
......
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
SET (TARGET reverse-geocoding)
PROJECT (${TARGET})
cmake_minimum_required(VERSION 2.8.12)
FIND_PACKAGE (Qt5Core REQUIRED)
FIND_PACKAGE (Qt5Widgets REQUIRED)
FIND_PACKAGE (Marble REQUIRED)
project(reverse-geocoding)
INCLUDE_DIRECTORIES (