diff --git a/CMakeLists.txt b/CMakeLists.txt index e58c599c..76fb62b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,14 @@ if(WIN32 AND MSVC) set(CMAKE_PREFIX_PATH "${QT5_PATH};${SQLITE3_PATH}") endif() +# See https://github.com/Homebrew/homebrew-core/issues/8392#issuecomment-325226494 +if(APPLE AND EXISTS /usr/local/opt/qt5) + # Homebrew installs Qt5 (up to at least 5.9.1) in + # /usr/local/qt5, ensure it can be found by CMake since + # it is not in the default /usr/local prefix. + list(APPEND CMAKE_PREFIX_PATH "/usr/local/opt/qt5") +endif() + find_package(Qt5 REQUIRED COMPONENTS Concurrent Gui LinguistTools Network PrintSupport Test Widgets Xml) if(NOT FORCE_INTERNAL_QSCINTILLA) @@ -418,14 +426,23 @@ else() include_directories(${QSCINTILLA_DIR}) endif() -add_executable(${PROJECT_NAME} +if(NOT APPLE) + add_executable(${PROJECT_NAME} + ${SQLB_HDR} + ${SQLB_SRC} + ${SQLB_FORM_HDR} + ${SQLB_MOC} + ${SQLB_RESOURCES_RCC} + ${SQLB_MISC}) +else() + add_executable(${PROJECT_NAME} MACOSX_BUNDLE ${SQLB_HDR} ${SQLB_SRC} ${SQLB_FORM_HDR} ${SQLB_MOC} ${SQLB_RESOURCES_RCC} ${SQLB_MISC}) - +endif() # Warnings if (ALL_WARNINGS AND CMAKE_COMPILER_IS_GNUCC) @@ -495,7 +512,7 @@ if(WIN32 AND MSVC) endif() endif() -if(NOT WIN32) +if(NOT WIN32 AND NOT APPLE) install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin LIBRARY DESTINATION lib) @@ -588,3 +605,10 @@ if(WIN32 AND MSVC) distri/winlaunch.bat DESTINATION "/") endif() + +if(APPLE) + set_target_properties(${PROJECT_NAME} PROPERTIES + BUNDLE True + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/src/app.plist + ) +endif() diff --git a/installer/macos/build_sqlitebrowser_nightly.sh b/installer/macos/build_sqlitebrowser_nightly.sh index 111d804a..8fc02f05 100755 --- a/installer/macos/build_sqlitebrowser_nightly.sh +++ b/installer/macos/build_sqlitebrowser_nightly.sh @@ -13,7 +13,7 @@ LRELEASE="$HOME/Qt/${QTVER}/clang_64/bin/lrelease" LUPDATE="$HOME/Qt/${QTVER}/clang_64/bin/lupdate" MACDEPLOYQT="$HOME/Qt/${QTVER}/clang_64/bin/macdeployqt" PATH="$PATH:/usr/local/bin:/usr/sbin" -QMAKE="$HOME/Qt/${QTVER}/clang_64/bin/qmake" +CMAKE="/usr/local/bin/cmake" # Add the sensitive values we don't want to store in this script file source ~/.db4s_secure @@ -85,13 +85,16 @@ $LRELEASE src/src.pro >>$LOG 2>&1 # Build and package standard sqlitebrowser nightly echo Build and package standard sqlitebrowser nightly >>$LOG 2>&1 +mkdir build >>$LOG 2>&1 +cd build >>$LOG 2>&1 if [ "${BUILD_TYPE}" = "debug" ]; then - $QMAKE sqlitebrowser.pro -r -spec macx-clang CONFIG+=debug CONFIG+=x86_64 CONFIG+="c++14" >>$LOG 2>&1 + $CMAKE -DCMAKE_BUILD_TYPE=Debug .. >>$LOG 2>&1 else - $QMAKE sqlitebrowser.pro -r -spec macx-clang CONFIG+=x86_64 CONFIG+="c++14" >>$LOG 2>&1 + $CMAKE .. >>$LOG 2>&1 fi make -j3 >>$LOG 2>&1 -make -j3 >>$LOG 2>&1 # Seems to need a 2nd time now, due to language files needing initialisation or something +cd .. >>$LOG 2>&1 +cp -R build/sqlitebrowser.app src/DB\ Browser\ for\ SQLite.app >>$LOG 2>&1 # Include the depencencies in the .app bundle $MACDEPLOYQT src/DB\ Browser\ for\ SQLite.app -verbose=2 -sign-for-notarization="${DEV_ID}">>$LOG 2>&1 @@ -163,13 +166,16 @@ $LRELEASE src/src.pro >>$LOG 2>&1 # Build and package sqlitebrowser with SQLCipher support echo Build and package sqlitebrowser with SQLCipher support >>$LOG 2>&1 +mkdir build >>$LOG 2>&1 +cd build >>$LOG 2>&1 if [ "${BUILD_TYPE}" = "debug" ]; then - $QMAKE sqlitebrowser.pro -r -spec macx-clang CONFIG+=debug CONFIG+=x86_64 CONFIG+=sqlcipher CONFIG+="c++14" >>$LOG 2>&1 + $CMAKE -DCMAKE_BUILD_TYPE=Debug -Dsqlcipher=1 .. >>$LOG 2>&1 else - $QMAKE sqlitebrowser.pro -r -spec macx-clang CONFIG+=x86_64 CONFIG+=sqlcipher CONFIG+="c++14" >>$LOG 2>&1 + $CMAKE -Dsqlcipher=1 .. >>$LOG 2>&1 fi make -j3 >>$LOG 2>&1 -make -j3 >>$LOG 2>&1 # Seems to need a 2nd time now, due to language files needing initialisation or something +cd .. >>$LOG 2>&1 +cp -R build/sqlitebrowser.app src/DB\ Browser\ for\ SQLite.app >>$LOG 2>&1 # Unlock the local security keychain, so signing can be done security unlock-keychain -p "${KEYCHAIN_PASSWORD}" "${HOME}/Library/Keychains/login.keychain"