ENH: install the mac application bundle into /Applications directly with no enclosing folder

This commit is contained in:
Bill Hoffman 2008-04-04 16:02:50 -04:00
parent d1c660d495
commit 45ce11a075
7 changed files with 53 additions and 10 deletions

View File

@ -417,12 +417,13 @@ ENDIF(BUILD_CursesDialog)
IF(BUILD_QtDialog) IF(BUILD_QtDialog)
IF(APPLE) IF(APPLE)
SET(CMAKE_INSTALL_SUBDIR SET(CMAKE_BUNDLE_NAME
"CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}-${CMake_VERSION_PATCH}") "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}-${CMake_VERSION_PATCH}")
IF(CMake_VERSION_DATE) IF(CMake_VERSION_DATE)
SET(CMAKE_INSTALL_SUBDIR SET(CMAKE_BUNDLE_NAME
"CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}-${CMake_VERSION_DATE}") "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}-${CMake_VERSION_DATE}")
ENDIF(CMake_VERSION_DATE) ENDIF(CMake_VERSION_DATE)
SET(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}")
# make sure CMAKE_INSTALL_PREFIX ends in / # make sure CMAKE_INSTALL_PREFIX ends in /
STRING(LENGTH "${CMAKE_INSTALL_PREFIX}" LEN) STRING(LENGTH "${CMAKE_INSTALL_PREFIX}" LEN)
MATH(EXPR LEN "${LEN} -1" ) MATH(EXPR LEN "${LEN} -1" )
@ -430,8 +431,8 @@ IF(BUILD_QtDialog)
IF(NOT "${ENDCH}" STREQUAL "/") IF(NOT "${ENDCH}" STREQUAL "/")
SET(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/") SET(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/")
ENDIF(NOT "${ENDCH}" STREQUAL "/") ENDIF(NOT "${ENDCH}" STREQUAL "/")
SET(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}${CMAKE_INSTALL_SUBDIR}") SET(CMAKE_INSTALL_PREFIX
SET(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}${CMAKE_INSTALL_SUBDIR}/cmake-gui.app/Contents") "${CMAKE_INSTALL_PREFIX}${CMAKE_BUNDLE_NAME}.app/Contents")
ENDIF(APPLE) ENDIF(APPLE)
SET(QT_NEED_RPATH FALSE) SET(QT_NEED_RPATH FALSE)

View File

@ -55,6 +55,10 @@ ELSE(NOT QT4_FOUND)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
ADD_EXECUTABLE(cmake-gui WIN32 MACOSX_BUNDLE ${SRCS}) 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}) TARGET_LINK_LIBRARIES(cmake-gui CMakeLib ${QT_QTMAIN_LIBRARY} ${QT_LIBRARIES})
IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.4) IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.4)
SET(CMAKE_INSTALL_DESTINATION_ARGS SET(CMAKE_INSTALL_DESTINATION_ARGS
@ -84,8 +88,10 @@ ELSE(NOT QT4_FOUND)
"${CMake_BINARY_DIR}/Source/QtDialog/postflight.sh") "${CMake_BINARY_DIR}/Source/QtDialog/postflight.sh")
configure_file("${CMake_SOURCE_DIR}/Source/QtDialog/postupgrade.sh.in" configure_file("${CMake_SOURCE_DIR}/Source/QtDialog/postupgrade.sh.in"
"${CMake_BINARY_DIR}/Source/QtDialog/postupgrade.sh") "${CMake_BINARY_DIR}/Source/QtDialog/postupgrade.sh")
INSTALL(CODE "set(input_file INSTALL(CODE "execute_process(COMMAND ln -s \"../MacOS/${CMAKE_BUNDLE_NAME}\" cmake-gui
\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/MacOS/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") INSTALL(SCRIPT "${CMake_SOURCE_DIR}/Source/QtDialog/CMakeIngestOSXBundleLibraries.cmake")
ENDIF(APPLE) ENDIF(APPLE)
CONFIGURE_FILE("${QtDialog_SOURCE_DIR}/QtDialogCPack.cmake.in" CONFIGURE_FILE("${QtDialog_SOURCE_DIR}/QtDialogCPack.cmake.in"

View File

@ -66,6 +66,7 @@ static const char * cmDocumentationOptions[][3] =
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
cmSystemTools::FindExecutableDirectory(argv[0]);
QApplication app(argc, argv); QApplication app(argc, argv);
// clean out standard Qt paths for plugins, which we don't use anyway // 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. // Construct and print requested documentation.
cmake hcm; cmake hcm;
hcm.AddCMakePaths(); 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<cmDocumentationEntry> commands; std::vector<cmDocumentationEntry> commands;
std::vector<cmDocumentationEntry> compatCommands; std::vector<cmDocumentationEntry> compatCommands;
std::map<std::string,cmDocumentationSection *> propDocs; std::map<std::string,cmDocumentationSection *> propDocs;

View File

@ -1,4 +1,5 @@
#include "QMacInstallDialog.h" #include "QMacInstallDialog.h"
#include <QMessageBox>
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include <iostream> #include <iostream>
#include <QFileDialog> #include <QFileDialog>
@ -33,6 +34,22 @@ void QMacInstallDialog::DoInstall()
{ {
QDir installDir(this->Internals->InstallPrefix->text()); QDir installDir(this->Internals->InstallPrefix->text());
std::string installTo = installDir.path().toStdString(); 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()); QDir cmExecDir(QApplication::applicationDirPath());
cmExecDir.cd("../bin"); cmExecDir.cd("../bin");
QFileInfoList list = cmExecDir.entryInfoList(); QFileInfoList list = cmExecDir.entryInfoList();

View File

@ -1,4 +1,3 @@
#!/bin/bash #!/bin/bash
echo "$2/@CMAKE_INSTALL_SUBDIR@/cmake-gui.app/Contents/MacOS/cmake-gui" >>/tmp/mylog "$2@CMAKE_INSTALL_SUBDIR@/@CMAKE_BUNDLE_NAME@.app/Contents/MacOS/@CMAKE_BUNDLE_NAME@" --mac-install
"$2/@CMAKE_INSTALL_SUBDIR@/cmake-gui.app/Contents/MacOS/cmake-gui" --mac-install
exit 0 exit 0

View File

@ -1244,7 +1244,8 @@ void cmFileCommand
bool cmFileCommand::HandleInstallDestination(cmFileInstaller& installer, bool cmFileCommand::HandleInstallDestination(cmFileInstaller& installer,
std::string& destination) 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. " this->SetError("called with inapropriate arguments. "
"No DESTINATION provided or ."); "No DESTINATION provided or .");

View File

@ -786,6 +786,19 @@ int cmake::AddCMakePaths()
cMakeSelf = cmSystemTools::GetRealPath(cMakeSelf.c_str()); cMakeSelf = cmSystemTools::GetRealPath(cMakeSelf.c_str());
cMakeSelf += "/cmake"; cMakeSelf += "/cmake";
cMakeSelf += cmSystemTools::GetExecutableExtension(); 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())) if(!cmSystemTools::FileExists(cMakeSelf.c_str()))
{ {
cmSystemTools::Error("CMake executable cannot be found at ", cmSystemTools::Error("CMake executable cannot be found at ",