Commit 04338427 authored by Jacek Galowicz's avatar Jacek Galowicz Committed by Peter Hoeg
Browse files

sqlitebrowser: Fix build for macOS

parent 0ca91724
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
{ lib, stdenv, mkDerivation, fetchFromGitHub, cmake
, qtbase, qttools, sqlcipher, wrapGAppsHook3, qtmacextras
{ lib, stdenv, fetchFromGitHub, cmake
, qtbase, qttools, sqlcipher, wrapQtAppsHook, qtmacextras
}:

mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
  pname = "sqlitebrowser";
  version = "3.13.0";

  src = fetchFromGitHub {
    owner = pname;
    repo = pname;
    rev = "v${version}";
    owner = "sqlitebrowser";
    repo = "sqlitebrowser";
    rev = "v${finalAttrs.version}";
    sha256 = "sha256-2U0jnL2hmrxynMxEiObl10bKFAFlCrY2hulZ/Ggqimw=";
  };

  patches = lib.optional stdenv.isDarwin ./macos.patch;

  # We should be using qscintilla from nixpkgs instead of the vendored version,
  # but qscintilla is currently in a bit of a mess as some consumers expect a
  # -qt4 or -qt5 prefix while others do not.
  # We *really* should get that cleaned up.
  buildInputs = [ qtbase sqlcipher ] ++ lib.optionals stdenv.isDarwin [ qtmacextras ];
  buildInputs = [ qtbase sqlcipher ] ++ lib.optional stdenv.isDarwin qtmacextras;

  nativeBuildInputs = [ cmake qttools wrapGAppsHook3 ];
  nativeBuildInputs = [ cmake qttools wrapQtAppsHook ];

  cmakeFlags = [
    "-Dsqlcipher=1"
    (lib.cmakeBool "ENABLE_TESTING" (finalAttrs.doCheck or false))
  ];

  doCheck = true;

  meta = with lib; {
    description = "DB Browser for SQLite";
    mainProgram = "sqlitebrowser";
@@ -33,4 +38,4 @@ mkDerivation rec {
    maintainers = with maintainers; [ peterhoeg ];
    platforms = platforms.unix;
  };
}
})
+86 −0
Original line number Diff line number Diff line
diff -ru source/CMakeLists.txt source-patched/CMakeLists.txt
--- source/CMakeLists.txt	1970-01-01 01:00:01.000000000 +0100
+++ source-patched/CMakeLists.txt	2024-09-03 11:09:48.289053141 +0200
@@ -39,9 +39,7 @@
 set(CMAKE_AUTOMOC ON)
 set(CMAKE_INCLUDE_CURRENT_DIR ON)
 
-if(APPLE)
-    add_executable(${PROJECT_NAME} MACOSX_BUNDLE)
-elseif(WIN32)
+if(WIN32)
     add_executable(${PROJECT_NAME} WIN32)
 else()
     add_executable(${PROJECT_NAME})
@@ -106,33 +104,6 @@
     list(PREPEND CMAKE_PREFIX_PATH ${QT5_PATH} ${SQLITE3_PATH})
 endif()
 
-
-if(APPLE)
-    # For Intel Mac's
-    if(EXISTS /usr/local/opt/qt5)
-        list(APPEND CMAKE_PREFIX_PATH "/usr/local/opt/qt5")
-    endif()
-
-    # For Apple Silicon Mac's
-    if(EXISTS /opt/homebrew/opt/qt5)
-        list(APPEND CMAKE_PREFIX_PATH "/opt/homebrew/opt/qt5")
-    endif()
-    if(EXISTS /opt/homebrew/opt/sqlitefts5)
-        list(PREPEND CMAKE_PREFIX_PATH "/opt/homebrew/opt/sqlitefts5")
-    endif()
-
-    # For Apple Silicon Mac's and install dependencies via our Homebrew tap(sqlitebrowser/homebrew-tap)
-    if(customTap AND EXISTS /opt/homebrew/opt/)
-        list(PREPEND CMAKE_PREFIX_PATH "/opt/homebrew/opt/sqlb-qt@5")
-        list(PREPEND CMAKE_PREFIX_PATH "/opt/homebrew/opt/sqlb-sqlite")
-
-        if(sqlcipher)
-            list(APPEND SQLCIPHER_INCLUDE_DIR "/opt/homebrew/include")
-            list(APPEND SQLCIPHER_LIBRARY "/opt/homebrew/opt/sqlb-sqlcipher/lib/libsqlcipher.0.dylib")
-        endif()
-    endif()
-endif()
-
 find_package(Qt5 REQUIRED COMPONENTS Concurrent Gui LinguistTools Network PrintSupport Test Widgets Xml)
 
 if(NOT FORCE_INTERNAL_QSCINTILLA)
@@ -439,13 +410,6 @@
     set(LIBSQLITE_NAME SQLite3)
 endif()
 
-# add extra library path for MacOS and FreeBSD
-set(EXTRAPATH APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
-if(EXTRAPATH)
-    list(PREPEND CMAKE_PREFIX_PATH /usr/local/opt/sqlite/lib)
-    list(PREPEND CMAKE_PREFIX_PATH /usr/local/opt/sqlitefts5/lib)
-endif()
-
 find_package(${LIBSQLITE_NAME})
 if (sqlcipher)
     target_link_libraries(${PROJECT_NAME} SQLCipher::SQLCipher)
@@ -510,7 +474,7 @@
     endif()
 endif()
 
-if((NOT WIN32 AND NOT APPLE) OR MINGW)
+if(NOT WIN32 OR MINGW)
     install(TARGETS ${PROJECT_NAME}
         RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
         LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
@@ -630,14 +594,6 @@
     )
 endif()
 
-if(APPLE)
-    set_target_properties(${PROJECT_NAME} PROPERTIES
-        BUNDLE True
-        OUTPUT_NAME "DB Browser for SQLite"
-        MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/src/app.plist
-    )
-endif()
-
 # CPack configuration
 set(CPACK_STRIP_FILES ON)
 set(CPACK_DEBIAN_PACKAGE_PRIORITY optional)