linphone: fix install with cmake

This commit is contained in:
Weijia Wang 2023-12-11 23:11:29 +01:00
parent 5551291f54
commit c76ffa0463
2 changed files with 35 additions and 29 deletions

View File

@ -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; {

View File

@ -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)