diff --git a/CMakeLists.txt b/CMakeLists.txt index 596c8f477..a54953de0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -417,12 +417,13 @@ ENDIF(BUILD_CursesDialog) IF(BUILD_QtDialog) IF(APPLE) - SET(CMAKE_INSTALL_SUBDIR + SET(CMAKE_BUNDLE_NAME "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}-${CMake_VERSION_PATCH}") IF(CMake_VERSION_DATE) - SET(CMAKE_INSTALL_SUBDIR + SET(CMAKE_BUNDLE_NAME "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}-${CMake_VERSION_DATE}") ENDIF(CMake_VERSION_DATE) + SET(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}") # make sure CMAKE_INSTALL_PREFIX ends in / STRING(LENGTH "${CMAKE_INSTALL_PREFIX}" LEN) MATH(EXPR LEN "${LEN} -1" ) @@ -430,8 +431,8 @@ IF(BUILD_QtDialog) IF(NOT "${ENDCH}" STREQUAL "/") SET(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/") ENDIF(NOT "${ENDCH}" STREQUAL "/") - SET(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}${CMAKE_INSTALL_SUBDIR}") - SET(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}${CMAKE_INSTALL_SUBDIR}/cmake-gui.app/Contents") + SET(CMAKE_INSTALL_PREFIX + "${CMAKE_INSTALL_PREFIX}${CMAKE_BUNDLE_NAME}.app/Contents") ENDIF(APPLE) SET(QT_NEED_RPATH FALSE) diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 2e61c296f..de13a7e73 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -55,6 +55,10 @@ ELSE(NOT QT4_FOUND) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) ADD_EXECUTABLE(cmake-gui WIN32 MACOSX_BUNDLE ${SRCS}) + IF(APPLE) + SET_TARGET_PROPERTIES(cmake-gui PROPERTIES + OUTPUT_NAME ${CMAKE_BUNDLE_NAME}) + ENDIF(APPLE) TARGET_LINK_LIBRARIES(cmake-gui CMakeLib ${QT_QTMAIN_LIBRARY} ${QT_LIBRARIES}) IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.4) SET(CMAKE_INSTALL_DESTINATION_ARGS @@ -84,8 +88,10 @@ ELSE(NOT QT4_FOUND) "${CMake_BINARY_DIR}/Source/QtDialog/postflight.sh") configure_file("${CMake_SOURCE_DIR}/Source/QtDialog/postupgrade.sh.in" "${CMake_BINARY_DIR}/Source/QtDialog/postupgrade.sh") - INSTALL(CODE "set(input_file - \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/MacOS/cmake-gui\")") + INSTALL(CODE "execute_process(COMMAND ln -s \"../MacOS/${CMAKE_BUNDLE_NAME}\" cmake-gui + WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin)") + INSTALL(CODE "set(input_file + \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/MacOS/${CMAKE_BUNDLE_NAME}\")") INSTALL(SCRIPT "${CMake_SOURCE_DIR}/Source/QtDialog/CMakeIngestOSXBundleLibraries.cmake") ENDIF(APPLE) CONFIGURE_FILE("${QtDialog_SOURCE_DIR}/QtDialogCPack.cmake.in" diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index bdc8a662d..bf7889027 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -66,6 +66,7 @@ static const char * cmDocumentationOptions[][3] = int main(int argc, char** argv) { + cmSystemTools::FindExecutableDirectory(argv[0]); QApplication app(argc, argv); // clean out standard Qt paths for plugins, which we don't use anyway @@ -113,7 +114,12 @@ int main(int argc, char** argv) // Construct and print requested documentation. cmake hcm; hcm.AddCMakePaths(); - doc.SetCMakeRoot(hcm.GetCacheDefinition("CMAKE_ROOT")); + // just incase the install is bad avoid a seg fault + const char* root = hcm.GetCacheDefinition("CMAKE_ROOT"); + if(root) + { + doc.SetCMakeRoot(root); + } std::vector commands; std::vector compatCommands; std::map propDocs; diff --git a/Source/QtDialog/QMacInstallDialog.cxx b/Source/QtDialog/QMacInstallDialog.cxx index 28c2c1a4e..70293f82b 100644 --- a/Source/QtDialog/QMacInstallDialog.cxx +++ b/Source/QtDialog/QMacInstallDialog.cxx @@ -1,4 +1,5 @@ #include "QMacInstallDialog.h" +#include #include "cmSystemTools.h" #include #include @@ -33,6 +34,22 @@ void QMacInstallDialog::DoInstall() { QDir installDir(this->Internals->InstallPrefix->text()); std::string installTo = installDir.path().toStdString(); + if(!cmSystemTools::FileExists(installTo.c_str())) + { + QString message = tr("Build install does not exist, " + "should I create it?") + + "\n\n" + + tr("Directory: "); + message += installDir.path(); + QString title = tr("Create Directory"); + QMessageBox::StandardButton btn; + btn = QMessageBox::information(this, title, message, + QMessageBox::Yes | QMessageBox::No); + if(btn == QMessageBox::Yes) + { + cmSystemTools::MakeDirectory(installTo.c_str()); + } + } QDir cmExecDir(QApplication::applicationDirPath()); cmExecDir.cd("../bin"); QFileInfoList list = cmExecDir.entryInfoList(); diff --git a/Source/QtDialog/postflight.sh.in b/Source/QtDialog/postflight.sh.in index 88dd06659..33be35206 100755 --- a/Source/QtDialog/postflight.sh.in +++ b/Source/QtDialog/postflight.sh.in @@ -1,4 +1,3 @@ #!/bin/bash -echo "$2/@CMAKE_INSTALL_SUBDIR@/cmake-gui.app/Contents/MacOS/cmake-gui" >>/tmp/mylog -"$2/@CMAKE_INSTALL_SUBDIR@/cmake-gui.app/Contents/MacOS/cmake-gui" --mac-install +"$2@CMAKE_INSTALL_SUBDIR@/@CMAKE_BUNDLE_NAME@.app/Contents/MacOS/@CMAKE_BUNDLE_NAME@" --mac-install exit 0 diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index aa9731bb7..4aa04e3ef 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -1244,7 +1244,8 @@ void cmFileCommand bool cmFileCommand::HandleInstallDestination(cmFileInstaller& installer, std::string& destination) { - if ( destination.size() < 2 ) + // allow for / to be a valid destination + if ( destination.size() < 2 && destination != "/" ) { this->SetError("called with inapropriate arguments. " "No DESTINATION provided or ."); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 5256fd064..5e5859b3b 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -786,6 +786,19 @@ int cmake::AddCMakePaths() cMakeSelf = cmSystemTools::GetRealPath(cMakeSelf.c_str()); cMakeSelf += "/cmake"; cMakeSelf += cmSystemTools::GetExecutableExtension(); +#if __APPLE__ + // on the apple this might be the gui bundle + if(!cmSystemTools::FileExists(cMakeSelf.c_str())) + { + cMakeSelf = cmSystemTools::GetExecutableDirectory(); + cMakeSelf = cmSystemTools::GetRealPath(cMakeSelf.c_str()); + cMakeSelf += "../../../.."; + cMakeSelf = cmSystemTools::GetRealPath(cMakeSelf.c_str()); + cMakeSelf = cmSystemTools::CollapseFullPath(cMakeSelf.c_str()); + cMakeSelf += "/cmake"; + std::cerr << cMakeSelf.c_str() << "\n"; + } +#endif if(!cmSystemTools::FileExists(cMakeSelf.c_str())) { cmSystemTools::Error("CMake executable cannot be found at ",