Skip to content

Commit

Permalink
[cmake] install icons, .desktop, and adjust RPM spec
Browse files Browse the repository at this point in the history
  • Loading branch information
rinigus committed Apr 3, 2021
1 parent 75c844d commit 252fe6c
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 33 deletions.
37 changes: 32 additions & 5 deletions CMakeLists.txt
Expand Up @@ -16,6 +16,7 @@ include(CMakePrintHelpers)
option(USE_BUNDLED_GPXPY "Use a bundled version of GPXPY rather than a system-wide version" ON)
set(FLAVOR "kirigami" CACHE STRING "Platform to build support for. Supported platforms: kirigami, silica, qtcontrols, uuitk")
set(PROFILE "Online" CACHE STRING "Default profile. Supported profiles: Online, Mixed, Offline")
set(PYTHON_EXE "auto" CACHE STRING "Set python3 executable. If set to 'auto', cmake will try to find it.")
option(RUN_FROM_SOURCE "Run from source, this is mainly intended for easy development" OFF)
set(S2INCLUDES "" CACHE STRING "Custom installed location for s2geometry, includes")
set(S2LIBS "" CACHE STRING "Custom installed location for s2geometry, libs")
Expand Down Expand Up @@ -53,14 +54,23 @@ else()
endif()

set(QT_MIN_VERSION "5.6.0")
find_package(Python3 COMPONENTS Interpreter REQUIRED)
find_package(Gettext REQUIRED)
find_package(Qt5 ${QT_MIN_VERSION} COMPONENTS Gui Positioning DBus LinguistTools REQUIRED)
find_package(Qt5 ${QT_MIN_VERSION} COMPONENTS Gui Positioning Qml Quick DBus LinguistTools REQUIRED)

if(PYTHON_EXE STREQUAL "auto")
find_package(Python3 COMPONENTS Interpreter REQUIRED)
else()
set(PYTHON_EXECUTABLE ${PYTHON_EXE})
endif()

if(FLAVOR STREQUAL "kirigami" OR FLAVOR STREQUAL "qtcontrols" OR FLAVOR STREQUAL "uuitk")
find_package(Qt5 ${QT_MIN_VERSION} COMPONENTS Quick Qml Widgets QuickControls2 REQUIRED)
find_package(Qt5 ${QT_MIN_VERSION} COMPONENTS Widgets QuickControls2 REQUIRED)
elseif(FLAVOR STREQUAL "silica")
include(FindPkgConfig)
pkg_search_module(SAILFISH sailfishapp REQUIRED)
endif()


if(RUN_FROM_SOURCE)
set(DATADIR ${CMAKE_CURRENT_SOURCE_DIR})
set(DATADIR_RUNNING ${DATADIR})
Expand Down Expand Up @@ -108,11 +118,28 @@ install(FILES packaging/pure-maps.appdata.xml
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/metainfo
RENAME ${APP_NAME}.appdata.xml)

# desktop files
if(NOT FLAVOR STREQUAL "silica")
configure_file(data/${APP_NAME}.desktop.in ${APP_NAME}.desktop @ONLY)
configure_file(data/${APP_NAME}.desktop.in ${APP_NAME}.desktop @ONLY)
configure_file(data/${APP_NAME}-uri-handler.desktop.in ${APP_NAME}-uri-handler.desktop @ONLY)
set(DESKTOP_SRC
${CMAKE_CURRENT_BINARY_DIR}/${APP_NAME}.desktop
${CMAKE_CURRENT_BINARY_DIR}/${APP_NAME}-uri-handler.desktop)
else()
set(DESKTOP_SRC
data/${APP_NAME}.desktop
data/${APP_NAME}-uri-handler.desktop)
endif()

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${APP_NAME}.desktop
install(FILES ${DESKTOP_SRC}
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)

# icons
set(ICON_SIZES 108 128 256 86)
foreach(_ISIZE ${ICON_SIZES})
install(FILES data/pure-maps-${_ISIZE}.png RENAME ${APP_NAME}.png
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${_ISIZE}x${_ISIZE}/apps)
endforeach()

# summary
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
@@ -1,7 +1,7 @@
[Desktop Entry]
Name=Pure Maps Uri Handler
MimeType=x-scheme-handler/geo
Exec=pure-maps %u
Icon=pure-maps
Exec=@CMAKE_INSTALL_FULL_BINDIR@/@APP_NAME@ %u
Icon=@APP_NAME@
Type=Application
NoDisplay=true
32 changes: 13 additions & 19 deletions rpm/harbour-pure-maps.spec
Expand Up @@ -77,33 +77,27 @@ cp %{SOURCE1} tools/
tools/manage-keys inject . || true

%build
mkdir build
cd build

%if 0%{?sailfishos}
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${_prefix} \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DFLAVOR=silica \
-DUSE_BUNDLED_GPXPY=ON \
..
%cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DFLAVOR=silica \
-DUSE_BUNDLED_GPXPY=ON \
-DPYTHON_EXE=python3
%else
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${_prefix} \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DFLAVOR=kirigami \
-DUSE_BUNDLED_GPXPY=ON \
..
%cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DFLAVOR=kirigami \
-DUSE_BUNDLED_GPXPY=ON
%endif

cmake --build . %{?_smp_mflags}
make %{?_smp_mflags}

%install
cd build
rm -rf %{buildroot}
DESTDIR=%{buildroot} cmake --install .
make DESTDIR=%{buildroot} install

%if 0%{?sailfishos}
# ship some shared libraries
Expand Down
27 changes: 20 additions & 7 deletions src/CMakeLists.txt
Expand Up @@ -53,19 +53,28 @@ if(CMAKE_BUILD_TYPE STREQUAL "release" OR CMAKE_BUILD_TYPE STREQUAL "debug")
-QT_NO_DEBUG_OUTPUT)
endif()

add_executable(${APP_NAME} ${SRC} ${HEADERS})

if(FLAVOR STREQUAL "silica")
target_include_directories(${APP_NAME} PRIVATE
$<BUILD_INTERFACE:
${SAILFISH_INCLUDE_DIRS}
>)
endif()

if(S2INCLUDES)
include_directories(${S2INCLUDES})
include_directories(${S2INCLUDES})
endif()

if(S2LIBS)
link_directories(${S2LIBS})
link_directories(${S2LIBS})
endif()

add_executable(${APP_NAME} ${SRC} ${HEADERS})

target_link_libraries(${APP_NAME}
Qt5::Gui
Qt5::Positioning
Qt5::Qml
Qt5::Quick
Qt5::Positioning
Qt5::DBus
s2)

Expand All @@ -75,11 +84,15 @@ set(LINKING_FLAVORS
"uuitk")
if(FLAVOR IN_LIST LINKING_FLAVORS)
target_link_libraries(${APP_NAME}
Qt5::Quick
Qt5::Qml
Qt5::Widgets
Qt5::QuickControls2)
endif()

if(FLAVOR STREQUAL "silica")
target_link_libraries(${APP_NAME}
${SAILFISH_LDFLAGS}
)
endif()

install(TARGETS ${APP_NAME}
DESTINATION ${CMAKE_INSTALL_BINDIR})

0 comments on commit 252fe6c

Please sign in to comment.