Skip to content

Commit a27aad0

Browse files
committedOct 29, 2012
Run Mac bundled app from build directory
- No longer a need for hard link - Build directory app bundle, providers, Python plugins and unit tests functional - Adjusted resources corrected on install
1 parent 4fa84b6 commit a27aad0

File tree

8 files changed

+20
-26
lines changed

8 files changed

+20
-26
lines changed
 

‎CMakeLists.txt

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -388,12 +388,9 @@ ELSE (WIN32)
388388
SET (DEFAULT_PLUGIN_SUBDIR ../PlugIns/qgis)
389389
SET (QGIS_PLUGIN_SUBDIR_REV ../../MacOS)
390390
SET (DEFAULT_INCLUDE_SUBDIR include/qgis)
391-
# path for framework references
392-
IF (ENABLE_TESTS)
393-
SET (CMAKE_INSTALL_NAME_DIR ${CMAKE_BINARY_DIR}/output/lib)
394-
ELSE (ENABLE_TESTS)
395-
SET (CMAKE_INSTALL_NAME_DIR @executable_path/${QGIS_FW_SUBDIR})
396-
ENDIF (ENABLE_TESTS)
391+
# path for framework references when running from build directory
392+
# changed later to reference in-app resources upon install
393+
SET (CMAKE_INSTALL_NAME_DIR ${CMAKE_BINARY_DIR}/output/lib)
397394
IF (WITH_GLOBE)
398395
SET (OSG_PLUGINS_PATH "" CACHE PATH "Path to OSG plugins for bundling")
399396
ENDIF (WITH_GLOBE)
@@ -480,16 +477,6 @@ SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_LIB_SUBDIR})
480477
# if run from the build directory QGIS will detect it and alter the paths
481478
FILE(WRITE ${QGIS_OUTPUT_DIRECTORY}/${QGIS_BIN_SUBDIR}/path.txt "${CMAKE_SOURCE_DIR}\n${QGIS_OUTPUT_DIRECTORY}")
482479

483-
# symlink extra provider plugin frameworks for Mac unit tests
484-
IF (APPLE AND ENABLE_TESTS)
485-
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink
486-
"${CMAKE_BINARY_DIR}/Plugins/qgis/qgisgrass.framework"
487-
"${CMAKE_BINARY_DIR}/output/lib/qgisgrass.framework")
488-
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink
489-
"${CMAKE_BINARY_DIR}/Plugins/qgis/qgissqlanyconnection.framework"
490-
"${CMAKE_BINARY_DIR}/output/lib/qgissqlanyconnection.framework")
491-
ENDIF (APPLE AND ENABLE_TESTS)
492-
493480
# manual page - makes sense only on unix systems
494481
IF (UNIX AND NOT APPLE)
495482
SET (DEFAULT_MANUAL_SUBDIR man)
@@ -625,11 +612,12 @@ IF (APPLE)
625612
# must be last for install, so install_name_tool can do its work
626613
ADD_SUBDIRECTORY(mac)
627614

