Commit ce1126b2 authored by Ghislain MARY's avatar Ghislain MARY

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

parent ed92d805
......@@ -53,7 +53,6 @@ cmake_dependent_option(ENABLE_ASSISTANT "Turn on assistant compiling." YES "ENAB
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/share/cmake/Modules")
include(CheckIncludeFile)
include(CheckSymbolExists)
......@@ -88,10 +87,7 @@ if(ENABLE_TUNNEL)
endif()
endif()
if(ENABLE_MSG_STORAGE)
find_package(Sqlite3)
if(NOT SQLITE3_FOUND)
message(FATAL_ERROR "Could not find the sqlite3 library!")
endif()
find_package(Sqlite3 REQUIRED)
endif()
if(ENABLE_NOTIFY)
find_package(Notify)
......@@ -200,9 +196,29 @@ if(ENABLE_UNIT_TESTS)
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindLinphone.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FindLinphone.cmake)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/LinphoneConfigVersion.cmake"
VERSION ${LINPHONE_VERSION}
COMPATIBILITY AnyNewerVersion
)
export(EXPORT LinphoneTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/LinphoneTargets.cmake"
NAMESPACE BelledonneCommunications::
)
configure_file(cmake/LinphoneConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/LinphoneConfig.cmake"
@ONLY
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FindLinphone.cmake
DESTINATION share/cmake/Modules
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
set(ConfigPackageLocation lib/cmake/Linphone)
install(EXPORT LinphoneTargets
FILE LinphoneTargets.cmake
NAMESPACE BelledonneCommunications::
DESTINATION ${ConfigPackageLocation}
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/LinphoneConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/LinphoneConfigVersion.cmake"
DESTINATION ${ConfigPackageLocation}
)
############################################################################
# FindCUnit.txt
# Copyright (C) 2015 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
#
# - Find the CUnit include file and library
#
# CUNIT_FOUND - system has CUnit
# CUNIT_INCLUDE_DIRS - the CUnit include directory
# CUNIT_LIBRARIES - The libraries needed to use CUnit
include(CheckIncludeFile)
include(CheckLibraryExists)
set(_CUNIT_ROOT_PATHS
${CMAKE_INSTALL_PREFIX}
)
find_path(CUNIT_INCLUDE_DIRS
NAMES CUnit/CUnit.h
HINTS _CUNIT_ROOT_PATHS
PATH_SUFFIXES include
)
if(CUNIT_INCLUDE_DIRS)
set(HAVE_CUNIT_CUNIT_H 1)
endif()
find_library(CUNIT_LIBRARIES
NAMES cunit
HINTS ${_CUNIT_ROOT_PATHS}
PATH_SUFFIXES bin lib
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CUnit
DEFAULT_MSG
CUNIT_INCLUDE_DIRS CUNIT_LIBRARIES
)
mark_as_advanced(CUNIT_INCLUDE_DIRS CUNIT_LIBRARIES)
......@@ -27,7 +27,6 @@
# ICONV_LIBRARIES - The libraries needed to use libiconv
set(_ICONV_ROOT_PATHS
${WITH_ICONV}
${CMAKE_INSTALL_PREFIX}
)
......
......@@ -27,7 +27,6 @@
# INTL_LIBRARIES - The libraries needed to use libintl
set(_INTL_ROOT_PATHS
${WITH_INTL}
${CMAKE_INSTALL_PREFIX}
)
......
......@@ -27,7 +27,6 @@
# NOTIFY_LIBRARIES - The libraries needed to use libnotify
set(_NOTIFY_ROOT_PATHS
${WITH_NOTIFY}
${CMAKE_INSTALL_PREFIX}
)
......
......@@ -32,7 +32,6 @@ endif()
find_package(GTK2 2.18 REQUIRED gtk)
set(_SOUP_ROOT_PATHS
${WITH_SOUP}
${CMAKE_INSTALL_PREFIX}
)
......
############################################################################
# FindSqlite3.cmake
# Copyright (C) 2014 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
#
# - Find the sqlite3 include file and library
#
# SQLITE3_FOUND - system has sqlite3
# SQLITE3_INCLUDE_DIRS - the sqlite3 include directory
# SQLITE3_LIBRARIES - The libraries needed to use sqlite3
set(_SQLITE3_ROOT_PATHS
${CMAKE_INSTALL_PREFIX}
)
find_path(SQLITE3_INCLUDE_DIRS
NAMES sqlite3.h
HINTS _SQLITE3_ROOT_PATHS
PATH_SUFFIXES include
)
if(SQLITE3_INCLUDE_DIRS)
set(HAVE_SQLITE3_H 1)
endif()
find_library(SQLITE3_LIBRARIES
NAMES sqlite3
HINTS ${_SQLITE3_ROOT_PATHS}
PATH_SUFFIXES bin lib
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Sqlite3
DEFAULT_MSG
SQLITE3_INCLUDE_DIRS SQLITE3_LIBRARIES HAVE_SQLITE3_H
)
mark_as_advanced(SQLITE3_INCLUDE_DIRS SQLITE3_LIBRARIES HAVE_SQLITE3_H)
############################################################################
# FindXML2.txt
# Copyright (C) 2015 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
#
# - Find the libxml2 include file and library
#
# XML2_FOUND - system has libxml2
# XML2_INCLUDE_DIRS - the libxml2 include directory
# XML2_LIBRARIES - The libraries needed to use libxml2
set(_XML2_ROOT_PATHS
${CMAKE_INSTALL_PREFIX}
)
find_path(XML2_INCLUDE_DIRS
NAMES libxml/xmlreader.h
HINTS _XML2_ROOT_PATHS
PATH_SUFFIXES include/libxml2
)
if(XML2_INCLUDE_DIRS)
set(HAVE_LIBXML_XMLREADER_H 1)
endif()
find_library(XML2_LIBRARIES
NAMES xml2
HINTS ${_XML2_ROOT_PATHS}
PATH_SUFFIXES bin lib
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(XML2
DEFAULT_MSG
XML2_INCLUDE_DIRS XML2_LIBRARIES
)
mark_as_advanced(XML2_INCLUDE_DIRS XML2_LIBRARIES)
############################################################################
# FindLinphone.cmake
# Copyright (C) 2014 Belledonne Communications, Grenoble France
# LinphoneConfig.cmake
# Copyright (C) 2015 Belledonne Communications, Grenoble France
#
############################################################################
#
......@@ -20,64 +20,25 @@
#
############################################################################
#
# - Find the linphone include file and library
# Config file for the belle-sip package.
# It defines the following variables:
#
# LINPHONE_FOUND - system has linphone
# LINPHONE_INCLUDE_DIRS - the linphone include directory
# LINPHONE_LIBRARIES - The libraries needed to use linphone
# LINPHONE_CPPFLAGS - The compilation flags needed to use linphone
# LINPHONE_LDFLAGS - The linking flags needed to use linphone
find_package(ORTP REQUIRED)
find_package(MS2 REQUIRED)
find_package(XML2 REQUIRED)
find_package(BelleSIP REQUIRED)
if(@ENABLE_MSG_STORAGE@)
find_package(Sqlite3)
include("${CMAKE_CURRENT_LIST_DIR}/LinphoneTargets.cmake")
if(@ENABLE_TUNNEL@)
find_package(Tunnel)
endif()
set(_LINPHONE_ROOT_PATHS
${WITH_LINPHONE}
${CMAKE_INSTALL_PREFIX}
)
find_path(LINPHONE_INCLUDE_DIRS
NAMES linphone/linphonecore.h
HINTS _LINPHONE_ROOT_PATHS
PATH_SUFFIXES include
)
if(LINPHONE_INCLUDE_DIRS)
set(HAVE_LINPHONE_LINPHONECORE_H 1)
endif()
find_library(LINPHONE_LIBRARIES
NAMES linphone
HINTS ${_LINPHONE_ROOT_PATHS}
PATH_SUFFIXES bin lib
)
list(APPEND LINPHONE_INCLUDE_DIRS ${ORTP_INCLUDE_DIRS} ${MS2_INCLUDE_DIRS} ${XML2_INCLUDE_DIRS} ${BELLESIP_INCLUDE_DIRS})
list(APPEND LINPHONE_LIBRARIES ${ORTP_LIBRARIES} ${MS2_LIBRARIES} ${XML2_LIBRARIES} ${BELLESIP_LIBRARIES})
if(SQLITE3_FOUND)
list(APPEND LINPHONE_INCLUDE_DIRS ${SQLITE3_INCLUDE_DIRS})
list(APPEND LINPHONE_LIBRARIES ${SQLITE3_LIBRARIES})
get_filename_component(LINPHONE_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(LINPHONE_INCLUDE_DIRS "${LINPHONE_CMAKE_DIR}/../../../include")
set(LINPHONE_LIBRARIES BelledonneCommunications::linphone)
set(LINPHONE_LDFLAGS @LINK_FLAGS@)
if(TUNNEL_FOUND)
list(APPEND LINPHONE_INCLUDE_DIRS ${TUNNEL_INCLUDE_DIRS})
list(APPEND LINPHONE_LIBRARIES ${TUNNEL_LIBRARIES})
endif()
if(WIN32)
list(APPEND LINPHONE_LIBRARIES shlwapi)
endif(WIN32)
list(REMOVE_DUPLICATES LINPHONE_INCLUDE_DIRS)
list(REMOVE_DUPLICATES LINPHONE_LIBRARIES)
set(LINPHONE_CPPFLAGS "${MS2_CPPFLAGS}")
set(LINPHONE_LDFLAGS "${MS2_LDFLAGS} ${BELLESIP_LDFLAGS}")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Linphone
DEFAULT_MSG
LINPHONE_INCLUDE_DIRS LINPHONE_LIBRARIES
)
mark_as_advanced(LINPHONE_INCLUDE_DIRS LINPHONE_LIBRARIES LINPHONE_CPPFLAGS LINPHONE_LDFLAGS)
set(LINPHONE_FOUND 1)
......@@ -159,7 +159,7 @@ if(ICONV_FOUND)
target_include_directories(linphone PUBLIC ${ICONV_INCLUDE_DIRS})
endif()
install(TARGETS linphone
install(TARGETS linphone EXPORT LinphoneTargets
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