Skip to content

Commit

Permalink
Run Mac bundled app from build directory
Browse files Browse the repository at this point in the history
- No longer a need for hard link
- Build directory app bundle, providers, Python plugins and unit tests functional
- Adjusted resources corrected on install
  • Loading branch information
dakcarto committed Oct 29, 2012
1 parent 4fa84b6 commit a27aad0
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 26 deletions.
30 changes: 9 additions & 21 deletions CMakeLists.txt
Expand Up @@ -388,12 +388,9 @@ ELSE (WIN32)
SET (DEFAULT_PLUGIN_SUBDIR ../PlugIns/qgis)
SET (QGIS_PLUGIN_SUBDIR_REV ../../MacOS)
SET (DEFAULT_INCLUDE_SUBDIR include/qgis)
# path for framework references
IF (ENABLE_TESTS)
SET (CMAKE_INSTALL_NAME_DIR ${CMAKE_BINARY_DIR}/output/lib)
ELSE (ENABLE_TESTS)
SET (CMAKE_INSTALL_NAME_DIR @executable_path/${QGIS_FW_SUBDIR})
ENDIF (ENABLE_TESTS)
# path for framework references when running from build directory
# changed later to reference in-app resources upon install
SET (CMAKE_INSTALL_NAME_DIR ${CMAKE_BINARY_DIR}/output/lib)
IF (WITH_GLOBE)
SET (OSG_PLUGINS_PATH "" CACHE PATH "Path to OSG plugins for bundling")
ENDIF (WITH_GLOBE)
Expand Down Expand Up @@ -480,16 +477,6 @@ SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_LIB_SUBDIR})
# if run from the build directory QGIS will detect it and alter the paths
FILE(WRITE ${QGIS_OUTPUT_DIRECTORY}/${QGIS_BIN_SUBDIR}/path.txt "${CMAKE_SOURCE_DIR}\n${QGIS_OUTPUT_DIRECTORY}")

# symlink extra provider plugin frameworks for Mac unit tests
IF (APPLE AND ENABLE_TESTS)
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink
"${CMAKE_BINARY_DIR}/Plugins/qgis/qgisgrass.framework"
"${CMAKE_BINARY_DIR}/output/lib/qgisgrass.framework")
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink
"${CMAKE_BINARY_DIR}/Plugins/qgis/qgissqlanyconnection.framework"
"${CMAKE_BINARY_DIR}/output/lib/qgissqlanyconnection.framework")
ENDIF (APPLE AND ENABLE_TESTS)

# manual page - makes sense only on unix systems
IF (UNIX AND NOT APPLE)
SET (DEFAULT_MANUAL_SUBDIR man)
Expand Down Expand Up @@ -625,11 +612,12 @@ IF (APPLE)
# must be last for install, so install_name_tool can do its work
ADD_SUBDIRECTORY(mac)