628-
# make hard link to embedded app bundle binary (symlink won't work)
629-
# allows QGIS to be run directly from build directory
630-
ADD_CUSTOM_TARGET(mac_hardlink ALL
631-
COMMAND /bin/ln -f QGIS.app/Contents/MacOS/QGIS QGIS
632-
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/output/bin"
615+
# allow QGIS to be run directly from build directory and to run unit tests
616+
ADD_CUSTOM_TARGET(mac_run_from_build ALL
617+
# make symlinks to extra provider-plugin
618+
COMMAND /bin/ln -fs ../../Plugins/qgis/qgisgrass.framework lib/
619+
COMMAND /bin/ln -fs ../../Plugins/qgis/qgissqlanyconnection.framework lib/
620+
WORKING_DIRECTORY "${QGIS_OUTPUT_DIRECTORY}"
633621
DEPENDS QGIS
634622
)
635623
ENDIF (APPLE)

‎cmake/MacBundleMacros.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ FUNCTION (COPY_FRAMEWORK FWPREFIX FWNAME FWDEST)
7575
EXECUTE_PROCESS (COMMAND cp -Rfp "${FWPREFIX}/${FWNAME}.framework/Versions/${FWVER}/Resources" "${FWDEST}/${FWNAME}.framework/Versions/${FWVER}")
7676
EXECUTE_PROCESS (COMMAND ln -sfh Versions/Current/Resources "${FWDEST}/${FWNAME}.framework/Resources")
7777
ENDIF (IS_DIRECTORY "${FWPREFIX}/${FWNAME}.framework/Versions/${FWVER}/Resources")
78+
EXECUTE_PROCESS (COMMAND install_name_tool -id "${ATEXECUTABLE}/${QGIS_FW_SUBDIR}/${FWNAME}" "${FWDEST}/${FWNAME}.framework/${FWNAME}")
7879
# debug variants
7980
SET (FWD "${FWNAME}_debug")
8081
IF ("${FWDEBUG}" STREQUAL "Debug" AND EXISTS "${FWPREFIX}/${FWNAME}.framework/Versions/${FWVER}/${FWD}")

‎mac/cmake/0qgis.cmake.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,9 @@ IF (@OSX_HAVE_LOADERPATH@)
2020
GET_INSTALL_NAME ("${QFWDIR}/${QL}.framework/${QL}" ${QL}.framework QQ)
2121
SET (QFW_CHG "${QQ}")
2222
UPDATEQGISPATHS ("${QFW_CHG}" ${QL})
23+
# change id of the framework
24+
IF (NOT @QGIS_MACAPP_INSTALL_DEV@)
25+
EXECUTE_PROCESS(COMMAND install_name_tool -id "${ATEXECUTABLE}/${QGIS_FW_SUBDIR}/${QL}.framework/${QL}" "${QFWDIR}/${QL}.framework/${QL}")
26+
ENDIF ()
2327
ENDFOREACH (QL)
2428
ENDIF (@OSX_HAVE_LOADERPATH@)

‎src/core/qgsapplication.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ void QgsApplication::init( QString customConfigPath )
9191

9292
// check if QGIS is run from build directory (not the install directory)
9393
QFile f;
94-
foreach ( QString path, QStringList() << "" << "/.." << "/bin" )
94+
// "/../../.." is for Mac bundled app in build directory
95+
foreach ( QString path, QStringList() << "" << "/.." << "/bin" << "/../../.." )
9596
{
9697
f.setFileName( prefixPath + path + "/path.txt" );
9798
if ( f.exists() )

‎tests/src/analysis/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ ENDIF (WIN32)
4242
# ensure the qgis libs can be found.
4343
IF (APPLE)
4444
# For Mac OS X, the executable must be at the root of the bundle's executable folder
45-
SET (CMAKE_INSTALL_NAME_DIR @executable_path/../../../src/core)
45+
# SET (CMAKE_INSTALL_NAME_DIR @executable_path/../../../src/core)
4646
ENDIF (APPLE)
4747

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

‎tests/src/core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ ENDIF (WIN32)
4141
# ensure the qgis libs can be found.
4242
IF (APPLE)
4343
# For Mac OS X, the executable must be at the root of the bundle's executable folder
44-
SET (CMAKE_INSTALL_NAME_DIR @executable_path/../../../src/core)
44+
# SET (CMAKE_INSTALL_NAME_DIR @executable_path/../../../src/core)
4545
ENDIF (APPLE)
4646

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

‎tests/src/gui/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ ENDIF(WIN32)
4848
# ensure the omg libs can be found.
4949
IF (APPLE)
5050
# For Mac OS X, the executable must be at the root of the bundle's executable folder
51-
SET (CMAKE_INSTALL_NAME_DIR @executable_path/../../../src/gui)
51+
# SET (CMAKE_INSTALL_NAME_DIR @executable_path/../../../src/gui)
5252
ENDIF (APPLE)
5353

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

‎tests/src/providers/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ ENDIF (WIN32)
3939
# ensure the qgis libs can be found.
4040
IF (APPLE)
4141
# For Mac OS X, the executable must be at the root of the bundle's executable folder
42-
SET (CMAKE_INSTALL_NAME_DIR @executable_path/../../../src/core)
42+
# SET (CMAKE_INSTALL_NAME_DIR @executable_path/../../../src/core)
4343
ENDIF (APPLE)
4444

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

0 commit comments

Comments
 (0)
Please sign in to comment.