install pkg-config file when building with cmake

This commit is contained in:
Dimitri Stolnikov 2012-05-12 12:34:21 +02:00
parent 2ed8375f39
commit 5371f206f3
2 changed files with 38 additions and 1 deletions

View File

@ -92,3 +92,39 @@ add_custom_target(uninstall
########################################################################
add_subdirectory(include)
add_subdirectory(src)
########################################################################
# Create Pkg Config File
########################################################################
FOREACH(inc ${LIBUSB_INCLUDE_DIR})
LIST(APPEND RTLSDR_PC_CFLAGS "-I${inc}")
ENDFOREACH(inc)
FOREACH(lib ${LIBUSB_LIBRARY_DIRS})
LIST(APPEND RTLSDR_PC_LIBS "-L${lib}")
ENDFOREACH(lib)
# use space-separation format for the pc file
STRING(REPLACE ";" " " RTLSDR_PC_CFLAGS "${RTLSDR_PC_CFLAGS}")
STRING(REPLACE ";" " " RTLSDR_PC_LIBS "${RTLSDR_PC_LIBS}")
# unset these vars to avoid hard-coded paths to cross environment
IF(CMAKE_CROSSCOMPILING)
UNSET(RTLSDR_PC_CFLAGS)
UNSET(RTLSDR_PC_LIBS)
ENDIF(CMAKE_CROSSCOMPILING)
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix \${prefix})
set(libdir \${exec_prefix}/lib)
set(includedir \${prefix}/include)
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/librtlsdr.pc.in
${CMAKE_CURRENT_BINARY_DIR}/librtlsdr.pc
@ONLY)
INSTALL(
FILES ${CMAKE_CURRENT_BINARY_DIR}/librtlsdr.pc
DESTINATION lib/pkgconfig
)

View File

@ -6,5 +6,6 @@ includedir=@includedir@
Name: RTL-SDR Library
Description: C Utility Library
Version: @VERSION@
Cflags: -I${includedir}/ @RTLSDR_PC_CFLAGS@
Libs: -L${libdir} -lrtlsdr -lusb-1.0
Cflags: -I${includedir}/
Libs.private: @RTLSDR_PC_LIBS@