Skip to content

Commit

Permalink
Also copy svg, icons and doc to build dir, into /data/ subdir
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn authored and nyalldawson committed Oct 25, 2019
1 parent bb181c8 commit e6a06ec
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 37 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -189,7 +189,7 @@ IF(WITH_CORE)
# The qgis_desktop target is meant to build a minimal but complete running QGIS during development
# This should help to reduce compile time while still having a "complete enough" QGIS for most of the development
ADD_CUSTOM_TARGET(qgis_desktop
DEPENDS qgis qgispython pycore pygui pyanalysis postgresprovider staged-plugins pyplugin-installer resources
DEPENDS qgis qgispython pycore pygui pyanalysis postgresprovider staged-plugins pyplugin-installer resources svg doc icons
)
ENDIF ()

Expand Down
22 changes: 22 additions & 0 deletions cmake/CopyResources.cmake
@@ -0,0 +1,22 @@
MACRO(ADD_QGIS_RESOURCES SOURCE_PREFIX TARGET_PREFIX DEST_FILES SOURCE_FILE_PATHS)

# On build copy all resource files to build folder
FOREACH(RESOURCE_FILE ${SOURCE_FILE_PATHS})
ADD_CUSTOM_COMMAND(
OUTPUT "${CMAKE_BINARY_DIR}/output/data/${TARGET_PREFIX}/${RESOURCE_FILE}"
COMMAND cmake -E copy
"${SOURCE_PREFIX}/${RESOURCE_FILE}"
"${CMAKE_BINARY_DIR}/output/data/${TARGET_PREFIX}/${RESOURCE_FILE}"
DEPENDS "${SOURCE_PREFIX}/${RESOURCE_FILE}"
)
LIST(APPEND ${DEST_FILES}
"${CMAKE_BINARY_DIR}/output/data/${TARGET_PREFIX}/${RESOURCE_FILE}")
ENDFOREACH(RESOURCE_FILE)

# Install resources to system resource folder
FOREACH(RESOURCE_FILE ${RESOURCES_FILES})
GET_FILENAME_COMPONENT(PATH_NAME "${TARGET_PREFIX}/${RESOURCE_FILE}" PATH)
INSTALL(FILES "${TARGET_PREFIX}/${RESOURCE_FILE}" DESTINATION ${PATH_NAME})
ENDFOREACH()

ENDMACRO()
25 changes: 22 additions & 3 deletions doc/CMakeLists.txt
@@ -1,3 +1,5 @@
INCLUDE(CopyResources)

# include doxygen documentation
SET (WITH_APIDOC FALSE CACHE BOOL "Determines whether the QGIS API doxygen documentation should be built")

Expand All @@ -19,13 +21,30 @@ IF(TXT2TAGS_EXECUTABLE)
ADD_CUSTOM_TARGET (t2tdoc ALL DEPENDS ${QGIS_DOC_FILES} ${t2tfiles})
ELSE(TXT2TAGS_EXECUTABLE)
SET(QGIS_DOC_FILES
${CMAKE_SOURCE_DIR}/INSTALL
../INSTALL
)
ENDIF(TXT2TAGS_EXECUTABLE)

SET(QGIS_DOC_FILES ${QGIS_DOC_FILES} index.html news.html developersmap.html nohelp.html favicon.ico style.css AUTHORS CONTRIBUTORS SPONSORS DONORS TRANSLATORS LICENSE)
SET(QGIS_DOC_FILES
${QGIS_DOC_FILES}
index.html
news.html
developersmap.html
nohelp.html
favicon.ico
style.css
AUTHORS
CONTRIBUTORS
SPONSORS
DONORS
TRANSLATORS
LICENSE
)

ADD_QGIS_RESOURCES("${CMAKE_CURRENT_SOURCE_DIR}" doc DEST_DOC_FILES "${QGIS_DOC_FILES}")

ADD_CUSTOM_TARGET(doc ALL DEPENDS ${DEST_DOC_FILES})