# make hard link to embedded app bundle binary (symlink won't work)
# allows QGIS to be run directly from build directory
ADD_CUSTOM_TARGET(mac_hardlink ALL
COMMAND /bin/ln -f QGIS.app/Contents/MacOS/QGIS QGIS
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/output/bin"
# allow QGIS to be run directly from build directory and to run unit tests
ADD_CUSTOM_TARGET(mac_run_from_build ALL
# make symlinks to extra provider-plugin
COMMAND /bin/ln -fs ../../Plugins/qgis/qgisgrass.framework lib/
COMMAND /bin/ln -fs ../../Plugins/qgis/qgissqlanyconnection.framework lib/
WORKING_DIRECTORY "${QGIS_OUTPUT_DIRECTORY}"
DEPENDS QGIS
)
ENDIF (APPLE)
Expand Down
1 change: 1 addition & 0 deletions cmake/MacBundleMacros.cmake
Expand Up @@ -75,6 +75,7 @@ FUNCTION (COPY_FRAMEWORK FWPREFIX FWNAME FWDEST)
EXECUTE_PROCESS (COMMAND cp -Rfp "${FWPREFIX}/${FWNAME}.framework/Versions/${FWVER}/Resources" "${FWDEST}/${FWNAME}.framework/Versions/${FWVER}")
EXECUTE_PROCESS (COMMAND ln -sfh Versions/Current/Resources "${FWDEST}/${FWNAME}.framework/Resources")
ENDIF (IS_DIRECTORY "${FWPREFIX}/${FWNAME}.framework/Versions/${FWVER}/Resources")
EXECUTE_PROCESS (COMMAND install_name_tool -id "${ATEXECUTABLE}/${QGIS_FW_SUBDIR}/${FWNAME}" "${FWDEST}/${FWNAME}.framework/${FWNAME}")
# debug variants
SET (FWD "${FWNAME}_debug")
IF ("${FWDEBUG}" STREQUAL "Debug" AND EXISTS "${FWPREFIX}/${FWNAME}.framework/Versions/${FWVER}/${FWD}")
Expand Down
4 changes: 4 additions & 0 deletions mac/cmake/0qgis.cmake.in
Expand Up @@ -20,5 +20,9 @@ IF (@OSX_HAVE_LOADERPATH@)
GET_INSTALL_NAME ("${QFWDIR}/${QL}.framework/${QL}" ${QL}.framework QQ)
SET (QFW_CHG "${QQ}")
UPDATEQGISPATHS ("${QFW_CHG}" ${QL})
# change id of the framework
IF (NOT @QGIS_MACAPP_INSTALL_DEV@)
EXECUTE_PROCESS(COMMAND install_name_tool -id "${ATEXECUTABLE}/${QGIS_FW_SUBDIR}/${QL}.framework/${QL}" "${QFWDIR}/${QL}.framework/${QL}")
ENDIF ()
ENDFOREACH (QL)
ENDIF (@OSX_HAVE_LOADERPATH@)
3 changes: 2 additions & 1 deletion src/core/qgsapplication.cpp
Expand Up @@ -91,7 +91,8 @@ void QgsApplication::init( QString customConfigPath )

// check if QGIS is run from build directory (not the install directory)
QFile f;
foreach ( QString path, QStringList() << "" << "/.." << "/bin" )
// "/../../.." is for Mac bundled app in build directory
foreach ( QString path, QStringList() << "" << "/.." << "/bin" << "/../../.." )
{
f.setFileName( prefixPath + path + "/path.txt" );
if ( f.exists() )
Expand Down
2 changes: 1 addition & 1 deletion tests/src/analysis/CMakeLists.txt
Expand Up @@ -42,7 +42,7 @@ ENDIF (WIN32)
# ensure the qgis libs can be found.
IF (APPLE)
# For Mac OS X, the executable must be at the root of the bundle's executable folder
SET (CMAKE_INSTALL_NAME_DIR @executable_path/../../../src/core)
# SET (CMAKE_INSTALL_NAME_DIR @executable_path/../../../src/core)
ENDIF (APPLE)

#note for tests we should not include the moc of our
Expand Down
2 changes: 1 addition & 1 deletion tests/src/core/CMakeLists.txt
Expand Up @@ -41,7 +41,7 @@ ENDIF (WIN32)
# ensure the qgis libs can be found.
IF (APPLE)
# For Mac OS X, the executable must be at the root of the bundle's executable folder
SET (CMAKE_INSTALL_NAME_DIR @executable_path/../../../src/core)
# SET (CMAKE_INSTALL_NAME_DIR @executable_path/../../../src/core)
ENDIF (APPLE)

#note for tests we should not include the moc of our
Expand Down
2 changes: 1 addition & 1 deletion tests/src/gui/CMakeLists.txt
Expand Up @@ -48,7 +48,7 @@ ENDIF(WIN32)
# ensure the omg libs can be found.
IF (APPLE)
# For Mac OS X, the executable must be at the root of the bundle's executable folder
SET (CMAKE_INSTALL_NAME_DIR @executable_path/../../../src/gui)
# SET (CMAKE_INSTALL_NAME_DIR @executable_path/../../../src/gui)
ENDIF (APPLE)

#note for tests we should not include the moc of our
Expand Down
2 changes: 1 addition & 1 deletion tests/src/providers/CMakeLists.txt
Expand Up @@ -39,7 +39,7 @@ ENDIF (WIN32)
# ensure the qgis libs can be found.
IF (APPLE)
# For Mac OS X, the executable must be at the root of the bundle's executable folder
SET (CMAKE_INSTALL_NAME_DIR @executable_path/../../../src/core)
# SET (CMAKE_INSTALL_NAME_DIR @executable_path/../../../src/core)
ENDIF (APPLE)

#note for tests we should not include the moc of our
Expand Down

0 comments on commit a27aad0

Please sign in to comment.