Commit 84de5850 authored by Ghislain MARY's avatar Ghislain MARY

Allow compilation with CMake.

parent f1f3d3cb
############################################################################
# CMakeLists.txt
# 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.
#
############################################################################
cmake_minimum_required(VERSION 2.8)
project(BZRTP C)
option(ENABLE_STATIC "Build static library (default is shared library)." OFF)
option(ENABLE_UNIT_TESTS "Enable compilation of unit tests." OFF)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_PREFIX_PATH}/share/cmake/Modules)
if(${ENABLE_TESTS})
find_package(CUnit)
if(CUNIT_FOUND)
check_library_exists(${CUNIT_LIBRARIES} "CU_add_suite" "" HAVE_CU_ADD_SUITE)
check_library_exists(${CUNIT_LIBRARIES} "CU_get_suite" "" HAVE_CU_GET_SUITE)
check_library_exists(${CUNIT_LIBRARIES} "CU_curses_run_tests" "" HAVE_CU_CURSES)
else()
message(WARNING "Could not find cunit framework, tests will not be compiled.")
set(ENABLE_TESTS OFF CACHE BOOL "Enable compilation of tests" FORCE)
endif()
endif()
find_package(PolarSSL REQUIRED)
find_package(XML2)
if(XML2_FOUND)
set(HAVE_LIBXML2 1)
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/config.h PROPERTIES GENERATED ON)
add_definitions("-DHAVE_CONFIG_H")
include_directories(
include
${CMAKE_CURRENT_BINARY_DIR}
)
set(INCLUDES ${CUNIT_INCLUDE_DIRS} ${POLARSSL_INCLUDE_DIRS} ${XML2_INCLUDE_DIRS})
include_directories(${INCLUDES})
set(LIBS ${CUNIT_LIBRARIES} ${POLARSSL_LIBRARIES} ${XML2_LIBRARIES})
add_subdirectory(include)
add_subdirectory(src)
if(${ENABLE_TESTS})
enable_testing()
add_subdirectory(test)
endif()
/***************************************************************************
* config.h.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.
*
****************************************************************************/
#cmakedefine HAVE_CU_ADD_SUITE
#cmakedefine HAVE_CU_GET_SUITE
#cmakedefine HAVE_CU_CURSES
#cmakedefine HAVE_LIBXML2
file(GLOB HEADER_FILES "bzrtp/*.h")
install(FILES ${HEADER_FILES}
DESTINATION include/bzrtp
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
......@@ -34,6 +34,9 @@
#define DHPART_MESSAGE_STORE_ID 2
#define CONFIRM_MESSAGE_STORE_ID 3
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdint.h>
......
############################################################################
# CMakeLists.txt
# 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.
#
############################################################################
set(SOURCE_FILES
bzrtp.c
cryptoPolarssl.c
cryptoUtils.c
packetParser.c
stateMachine.c
zidCache.c
)
if(${ENABLE_STATIC})
add_library(bzrtp STATIC ${SOURCE_FILES})
target_link_libraries(bzrtp ${LIBS})
else(${ENABLE_STATIC})
add_library(bzrtp SHARED ${SOURCE_FILES})
set_target_properties(bzrtp PROPERTIES VERSION 0.1 SOVERSION 0)
target_link_libraries(bzrtp ${LIBS})
if(MSVC)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/bzrtp.pdb
DESTINATION bin
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif(CMAKE_BUILD_TYPE STREQUAL "Debug")
endif(MSVC)
endif(${ENABLE_STATIC})
install(TARGETS bzrtp
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
......@@ -28,11 +28,12 @@
#include <string.h>
#include "zidCache.h"
#include "typedef.h"
#ifdef HAVE_LIBXML2
#include <libxml/tree.h>
#include <libxml/parser.h>
#include "typedef.h"
#define MIN_VALID_CACHE_LENGTH 56 /* root tag + selfZID tag size */
#define XML_HEADER_STRING "<?xml version='1.0' encoding='utf-8'?>"
......
############################################################################
# CMakeLists.txt
# 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.
#
############################################################################
set(TEST_SOURCES
bzrtpCryptoTest.c
bzrtpParserTest.c
bzrtpTest.c
testUtils.c
${CMAKE_SOURCE_DIR}/src/bzrtp.c
${CMAKE_SOURCE_DIR}/src/cryptoPolarssl.c
${CMAKE_SOURCE_DIR}/src/cryptoUtils.c
${CMAKE_SOURCE_DIR}/src/packetParser.c
${CMAKE_SOURCE_DIR}/src/stateMachine.c
${CMAKE_SOURCE_DIR}/src/zidCache.c
)
add_executable(bzrtpTest ${TEST_SOURCES})
set_target_properties(bzrtpTest PROPERTIES LINK_FLAGS "${LINK_FLAGS}")
if("${CMAKE_VERSION}" VERSION_GREATER "2.8.10")
target_include_directories(bzrtpTest PUBLIC ${CUNIT_INCLUDE_DIR})
else()
include_directories(${CUNIT_INCLUDE_DIR})
endif()
target_link_libraries(bzrtpTest ${CUNIT_LIBRARIES} bzrtp)
add_test(NAME bzrtpTest COMMAND bzrtpTest)
......@@ -24,6 +24,7 @@
#include "CUnit/Basic.h"
#include "bzrtpCryptoTest.h"
#include "bzrtpParserTest.h"
#include "typedef.h"
#ifdef HAVE_LIBXML2
#include <libxml/parser.h>
......
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