Bug#978616: mediastreamer2: doesn't build correct libraries with cmake?
Gianfranco Costamagna
locutusofborg at debian.org
Tue Dec 29 11:17:59 GMT 2020
This might be a patch that works if the library is found via pkgconfig but not via cmake
--- mediastreamer2-4.4.21.orig/src/CMakeLists.txt
+++ mediastreamer2-4.4.21/src/CMakeLists.txt
@@ -495,12 +495,16 @@ if(ENABLE_STATIC)
)
endif()
if(ENABLE_SHARED)
- add_library(mediastreamer SHARED ${MEDIASTREAMER2_HEADER_FILES} ${SOURCE_FILES_ALL})
- set_target_properties(mediastreamer PROPERTIES LINKER_LANGUAGE CXX)
+ add_library(mediastreamer_base SHARED ${MEDIASTREAMER2_HEADER_FILES} ${BASE_SOURCE_FILES_C})
+ set_target_properties(mediastreamer_base PROPERTIES LINKER_LANGUAGE CXX)
+ add_library(mediastreamer_voip SHARED ${MEDIASTREAMER2_HEADER_FILES} ${VOIP_SOURCE_FILES_ALL})
+ set_target_properties(mediastreamer_voip PROPERTIES LINKER_LANGUAGE CXX)
if(LINK_FLAGS_STR)
- set_target_properties(mediastreamer PROPERTIES LINK_FLAGS "${LINK_FLAGS_STR}")
+ set_target_properties(mediastreamer_base PROPERTIES LINK_FLAGS "${LINK_FLAGS_STR}")
+ set_target_properties(mediastreamer_voip PROPERTIES LINK_FLAGS "${LINK_FLAGS_STR}")
endif()
- add_dependencies(mediastreamer ${MS2_DEPENDENCIES})
+ add_dependencies(mediastreamer_base ${MS2_DEPENDENCIES})
+ add_dependencies(mediastreamer_voip ${MS2_DEPENDENCIES})
if(APPLE)
if(IOS)
set(MIN_OS ${LINPHONE_IOS_DEPLOYMENT_TARGET})
@@ -526,14 +530,21 @@ if(ENABLE_SHARED)
endif()
else()
# Do not version shared library on Android
- set_target_properties(mediastreamer PROPERTIES SOVERSION ${MEDIASTREAMER_SO_VERSION})
+ set_target_properties(mediastreamer_base PROPERTIES SOVERSION ${MEDIASTREAMER_SO_VERSION})
+ set_target_properties(mediastreamer_voip PROPERTIES SOVERSION ${MEDIASTREAMER_SO_VERSION})
endif()
- target_include_directories(mediastreamer INTERFACE
+ target_include_directories(mediastreamer_base INTERFACE
$<INSTALL_INTERFACE:include/>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/>
PRIVATE ${MEDIASTREAMER2_INCLUDE_DIRS}
)
- target_link_libraries(mediastreamer PRIVATE ${LINK_LIBS})
+ target_include_directories(mediastreamer_voip INTERFACE
+ $<INSTALL_INTERFACE:include/>
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/>
+ PRIVATE ${MEDIASTREAMER2_INCLUDE_DIRS}
+ )
+ target_link_libraries(mediastreamer_base PRIVATE ${LINK_LIBS})
+ target_link_libraries(mediastreamer_voip PRIVATE ${LINK_LIBS})
if(IOS)
target_link_libraries(mediastreamer INTERFACE "-framework Foundation" "-framework AVFoundation")
endif()
@@ -545,7 +556,14 @@ if(ENABLE_SHARED)
)
endif()
endif()
- install(TARGETS mediastreamer EXPORT ${EXPORT_TARGETS_NAME}Targets
+ install(TARGETS mediastreamer_base EXPORT ${EXPORT_TARGETS_NAME}Targets
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ FRAMEWORK DESTINATION Frameworks
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+ )
+ install(TARGETS mediastreamer_voip EXPORT ${EXPORT_TARGETS_NAME}Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
--- mediastreamer2-4.4.21.orig/tools/CMakeLists.txt
+++ mediastreamer2-4.4.21/tools/CMakeLists.txt
@@ -28,7 +28,7 @@ if (IOS)
endif()
if(ENABLE_SHARED)
- set(MS2_LIBS_FOR_TOOLS mediastreamer)
+ set(MS2_LIBS_FOR_TOOLS mediastreamer_voip mediastreamer_base)
else()
set(MS2_LIBS_FOR_TOOLS mediastreamer-static)
if(XV_FOUND)
--- mediastreamer2-4.4.21.orig/cmake/Mediastreamer2Config.cmake.in
+++ mediastreamer2-4.4.21/cmake/Mediastreamer2Config.cmake.in
@@ -36,7 +36,7 @@ include(CMakeFindDependencyMacro)
include("${CMAKE_CURRENT_LIST_DIR}/Mediastreamer2Targets.cmake")
if(@ENABLE_SHARED@)
- set(MEDIASTREAMER2_TARGETNAME mediastreamer)
+ set(MEDIASTREAMER2_TARGETNAME mediastreamer_voip mediastreamer_base)
set(MEDIASTREAMER2_LIBRARIES ${MEDIASTREAMER2_TARGETNAME})
else()
set(MEDIASTREAMER2_TARGETNAME mediastreamer-static)
I don't understand how such interfaces work...
G.
I tried a simple CMakeLists.txt
project(foo)
cmake_minimum_required(VERSION 3.18)
find_package(Mediastreamer2 REQUIRED)
add_executable(main main.c)
target_link_libraries(main mediastreamer2)
but fails with:
cmake ..
-- The C compiler identification is GNU 10.2.1
-- The CXX compiler identification is GNU 10.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at /usr/share/Mediastreamer2/cmake/Mediastreamer2Config.cmake:68 (get_target_property):
get_target_property() called with non-existent target "mediastreamer".
Call Stack (most recent call first):
CMakeLists.txt:3 (find_package)
CMake Error at /usr/share/Mediastreamer2/cmake/Mediastreamer2Config.cmake:76 (get_target_property):
get_target_property() called with non-existent target "mediastreamer".
Call Stack (most recent call first):
CMakeLists.txt:3 (find_package)
-- Configuring incomplete, errors occurred!
See also "/foo/foo/CMakeFiles/CMakeOutput.log".
More information about the Pkg-voip-maintainers
mailing list