about summary refs log tree commit diff
path: root/pkgs/applications/networking/instant-messengers/linphone
diff options
context:
space:
mode:
authorWeijia Wang <9713184+wegank@users.noreply.github.com>2023-12-11 23:11:29 +0100
committerWeijia Wang <9713184+wegank@users.noreply.github.com>2023-12-11 23:11:29 +0100
commitc76ffa0463d45654ea2967456a185d7c913a0b4a (patch)
treed206b936131ea7743ff4d7514431cb601660f219 /pkgs/applications/networking/instant-messengers/linphone
parent5551291f546c3302534d27d2a51ea5fcf5b6a457 (diff)
linphone: fix install with cmake
Diffstat (limited to 'pkgs/applications/networking/instant-messengers/linphone')
-rw-r--r--pkgs/applications/networking/instant-messengers/linphone/default.nix46
-rw-r--r--pkgs/applications/networking/instant-messengers/linphone/reset-output-dirs.patch18
2 files changed, 35 insertions, 29 deletions
diff --git a/pkgs/applications/networking/instant-messengers/linphone/default.nix b/pkgs/applications/networking/instant-messengers/linphone/default.nix
index c57598e6205cd..1d930612e9f9f 100644
--- a/pkgs/applications/networking/instant-messengers/linphone/default.nix
+++ b/pkgs/applications/networking/instant-messengers/linphone/default.nix
@@ -49,6 +49,7 @@ mkDerivation rec {
     ./do-not-build-linphone-sdk.patch
     ./remove-bc_compute_full_version-usage.patch
     ./no-store-path-in-autostart.patch
+    ./reset-output-dirs.patch
   ];
 
   # See: https://gitlab.linphone.org/BC/public/linphone-desktop/issues/21
@@ -56,6 +57,8 @@ mkDerivation rec {
     echo "project(linphoneqt VERSION ${version})" >linphone-app/linphoneqt_version.cmake
     substituteInPlace linphone-app/src/app/AppController.cpp \
       --replace "APPLICATION_SEMVER" "\"${version}\""
+    substituteInPlace CMakeLists.txt \
+      --subst-var out
   '';
 
   # TODO: After linphone-desktop and liblinphone split into separate packages,
@@ -91,23 +94,17 @@ mkDerivation rec {
 
     # Requires EQt5Keychain
     "-DENABLE_QT_KEYCHAIN=OFF"
+
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
   ];
 
-  # The default install phase fails because the paths are somehow messed up in
-  # the makefiles. The errors were like:
-  #
-  #   CMake Error at cmake_builder/linphone_package/cmake_install.cmake:49 (file):
-  #     file INSTALL cannot find
-  #     "/build/linphone-desktop-.../build/linphone-sdk/desktop//nix/store/.../bin":
-  #     No such file or directory.
-  #
-  # If someone is able to figure out how to fix that, great. For now, just
-  # trying to pick all the relevant files to the output.
-  #
-  # Also, the exec path in linphone.desktop file remains invalid, pointing to
-  # the build directory, after the whole nix build process. So, let's use sed to
-  # manually fix that path.
-  #
+  preInstall = ''
+    mkdir -p $out/share/linphone
+    mkdir -p $out/share/sounds/linphone
+  '';
+
   # In order to find mediastreamer plugins, mediastreamer package was patched to
   # support an environment variable pointing to the plugin directory. Set that
   # environment variable by wrapping the Linphone executable.
@@ -121,26 +118,17 @@ mkDerivation rec {
   # It is quite likely that there are some other files still missing and
   # Linphone will randomly crash when it tries to access those files. Then,
   # those just need to be copied manually below.
-  installPhase = ''
-    mkdir -p $out/bin $out/lib
-    cp linphone-app/linphone $out/bin/
-    cp linphone-app/libapp-plugin.so $out/lib/
+  postInstall = ''
     mkdir -p $out/lib/mediastreamer/plugins
     ln -s ${mediastreamer-openh264}/lib/mediastreamer/plugins/* $out/lib/mediastreamer/plugins/
     ln -s ${mediastreamer}/lib/mediastreamer/plugins/* $out/lib/mediastreamer/plugins/
-    wrapProgram $out/bin/linphone \
-      --set MEDIASTREAMER_PLUGINS_DIR \
-            $out/lib/mediastreamer/plugins
-    mkdir -p $out/share/applications
-    cp linphone-app/linphone.desktop $out/share/applications/
-    mkdir -p $out/share/icons/hicolor/scalable/apps
-    cp ../linphone-app/assets/images/linphone_logo.svg $out/share/icons/hicolor/scalable/apps/linphone.svg
+
     mkdir -p $out/share/belr/grammars
     ln -s ${liblinphone}/share/belr/grammars/* $out/share/belr/grammars/
     ln -s ${belle-sip}/share/belr/grammars/* $out/share/belr/grammars/
-    mkdir -p $out/share/linphone
-    ln -s ${liblinphone}/share/linphone/* $out/share/linphone/
-    ln -s ${liblinphone}/share/sounds $out/share/sounds
+
+    wrapProgram $out/bin/linphone \
+      --set MEDIASTREAMER_PLUGINS_DIR $out/lib/mediastreamer/plugins
   '';
 
   meta = with lib; {
diff --git a/pkgs/applications/networking/instant-messengers/linphone/reset-output-dirs.patch b/pkgs/applications/networking/instant-messengers/linphone/reset-output-dirs.patch
new file mode 100644
index 0000000000000..2ad43fb17e280
--- /dev/null
+++ b/pkgs/applications/networking/instant-messengers/linphone/reset-output-dirs.patch
@@ -0,0 +1,18 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index b5a4ab5..b6b89c2 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -59,10 +59,10 @@ set(CMAKE_CXX_STANDARD 11)
+ 
+ # Prepare gobal CMAKE configuration specific to the current project
+ set(SDK_BUILD_DIR "${CMAKE_BINARY_DIR}/WORK")       # SDK build in WORK. Keep all in it.
+-set(LINPHONE_OUTPUT_DIR "${CMAKE_BINARY_DIR}/linphone-sdk/desktop")
+-set(QTKEYCHAIN_OUTPUT_DIR "${CMAKE_BINARY_DIR}/qtkeychain")
++set(LINPHONE_OUTPUT_DIR "@out@")
++set(QTKEYCHAIN_OUTPUT_DIR "@out@")
+ set(QTKEYCHAIN_TARGET_NAME "EQt5Keychain")
+-set(APPLICATION_OUTPUT_DIR "${CMAKE_BINARY_DIR}/OUTPUT")
++set(APPLICATION_OUTPUT_DIR "@out@")
+ 
+ set(CMAKE_PREFIX_PATH "${LINPHONE_OUTPUT_DIR};${APPLICATION_OUTPUT_DIR};${APPLICATION_OUTPUT_DIR}/include${PREFIX_PATH}")
+ if(WIN32)