CMakeLists.txt 3.01 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
############################################################################
# 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
19
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 21 22 23 24 25 26
#
############################################################################

set(SOURCE_FILES
	bzrtp.c
	cryptoUtils.c
	packetParser.c
27
	pgpwords.c
28 29 30
	stateMachine.c
	zidCache.c
)
31 32 33 34 35

add_definitions(
	-DBCTBX_LOG_DOMAIN="bzrtp"
)

36 37 38 39
if(POLARSSL_FOUND)
	list(APPEND SOURCE_FILES cryptoPolarssl.c)
elseif(MBEDTLS_FOUND)
	list(APPEND SOURCE_FILES cryptoMbedtls.c)
johan's avatar
johan committed
40
endif()
41

42
bc_apply_compile_flags(SOURCE_FILES STRICT_OPTIONS_CPP)
43

Ghislain MARY's avatar
Ghislain MARY committed
44 45 46 47 48 49
set(INCLUDE_DIRS ${BCTOOLBOX_CORE_INCLUDE_DIRS})
set(LIBS ${BCTOOLBOX_CORE_LIBRARIES})
if(SQLITE3_FOUND)
	list(APPEND INCLUDE_DIRS ${SQLITE3_INCLUDE_DIRS})
	list(APPEND LIBS ${SQLITE3_LIBRARIES})
endif()
50 51 52 53
if(XML2_FOUND)
	list(APPEND INCLUDE_DIRS ${XML2_INCLUDE_DIRS})
	list(APPEND LIBS ${XML2_LIBRARIES})
endif()
Ghislain MARY's avatar
Ghislain MARY committed
54

55
if(ENABLE_STATIC)
56
	add_library(bzrtp-static STATIC ${SOURCE_FILES})
57
	set_target_properties(bzrtp-static PROPERTIES OUTPUT_NAME bzrtp)
Ghislain MARY's avatar
Ghislain MARY committed
58
	target_include_directories(bzrtp-static PUBLIC ${INCLUDE_DIRS})
59
	target_link_libraries(bzrtp-static INTERFACE ${LIBS})
60 61 62 63 64 65
	install(TARGETS bzrtp-static EXPORT ${EXPORT_TARGETS_NAME}Targets
		ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
		PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
	)
endif()
if(ENABLE_SHARED)
66
	add_library(bzrtp SHARED ${SOURCE_FILES})
Ghislain MARY's avatar
Ghislain MARY committed
67
	target_compile_definitions(bzrtp PRIVATE "-DBZRTP_EXPORTS")
68
	set_target_properties(bzrtp PROPERTIES VERSION 0)
Ghislain MARY's avatar
Ghislain MARY committed
69
	target_include_directories(bzrtp PUBLIC ${INCLUDE_DIRS})
70
	target_link_libraries(bzrtp PRIVATE ${LIBS})
71
	if(MSVC)
72 73
		if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
			install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/bzrtp.pdb
74
				DESTINATION ${CMAKE_INSTALL_BINDIR}
75 76
				PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
			)
77 78
		endif()
	endif()
79 80 81 82 83 84
	install(TARGETS bzrtp EXPORT ${EXPORT_TARGETS_NAME}Targets
		RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
		LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
		ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
		PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
	)
85
endif()