INSTALL(FILES ${QGIS_DOC_FILES} DESTINATION ${QGIS_DATA_DIR}/doc)
INSTALL(FILES ../images/icons/qgis-icon-60x60.png DESTINATION ${QGIS_DATA_DIR}/doc/images)

# Sponsor images
Expand Down
11 changes: 7 additions & 4 deletions images/icons/CMakeLists.txt
@@ -1,9 +1,12 @@

FILE (GLOB IMAGES *.png)
INSTALL (FILES ${IMAGES}
DESTINATION ${QGIS_DATA_DIR}/images/icons)
INCLUDE(CopyResources)

# OS X app/doc icons
IF (APPLE)
ADD_SUBDIRECTORY(mac)
ENDIF (APPLE)

FILE(GLOB_RECURSE ICON_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.png)

ADD_QGIS_RESOURCES("${CMAKE_CURRENT_SOURCE_DIR}" "images/icons" DEST_ICON_FILES "${ICON_FILES}")

ADD_CUSTOM_TARGET(icons ALL DEPENDS ${DEST_ICON_FILES})
11 changes: 6 additions & 5 deletions images/svg/CMakeLists.txt
@@ -1,3 +1,4 @@
INCLUDE(CopyResources)

SET (SVG_DIRS
accommodation
Expand Down Expand Up @@ -25,12 +26,12 @@ SET (SVG_DIRS
wind_roses
)


FOREACH (SVG_DIR ${SVG_DIRS})
FILE(GLOB_RECURSE IMAGES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${SVG_DIR}/*.svg)
SET(SVG_FILES ${SVG_FILES} ${IMAGES})
ENDFOREACH (SVG_DIR)

FILE (GLOB IMAGES ${SVG_DIR}/*.svg)
ADD_QGIS_RESOURCES("${CMAKE_CURRENT_SOURCE_DIR}" "svg/${SVG_DIR}" DEST_SVG_FILES "${SVG_FILES}")

INSTALL (FILES ${IMAGES}
DESTINATION ${QGIS_DATA_DIR}/svg/${SVG_DIR})
ADD_CUSTOM_TARGET(svg ALL DEPENDS ${DEST_SVG_FILES})

ENDFOREACH (SVG_DIR)
25 changes: 5 additions & 20 deletions resources/CMakeLists.txt
@@ -1,3 +1,5 @@
INCLUDE(CopyResources)

# Folders to install
FILE(GLOB_RECURSE CPT_CITY_QGIS_MIN_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} cpt-city-qgis-min/*)
FILE(GLOB_RECURSE THEMES_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} themes/*)
Expand Down Expand Up @@ -38,24 +40,7 @@ IF (APPLE)
SET(RESOURCES_FILES ${RESOURCES_FILES} pkcs8.asn)
ENDIF (APPLE)

# On build copy all resource files to build folder
FOREACH(RESOURCE_FILE ${RESOURCES_FILES})
ADD_CUSTOM_COMMAND(
OUTPUT "${CMAKE_BINARY_DIR}/output/resources/${RESOURCE_FILE}"
COMMAND cmake -E copy
"${CMAKE_CURRENT_SOURCE_DIR}/${RESOURCE_FILE}"
"${CMAKE_BINARY_DIR}/output/resources/${RESOURCE_FILE}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${RESOURCE_FILE}"
)
LIST(APPEND RESOURCE_FILES_DEST
"${CMAKE_BINARY_DIR}/output/resources/${RESOURCE_FILE}")
ENDFOREACH(RESOURCE_FILE)

# Install resources to system resource folder
FOREACH(RESOURCE_FILE ${RESOURCES_FILES})
GET_FILENAME_COMPONENT(PATH_NAME "resources/${RESOURCE_FILE}" PATH)
INSTALL( FILES "resources/${RESOURCE_FILE}" DESTINATION ${PATH_NAME})
ENDFOREACH()
ADD_QGIS_RESOURCES("${CMAKE_CURRENT_SOURCE_DIR}" resources DEST_RESOURCE_FILES "${RESOURCES_FILES}")

# srs.db -- spcial handling because there is a switch and rename depending on proj version
IF (PROJ_VERSION_MAJOR GREATER 5)
Expand All @@ -73,8 +58,8 @@ ADD_CUSTOM_COMMAND(
"${CMAKE_CURRENT_BINARY_DIR}/srs.db"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${SRSDB}"
)
LIST(APPEND RESOURCE_FILES_DEST
LIST(APPEND DEST_RESOURCE_FILES
"${CMAKE_CURRENT_BINARY_DIR}/srs.db")
INSTALL(FILES ${SRSDB} DESTINATION ${QGIS_DATA_DIR}/resources RENAME srs.db)

ADD_CUSTOM_TARGET(resources ALL DEPENDS ${RESOURCE_FILES_DEST})
ADD_CUSTOM_TARGET(resources ALL DEPENDS ${DEST_RESOURCE_FILES})
2 changes: 1 addition & 1 deletion src/app/qgspluginregistry.cpp
Expand Up @@ -577,7 +577,7 @@ void QgsPluginRegistry::restoreSessionPlugins( const QString &pluginDirString )
// start - temporary fix for issue #5879, more above
if ( QgsApplication::isRunningFromBuildDir() )
{
QgsApplication::setPkgDataPath( QgsApplication::buildOutputPath() );
QgsApplication::setPkgDataPath( QgsApplication::buildOutputPath() + QStringLiteral( "/data" ) );
}
// end - temporary fix for issue #5879
}
Expand Down
10 changes: 7 additions & 3 deletions src/core/qgsapplication.cpp
Expand Up @@ -237,7 +237,7 @@ void QgsApplication::init( QString profileFolder )
#else
setPluginPath( ABISYM( mBuildOutputPath ) + '/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
#endif
setPkgDataPath( ABISYM( mBuildOutputPath ) ); // directly source path - used for: doc, resources, svg
setPkgDataPath( ABISYM( mBuildOutputPath ) + QStringLiteral( "/data" ) ); // in buildDir/data - used for: doc, resources, svg
ABISYM( mLibraryPath ) = ABISYM( mBuildOutputPath ) + '/' + QGIS_LIB_SUBDIR + '/';
#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
ABISYM( mLibexecPath ) = ABISYM( mBuildOutputPath ) + '/' + QGIS_LIBEXEC_SUBDIR + '/' + ABISYM( mCfgIntDir ) + '/';
Expand Down Expand Up @@ -490,7 +490,9 @@ void QgsApplication::setPluginPath( const QString &pluginPath )
void QgsApplication::setPkgDataPath( const QString &pkgDataPath )
{
ABISYM( mPkgDataPath ) = pkgDataPath;
QString mySvgPath = pkgDataPath + ( ABISYM( mRunningFromBuildDir ) ? "/images/svg/" : "/svg/" );

QString mySvgPath = pkgDataPath + QStringLiteral( "/svg/" );

// avoid duplicate entries
if ( !ABISYM( mDefaultSvgPaths ).contains( mySvgPath ) )
ABISYM( mDefaultSvgPaths ) << mySvgPath;
Expand Down Expand Up @@ -532,13 +534,15 @@ QString QgsApplication::pluginPath()
{
return ABISYM( mPluginPath );
}

QString QgsApplication::pkgDataPath()
{
if ( ABISYM( mPkgDataPath ).isNull() )
return resolvePkgPath();
else
return ABISYM( mPkgDataPath );
}

QString QgsApplication::defaultThemePath()
{
return QStringLiteral( ":/images/themes/default/" );
Expand Down Expand Up @@ -766,7 +770,7 @@ QString QgsApplication::resolvePkgPath()
}

if ( ABISYM( mRunningFromBuildDir ) )
return ABISYM( mBuildOutputPath );
return ABISYM( mBuildOutputPath ) + QStringLiteral( "/data" );
else
return prefixPath + '/' + QStringLiteral( QGIS_DATA_SUBDIR );
}
Expand Down

0 comments on commit e6a06ec

Please sign in to comment.