CMakeLists.txt 4.11 KB
Newer Older
johan's avatar
johan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
############################################################################
# CMakeLists.txt
# Copyright (C) 2017  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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
#
############################################################################

jehan's avatar
jehan committed
23
set(LIME_PRIVATE_HEADER_FILES
johan's avatar
johan committed
24 25 26 27 28 29 30 31 32
	lime_settings.hpp
	lime_defines.hpp
	lime_keys.hpp
	lime_impl.hpp
	lime_x3dh_protocol.hpp
	lime_localStorage.hpp
	lime_double_ratchet.hpp
	lime_double_ratchet_protocol.hpp
	lime_lime.hpp
Johan Pascal's avatar
Johan Pascal committed
33
	lime_crypto_primitives.hpp
Johan Pascal's avatar
Johan Pascal committed
34
	lime_log.hpp
johan's avatar
johan committed
35 36 37
)
set(LIME_SOURCE_FILES_CXX
	lime.cpp
Johan Pascal's avatar
Johan Pascal committed
38
	lime_crypto_primitives.cpp
johan's avatar
johan committed
39 40 41 42 43 44 45 46
	lime_x3dh.cpp
	lime_x3dh_protocol.cpp
	lime_localStorage.cpp
	lime_double_ratchet.cpp
	lime_double_ratchet_protocol.cpp
	lime_manager.cpp
)

johan's avatar
johan committed
47 48 49 50
if (ENABLE_C_INTERFACE)
	set(LIME_SOURCE_FILES_CXX ${LIME_SOURCE_FILES_CXX} lime_ffi.cpp)
endif()

johan's avatar
johan committed
51 52 53
bc_apply_compile_flags(LIME_SOURCE_FILES_CXX STRICT_OPTIONS_CPP STRICT_OPTIONS_CXX)

if(ENABLE_STATIC)
jehan's avatar
jehan committed
54
	add_library(lime-static STATIC ${LIME_PRIVATE_HEADER_FILES} ${LIME_SOURCE_FILES_CXX})
johan's avatar
johan committed
55 56
	set_target_properties(lime-static PROPERTIES OUTPUT_NAME lime)
	target_include_directories(lime-static PUBLIC ${BCTOOLBOX_INCLUDE_DIRS} ${SOCI_INCLUDE_DIRS} ${SOCI_INCLUDE_DIRS}/soci)
57
	target_link_libraries(lime-static INTERFACE ${BCTOOLBOX_CORE_LIBRARIES} ${SOCI_LIBRARIES} ${SOCI_sqlite3_PLUGIN})
Johan Pascal's avatar
Johan Pascal committed
58 59 60
	if(ENABLE_PROFILING)
		set_target_properties(lime-static PROPERTIES LINK_FLAGS "-pg")
	endif()
johan's avatar
johan committed
61 62
endif()
if(ENABLE_SHARED)
jehan's avatar
jehan committed
63
	add_library(lime SHARED ${LIME_PRIVATE_HEADER_FILES} ${LIME_HEADER_FILES} ${LIME_SOURCE_FILES_CXX})
johan's avatar
johan committed
64 65
	set_target_properties(lime PROPERTIES VERSION ${LIME_SO_VERSION})
	target_include_directories(lime PUBLIC ${BCTOOLBOX_INCLUDE_DIRS} ${SOCI_INCLUDE_DIRS} ${SOCI_INCLUDE_DIRS}/soci)
66
	target_link_libraries(lime PRIVATE ${BCTOOLBOX_CORE_LIBRARIES} ${SOCI_LIBRARIES} ${SOCI_sqlite3_PLUGIN})
Ghislain MARY's avatar
Ghislain MARY committed
67 68 69 70 71 72 73 74 75 76 77 78 79 80
	# TODO: replace by if(APPLE) when we want to make apple framework on linphone-desktop too
	if(IOS)
		if(IOS)
			set(MIN_OS ${LINPHONE_IOS_DEPLOYMENT_TARGET})
		else()
			set(MIN_OS ${CMAKE_OSX_DEPLOYMENT_TARGET})
		endif()
		set_target_properties(lime PROPERTIES
			FRAMEWORK TRUE
			MACOSX_FRAMEWORK_IDENTIFIER com.belledonne-communications.lime
			MACOSX_FRAMEWORK_INFO_PLIST "${CMAKE_SOURCE_DIR}/build/osx/Info.plist.in"
			PUBLIC_HEADER "${LIME_HEADER_FILES}"
		)
	endif()
johan's avatar
johan committed
81 82 83
	if(WIN32)
		set_target_properties(lime PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
	endif()
johan's avatar
johan committed
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
	if(MSVC)
		if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
			install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/lime.pdb
				DESTINATION ${CMAKE_INSTALL_BINDIR}
				PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
			)
		endif()
	endif()
endif()

if(ENABLE_STATIC)
	install(TARGETS lime-static 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
	)
endif()
if(ENABLE_SHARED)
	install(TARGETS lime EXPORT ${EXPORT_TARGETS_NAME}Targets
		RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
		LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
		ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
Ghislain MARY's avatar
Ghislain MARY committed
107
		FRAMEWORK DESTINATION Frameworks
johan's avatar
johan committed
108 109 110
		PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
	)
endif()