Commit 98c0bfb0 authored by Ghislain MARY's avatar Ghislain MARY

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

parent 0d5e84be
......@@ -22,13 +22,14 @@
cmake_minimum_required(VERSION 2.8)
project(BZRTP C)
set(BZRTP_VERSION 0.1)
option(ENABLE_STATIC "Build static library (default is shared library)." NO)
option(ENABLE_UNIT_TESTS "Enable compilation of unit tests." NO)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_PREFIX_PATH}/share/cmake/Modules)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
if(MSVC)
list(APPEND CMAKE_REQUIRED_INCLUDES ${CMAKE_PREFIX_PATH}/include/MSVC)
......@@ -86,7 +87,30 @@ if(ENABLE_TESTS)
add_subdirectory(test)
endif()
install(FILES FindBZRTP.cmake
DESTINATION share/cmake/Modules
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/BZRTPConfigVersion.cmake"
VERSION ${BZRTP_VERSION}
COMPATIBILITY AnyNewerVersion
)
export(EXPORT BZRTPTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/BZRTPTargets.cmake"
NAMESPACE BelledonneCommunications::
)
configure_file(cmake/BZRTPConfig.cmake
"${CMAKE_CURRENT_BINARY_DIR}/BZRTPConfig.cmake"
COPYONLY
)
set(ConfigPackageLocation lib/cmake/BZRTP)
install(EXPORT BZRTPTargets
FILE BZRTPTargets.cmake
NAMESPACE BelledonneCommunications::
DESTINATION ${ConfigPackageLocation}
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/BZRTPConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/BZRTPConfigVersion.cmake"
DESTINATION ${ConfigPackageLocation}
)
############################################################################
# BZRTPConfig.cmake
# 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.
#
############################################################################
#
# Config file for the bzrtp package.
# It defines the following variables:
#
# BZRTP_FOUND - system has bzrtp
# BZRTP_INCLUDE_DIRS - the bzrtp include directory
# BZRTP_LIBRARIES - The libraries needed to use bzrtp
include("${CMAKE_CURRENT_LIST_DIR}/BZRTPTargets.cmake")
get_filename_component(BZRTP_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(BZRTP_INCLUDE_DIRS "${BZRTP_CMAKE_DIR}/../../../include")
set(BZRTP_LIBRARIES BelledonneCommunications::bzrtp)
set(BZRTP_FOUND 1)
############################################################################
# FindBZRTP.txt
# Copyright (C) 2014 Belledonne Communications, Grenoble France
# FindCUnit.txt
# Copyright (C) 2015 Belledonne Communications, Grenoble France
#
############################################################################
#
......@@ -20,47 +20,39 @@
#
############################################################################
#
# - Find the bzrtp include file and library
# - Find the CUnit include file and library
#
# BZRTP_FOUND - system has bzrtp
# BZRTP_INCLUDE_DIRS - the bzrtp include directory
# BZRTP_LIBRARIES - The libraries needed to use bzrtp
# CUNIT_FOUND - system has CUnit
# CUNIT_INCLUDE_DIRS - the CUnit include directory
# CUNIT_LIBRARIES - The libraries needed to use CUnit
find_package(PolarSSL REQUIRED)
find_package(XML2)
include(CheckIncludeFile)
include(CheckLibraryExists)
set(_BZRTP_ROOT_PATHS
${WITH_BZRTP}
set(_CUNIT_ROOT_PATHS
${CMAKE_INSTALL_PREFIX}
)
find_path(BZRTP_INCLUDE_DIRS
NAMES bzrtp/bzrtp.h
HINTS _BZRTP_ROOT_PATHS
find_path(CUNIT_INCLUDE_DIRS
NAMES CUnit/CUnit.h
HINTS _CUNIT_ROOT_PATHS
PATH_SUFFIXES include
)
if(BZRTP_INCLUDE_DIRS)
set(HAVE_BZRTP_BZRTP_H 1)
if(CUNIT_INCLUDE_DIRS)
set(HAVE_CUNIT_CUNIT_H 1)
endif()
find_library(BZRTP_LIBRARIES
NAMES bzrtp
HINTS ${_BZRTP_ROOT_PATHS}
find_library(CUNIT_LIBRARIES
NAMES cunit
HINTS ${_CUNIT_ROOT_PATHS}
PATH_SUFFIXES bin lib
)
list(APPEND BZRTP_INCLUDE_DIRS ${POLARSSL_INCLUDE_DIRS})
list(APPEND BZRTP_LIBRARIES ${POLARSSL_LIBRARIES})
if(XML2_FOUND)
list(APPEND BZRTP_INCLUDE_DIRS ${XML2_INCLUDE_DIRS})
list(APPEND BZRTP_LIBRARIES ${XML2_LIBRARIES})
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(BZRTP
find_package_handle_standard_args(CUnit
DEFAULT_MSG
BZRTP_INCLUDE_DIRS BZRTP_LIBRARIES
CUNIT_INCLUDE_DIRS CUNIT_LIBRARIES
)
mark_as_advanced(BZRTP_INCLUDE_DIRS BZRTP_LIBRARIES)
mark_as_advanced(CUNIT_INCLUDE_DIRS CUNIT_LIBRARIES)
############################################################################
# FindPolarSSL.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 polarssl include file and library
#
# POLARSSL_FOUND - system has polarssl
# POLARSSL_INCLUDE_DIRS - the polarssl include directory
# POLARSSL_LIBRARIES - The libraries needed to use polarssl
include(CMakePushCheckState)
include(CheckIncludeFile)
include(CheckCSourceCompiles)
set(_POLARSSL_ROOT_PATHS
${CMAKE_INSTALL_PREFIX}
)
find_path(POLARSSL_INCLUDE_DIRS
NAMES polarssl/ssl.h
HINTS _POLARSSL_ROOT_PATHS
PATH_SUFFIXES include
)
if(POLARSSL_INCLUDE_DIRS)
set(HAVE_POLARSSL_SSL_H 1)
endif()
find_library(POLARSSL_LIBRARIES
NAMES polarssl
HINTS _POLARSSL_ROOT_PATHS
PATH_SUFFIXES bin lib
)
if(POLARSSL_LIBRARIES)
cmake_push_check_state(RESET)
set(CMAKE_REQUIRED_INCLUDES ${POLARSSL_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${POLARSSL_LIBRARIES})
check_c_source_compiles("#include <polarssl/version.h>
#include <polarssl/x509.h>
#if POLARSSL_VERSION_NUMBER >= 0x01030000
#include <polarssl/compat-1.2.h>
#endif
int main(int argc, char *argv[]) {
x509parse_crtpath(0,0);
return 0;
}"
X509PARSE_CRTPATH_OK)
cmake_pop_check_state()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PolarSSL
DEFAULT_MSG
POLARSSL_INCLUDE_DIRS POLARSSL_LIBRARIES
)
mark_as_advanced(POLARSSL_INCLUDE_DIRS POLARSSL_LIBRARIES)
############################################################################
# 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)
......@@ -46,7 +46,7 @@ else()
endif()
endif()
install(TARGETS bzrtp
install(TARGETS bzrtp EXPORT BZRTPTargets
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