Commit c53b0501 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Use a config-file package instead of a find-module package in CMake.

parent 6c715fb5
############################################################################
# FindBelleSIP.txt
# Copyright (C) 2014 Belledonne Communications, Grenoble France
# BelleSIPConfig.cmake
# Copyright (C) 2015 Belledonne Communications, Grenoble France
#
############################################################################
#
......@@ -20,64 +20,16 @@
#
############################################################################
#
# - Find the belle-sip include file and library
# Config file for the belle-sip package.
# It defines the following variables:
#
# BELLESIP_FOUND - system has belle-sip
# BELLESIP_INCLUDE_DIRS - the belle-sip include directory
# BELLESIP_LIBRARIES - The libraries needed to use belle-sip
# BELLESIP_LDFLAGS - The linking flags needed to use belle-sip
find_package(Antlr3 REQUIRED)
find_package(PolarSSL)
include("${CMAKE_CURRENT_LIST_DIR}/BelleSIPTargets.cmake")
set(_BELLESIP_ROOT_PATHS
${WITH_BELLESIP}
${CMAKE_INSTALL_PREFIX}
)
find_path(BELLESIP_INCLUDE_DIRS
NAMES belle-sip/belle-sip.h
HINTS _BELLESIP_ROOT_PATHS
PATH_SUFFIXES include
)
if(BELLESIP_INCLUDE_DIRS)
set(HAVE_BELLESIP_BELLESIP_H 1)
endif()
find_library(BELLESIP_LIBRARIES
NAMES bellesip
HINTS ${_BELLESIP_ROOT_PATHS}
PATH_SUFFIXES bin lib
)
if(@HAVE_LIBDL@)
list(APPEND BELLESIP_LIBRARIES dl)
endif()
if(@HAVE_LIBRT@)
list(APPEND BELLESIP_LIBRARIES rt)
endif()
if(@HAVE_RESINIT@)
list(APPEND BELLESIP_LIBRARIES resolv)
endif()
if(APPLE)
set(BELLESIP_LDFLAGS "-framework CoreFoundation -framework CFNetwork")
endif()
if(ANTLR3C_FOUND)
list(APPEND BELLESIP_INCLUDE_DIRS ${ANTLR3C_INCLUDE_DIRS})
list(APPEND BELLESIP_LIBRARIES ${ANTLR3C_LIBRARIES})
endif()
if(POLARSSL_FOUND)
list(APPEND BELLESIP_INCLUDE_DIRS ${POLARSSL_INCLUDE_DIRS})
list(APPEND BELLESIP_LIBRARIES ${POLARSSL_LIBRARIES})
endif()
list(REMOVE_DUPLICATES BELLESIP_INCLUDE_DIRS)
list(REMOVE_DUPLICATES BELLESIP_LIBRARIES)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(BelleSIP
DEFAULT_MSG
BELLESIP_INCLUDE_DIRS BELLESIP_LIBRARIES
)
mark_as_advanced(BELLESIP_INCLUDE_DIRS BELLESIP_LIBRARIES BELLESIP_LDFLAGS)
get_filename_component(BELLESIP_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(BELLESIP_INCLUDE_DIRS "${BELLESIP_CMAKE_DIR}/../../../include")
set(BELLESIP_LIBRARIES BelledonneCommunications::bellesip)
set(BELLESIP_FOUND 1)
......@@ -164,12 +164,6 @@ if(WIN32)
)
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/FindBelleSIP.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FindBelleSIP.cmake @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FindBelleSIP.cmake
DESTINATION share/cmake/Modules
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
add_subdirectory(include)
add_subdirectory(src)
......@@ -179,3 +173,31 @@ if(ENABLE_TESTS)
enable_testing()
add_subdirectory(tester)
endif()
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/BelleSIPConfigVersion.cmake"
VERSION ${PACKAGE_VERSION}
COMPATIBILITY AnyNewerVersion
)
export(EXPORT BelleSIPTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/BelleSIPTargets.cmake"
NAMESPACE BelledonneCommunications::
)
configure_file(BelleSIPConfig.cmake
"${CMAKE_CURRENT_BINARY_DIR}/BelleSIPConfig.cmake"
COPYONLY
)
set(ConfigPackageLocation lib/cmake/BelleSIP)
install(EXPORT BelleSIPTargets
FILE BelleSIPTargets.cmake
NAMESPACE BelledonneCommunications::
DESTINATION ${ConfigPackageLocation}
)
install(FILES
BelleSIPConfig.cmake
"${CMAKE_CURRENT_BINARY_DIR}/BelleSIPConfigVersion.cmake"
DESTINATION ${ConfigPackageLocation}
)
......@@ -165,7 +165,7 @@ else()
endif()
target_link_libraries(bellesip ${LIBS})
install(TARGETS bellesip
install(TARGETS bellesip EXPORT BelleSIPTargets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment