mirror of
https://github.com/UltraCoderRU/libwebrtc.git
synced 2026-01-28 11:15:13 +00:00
Enhance pkg-config generation, state it inside README.md
This commit is contained in:
parent
702153c428
commit
2d2ddde88d
5 changed files with 55 additions and 4 deletions
|
|
@ -5,7 +5,7 @@ find_package(Git REQUIRED)
|
||||||
find_package(DepotTools REQUIRED)
|
find_package(DepotTools REQUIRED)
|
||||||
find_package(PythonInterp REQUIRED)
|
find_package(PythonInterp REQUIRED)
|
||||||
|
|
||||||
list(APPEND LIBWEBRTC_LIBRARIES webrtc Threads::Threads)
|
list(APPEND LIBWEBRTC_LIBRARIES webrtc)
|
||||||
|
|
||||||
if (UNIX AND NOT APPLE)
|
if (UNIX AND NOT APPLE)
|
||||||
find_package(X11 REQUIRED)
|
find_package(X11 REQUIRED)
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,39 @@ install(FILES ${CMAKE_BINARY_DIR}/LibWebRTCConfigVersion.cmake
|
||||||
#
|
#
|
||||||
# Install pkg-config file
|
# Install pkg-config file
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
|
set(prefix "${CMAKE_INSTALL_PREFIX}")
|
||||||
|
set(exec_prefix "\${prefix}")
|
||||||
|
set(libdir "${INSTALL_LIB_DIR}")
|
||||||
|
set(includedir "${INSTALL_INCLUDE_DIR}")
|
||||||
|
|
||||||
|
set(LIBWEBRTC_PC_LIBS "-L${INSTALL_LIB_DIR}" "-lwebrtc")
|
||||||
|
foreach(LIB_NAME ${LIBWEBRTC_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
if (LIB_NAME MATCHES "[\\/]")
|
||||||
|
get_filename_component(LIB_DIR "${LIB_NAME}" PATH)
|
||||||
|
get_filename_component(LIB_NAME "${LIB_NAME}" NAME_WE)
|
||||||
|
string(REGEX REPLACE "^lib(.*)" "-l\\1" LIB_NAME "${LIB_NAME}")
|
||||||
|
|
||||||
|
if (NOT ${LIB_DIR} IN_LIST LIB_DIRS)
|
||||||
|
list(APPEND LIB_DIRS ${LIB_DIR})
|
||||||
|
list(APPEND LIBWEBRTC_PC_LIBS_PRIVATE "-L${LIB_DIR}")
|
||||||
|
endif (NOT ${LIB_DIR} IN_LIST LIB_DIRS)
|
||||||
|
|
||||||
|
elseif (NOT LIB_NAME MATCHES "^-l")
|
||||||
|
set(LIB_NAME "-l${LIB_NAME}")
|
||||||
|
endif ()
|
||||||
|
list(APPEND LIBWEBRTC_PC_LIBS_PRIVATE "${LIB_NAME}")
|
||||||
|
endforeach(LIB_NAME ${LIBWEBRTC_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
|
||||||
|
foreach(DEFINITION ${LIBWEBRTC_DEFINITIONS})
|
||||||
|
list(APPEND LIBWEBRTC_PC_DEFINITIONS "-D${DEFINITION}")
|
||||||
|
endforeach(DEFINITION ${LIBWEBRTC_DEFINITIONS})
|
||||||
|
|
||||||
|
list(REMOVE_ITEM LIBWEBRTC_PC_LIBS_PRIVATE "-lwebrtc")
|
||||||
|
string(REPLACE ";" " " LIBWEBRTC_PC_DEFINITIONS "${LIBWEBRTC_PC_DEFINITIONS}")
|
||||||
|
string(REPLACE ";" " " LIBWEBRTC_PC_LIBS "${LIBWEBRTC_PC_LIBS}")
|
||||||
|
string(REPLACE ";" " " LIBWEBRTC_PC_LIBS_PRIVATE "${LIBWEBRTC_PC_LIBS_PRIVATE}")
|
||||||
|
string(REPLACE ";" " " LIBWEBRTC_PC_CXXFLAGS "${LIBWEBRTC_REQUIRED_CXX_FLAGS}")
|
||||||
|
|
||||||
configure_file(${CMAKE_MODULE_PATH}/Templates/LibWebRTC.pc.in
|
configure_file(${CMAKE_MODULE_PATH}/Templates/LibWebRTC.pc.in
|
||||||
${CMAKE_BINARY_DIR}/LibWebRTC.pc @ONLY)
|
${CMAKE_BINARY_DIR}/LibWebRTC.pc @ONLY)
|
||||||
install(FILES ${CMAKE_BINARY_DIR}/LibWebRTC.pc
|
install(FILES ${CMAKE_BINARY_DIR}/LibWebRTC.pc
|
||||||
|
|
|
||||||
|
|
@ -66,10 +66,15 @@ endif (NOT ${TARGET_CPU} IN_LIST TARGET_CPU_LIST)
|
||||||
|
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
if (ARCH_X86)
|
if (ARCH_X86)
|
||||||
set(LIBWEBRTC_REQUIRED_CXX_FLAGS "-m32")
|
list(APPEND LIBWEBRTC_REQUIRED_CXX_FLAGS "-m32")
|
||||||
endif (ARCH_X86)
|
endif (ARCH_X86)
|
||||||
|
|
||||||
set(LIBWEBRTC_REQUIRED_CXX_FLAGS "${LIBWEBRTC_REQUIRED_CXX_FLAGS} -std=gnu++0x")
|
list(APPEND LIBWEBRTC_REQUIRED_CXX_FLAGS "-std=gnu++0x")
|
||||||
|
|
||||||
|
if(THREADS_HAVE_PTHREAD_ARG)
|
||||||
|
list(APPEND LIBWEBRTC_REQUIRED_CXX_FLAGS "-pthread")
|
||||||
|
endif()
|
||||||
|
|
||||||
list(APPEND LIBWEBRTC_DEFINITIONS
|
list(APPEND LIBWEBRTC_DEFINITIONS
|
||||||
WEBRTC_POSIX _GLIBCXX_USE_CXX11_ABI=0 _CRT_SECURE_NO_WARNINGS)
|
WEBRTC_POSIX _GLIBCXX_USE_CXX11_ABI=0 _CRT_SECURE_NO_WARNINGS)
|
||||||
elseif (WIN32)
|
elseif (WIN32)
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,4 @@ Description: Google's native WebRTC implementation shipped into a single library
|
||||||
Version: @LIBWEBRTC_VERSION@
|
Version: @LIBWEBRTC_VERSION@
|
||||||
Libs: @LIBWEBRTC_PC_LIBS@
|
Libs: @LIBWEBRTC_PC_LIBS@
|
||||||
Libs.private: @LIBWEBRTC_PC_LIBS_PRIVATE@
|
Libs.private: @LIBWEBRTC_PC_LIBS_PRIVATE@
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir} @LIBWEBRTC_PC_DEFINITIONS@ @LIBWEBRTC_PC_CXXFLAGS@
|
||||||
13
README.md
13
README.md
|
|
@ -15,6 +15,12 @@ add_executable(sample ${SOURCE_FILES})
|
||||||
target_link_libraries(sample ${LIBWEBRTC_LIBRARIES})
|
target_link_libraries(sample ${LIBWEBRTC_LIBRARIES})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
It also produces a `pkg-config` file if you prefer the classic way:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ g++ `pkg-config --cflags LibWebRTC` main.cpp -o main `pkg-config --libs LibWebRTC`
|
||||||
|
```
|
||||||
|
|
||||||
## Status
|
## Status
|
||||||
|
|
||||||
The following table displays the current state of this project, including
|
The following table displays the current state of this project, including
|
||||||
|
|
@ -133,6 +139,13 @@ include(${LIBWEBRTC_USE_FILE})
|
||||||
target_link_libraries(my-app ${LIBWEBRTC_LIBRARIES})
|
target_link_libraries(my-app ${LIBWEBRTC_LIBRARIES})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
A pkg-config file is also provided, you can obtain the required compiler and
|
||||||
|
linker flags by specifying `LibWebRTC` as the package name.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ pkg-config --cflags --libs LibWebRTC
|
||||||
|
```
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
The library will be compiled and usable on the same host's platform and
|
The library will be compiled and usable on the same host's platform and
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue