2019-06-26 16:11:22 -04:00
|
|
|
cmake_minimum_required(VERSION 3.6)
|
|
|
|
project(TeaSpeak-Shared)
|
2020-01-24 08:02:19 -05:00
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
2019-06-26 16:11:22 -04:00
|
|
|
|
|
|
|
if(NOT WIN32)
|
2020-01-23 20:49:59 -05:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -Wno-reorder -Wno-sign-compare -fpermissive -ftemplate-depth=1000 ${MEMORY_DEBUG_FLAGS}")
|
|
|
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
2019-09-22 10:57:01 -04:00
|
|
|
else()
|
2020-01-23 20:49:59 -05:00
|
|
|
#For Windows
|
|
|
|
add_definitions(-D_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING)
|
2019-09-22 10:57:01 -04:00
|
|
|
|
2020-01-23 20:49:59 -05:00
|
|
|
add_compile_options(/wd4996) #'std::result_of_t': warning STL4014: std::result_of and std::result_of_t are deprecated in C++17.
|
2019-06-26 16:11:22 -04:00
|
|
|
endif()
|
|
|
|
|
2019-07-01 20:15:17 -04:00
|
|
|
if(CMAKE_PLATFORM_INCLUDE AND NOT CMAKE_PLATFORM_INCLUDE STREQUAL "")
|
2020-01-23 20:49:59 -05:00
|
|
|
include(${CMAKE_PLATFORM_INCLUDE})
|
2019-07-01 20:15:17 -04:00
|
|
|
endif()
|
2019-07-01 20:02:50 -04:00
|
|
|
|
2020-01-24 09:42:32 -05:00
|
|
|
find_package(TomMath REQUIRED)
|
|
|
|
include_directories(${TomMath_INCLUDE_DIR})
|
2019-06-26 16:11:22 -04:00
|
|
|
|
2020-01-24 09:42:32 -05:00
|
|
|
find_package(TomCrypt REQUIRED)
|
|
|
|
include_directories(${TomCrypt_INCLUDE_DIR})
|
2019-06-26 16:11:22 -04:00
|
|
|
|
2020-01-24 09:42:32 -05:00
|
|
|
find_package(DataPipes REQUIRED)
|
|
|
|
include_directories(${DataPipes_INCLUDE_DIR})
|
2019-06-26 16:11:22 -04:00
|
|
|
|
2020-01-24 11:06:52 -05:00
|
|
|
# LibEvent fucks up the CMAKE_FIND_LIBRARY_SUFFIXES variable
|
|
|
|
function(find_event)
|
|
|
|
set(LIBEVENT_STATIC_LINK TRUE)
|
|
|
|
find_package(Libevent REQUIRED)
|
|
|
|
include_directories(${LIBEVENT_INCLUDE_DIRS})
|
|
|
|
endfunction()
|
|
|
|
find_event()
|
2019-06-26 16:11:22 -04:00
|
|
|
|
2020-01-24 09:42:32 -05:00
|
|
|
find_package(StringVariable REQUIRED)
|
|
|
|
include_directories(${StringVariable_INCLUDE_DIR})
|
2019-06-26 16:11:22 -04:00
|
|
|
|
2020-01-24 09:42:32 -05:00
|
|
|
find_package(Ed25519 REQUIRED)
|
|
|
|
include_directories(${ed25519_INCLUDE_DIR})
|
2019-06-26 16:11:22 -04:00
|
|
|
|
2020-01-24 09:42:32 -05:00
|
|
|
find_package(ThreadPool REQUIRED)
|
|
|
|
include_directories(${ThreadPool_INCLUDE_DIR})
|
|
|
|
if(WIN32)
|
|
|
|
add_definitions(-DWINDOWS) #Required for ThreadPool
|
|
|
|
endif()
|
|
|
|
find_package(spdlog REQUIRED)
|
|
|
|
link_libraries(spdlog::spdlog_header_only) #Its a header only lib so we should be fine :)
|
2019-06-26 16:11:22 -04:00
|
|
|
|
2020-01-24 09:42:32 -05:00
|
|
|
if(NOT TEASPEAK_SERVER)
|
2020-01-23 20:49:59 -05:00
|
|
|
add_definitions(-DNO_OPEN_SSL)
|
|
|
|
add_definitions(-D_HAS_STD_BYTE)
|
|
|
|
#FML
|
2019-06-26 16:11:22 -04:00
|
|
|
else()
|
2020-01-24 09:42:32 -05:00
|
|
|
find_package(CXXTerminal REQUIRED)
|
|
|
|
|
2020-01-23 20:49:59 -05:00
|
|
|
add_definitions(-DHAVE_CXX_TERMINAL)
|
|
|
|
add_definitions(-DHAVE_JSON)
|
|
|
|
set(HAVE_SQLITE3 ON)
|
|
|
|
set(HAVE_OPEN_SSL ON)
|
|
|
|
message("HAVE JSON!")
|
2019-06-26 16:11:22 -04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (MSVC)
|
2020-01-23 20:49:59 -05:00
|
|
|
set(CompilerFlags
|
|
|
|
CMAKE_CXX_FLAGS
|
|
|
|
CMAKE_CXX_FLAGS_DEBUG
|
|
|
|
CMAKE_CXX_FLAGS_RELEASE
|
|
|
|
CMAKE_C_FLAGS
|
|
|
|
CMAKE_C_FLAGS_DEBUG
|
|
|
|
CMAKE_C_FLAGS_RELEASE
|
|
|
|
)
|
|
|
|
foreach(CompilerFlag ${CompilerFlags})
|
|
|
|
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
|
|
|
|
endforeach()
|
|
|
|
add_compile_options("/EHsc") #We require exception handling
|
2019-06-26 16:11:22 -04:00
|
|
|
else()
|
2020-01-23 20:49:59 -05:00
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3") #-DNDEBUG We want assert!
|
2019-06-26 16:11:22 -04:00
|
|
|
endif()
|
|
|
|
add_definitions(-DUSE_BORINGSSL)
|
|
|
|
include_directories(${LIBRARY_PATH}/boringssl/include/)
|
|
|
|
set(SOURCE_FILES
|
2020-01-23 20:49:59 -05:00
|
|
|
src/misc/rnd.cpp
|
|
|
|
src/misc/time.cpp
|
|
|
|
src/misc/memtracker.cpp
|
|
|
|
src/misc/digest.cpp
|
|
|
|
src/misc/base64.cpp
|
|
|
|
|
|
|
|
#Logger
|
|
|
|
src/log/LogUtils.cpp
|
|
|
|
src/log/LogSinks.cpp
|
|
|
|
|
|
|
|
|
|
|
|
src/qlz/QuickLZ.cpp
|
|
|
|
src/qlz/QuickLZ_L3.cpp
|
|
|
|
src/qlz/QuickLZ_L1.cpp
|
|
|
|
|
2020-01-25 17:42:36 -05:00
|
|
|
src/converters/converter.cpp
|
|
|
|
|
|
|
|
src/query/command3.cpp
|
2020-01-23 20:49:59 -05:00
|
|
|
src/query/command2.cpp
|
|
|
|
src/query/Command.cpp
|
|
|
|
src/query/escape.cpp
|
|
|
|
|
|
|
|
src/protocol/Packet.cpp
|
|
|
|
src/protocol/buffers.cpp
|
|
|
|
src/protocol/buffers_allocator_c.cpp
|
|
|
|
src/PermissionManager.cpp
|
|
|
|
src/Properties.cpp
|
|
|
|
src/BasicChannel.cpp
|
|
|
|
src/Error.cpp
|
|
|
|
src/protocol/CryptionHandler.cpp
|
|
|
|
src/protocol/CompressionHandler.cpp
|
|
|
|
src/Variable.cpp
|
|
|
|
src/linked_helper.cpp
|
|
|
|
src/EventLoop.cpp
|
|
|
|
|
|
|
|
src/License.cpp
|
|
|
|
|
|
|
|
src/bbcode/bbcodes.cpp
|
|
|
|
|
|
|
|
src/channel/TreeView.cpp
|
|
|
|
src/protocol/ringbuffer.cpp
|
|
|
|
src/protocol/AcknowledgeManager.cpp
|
2019-06-26 16:11:22 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
set(HEADER_FILES
|
2020-01-23 20:49:59 -05:00
|
|
|
src/misc/base64.h
|
|
|
|
src/misc/endianness.h
|
|
|
|
src/misc/cast.h
|
|
|
|
src/misc/rnd.h
|
|
|
|
src/misc/time.h
|
|
|
|
src/misc/std_unique_ptr.h
|
|
|
|
src/misc/net.h
|
|
|
|
src/misc/lambda.h
|
|
|
|
src/misc/hex.h
|
|
|
|
src/misc/advanced_mutex.h
|
|
|
|
src/misc/memtracker.h
|
|
|
|
src/misc/strobf.h
|
|
|
|
|
|
|
|
src/log/translation.h
|
|
|
|
src/log/LogUtils.h
|
|
|
|
|
|
|
|
src/PermissionManager.h
|
|
|
|
src/protocol/buffers.h
|
|
|
|
src/protocol/Packet.h
|
|
|
|
src/Properties.h
|
|
|
|
src/BasicChannel.h
|
|
|
|
src/Definitions.h
|
|
|
|
src/Error.h
|
|
|
|
src/protocol/CryptionHandler.h
|
|
|
|
src/Variable.h
|
|
|
|
src/misc/queue.h
|
|
|
|
|
|
|
|
src/misc/digest.h
|
|
|
|
|
|
|
|
src/bbcode/bbcodes.h
|
2019-06-26 16:11:22 -04:00
|
|
|
|
|
|
|
src/channel/TreeView.h
|
|
|
|
)
|
|
|
|
|
|
|
|
if(HAVE_SQLITE3)
|
2020-01-23 20:49:59 -05:00
|
|
|
set(SOURCE_FILES ${SOURCE_FILES}
|
|
|
|
src/sql/SqlQuery.cpp
|
|
|
|
src/sql/sqlite/SqliteSQL.cpp
|
|
|
|
src/sql/mysql/MySQL.cpp
|
|
|
|
)
|
|
|
|
set(HEADER_FILES ${HEADER_FILES}
|
|
|
|
src/sql/SqlQuery.h
|
|
|
|
src/sql/sqlite/SqliteSQL.h
|
|
|
|
src/sql/mysql/MySQL.h
|
|
|
|
)
|
2019-06-26 16:11:22 -04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(HAVE_OPEN_SSL)
|
2020-01-23 20:49:59 -05:00
|
|
|
set(SOURCE_FILES ${SOURCE_FILES}
|
|
|
|
src/ssl/SSLManager.cpp
|
|
|
|
)
|
|
|
|
set(HEADER_FILES ${HEADER_FILES}
|
|
|
|
src/ssl/SSLManager.h
|
|
|
|
)
|
2019-06-26 16:11:22 -04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (NOT WIN32)
|
2020-01-23 20:49:59 -05:00
|
|
|
#TODO: Do we really need that anymroe?
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES}
|
|
|
|
#src/misc/TraceUtils.cpp
|
|
|
|
)
|
|
|
|
set(HEADER_FILES ${HEADER_FILES}
|
2019-06-26 16:11:22 -04:00
|
|
|
|
2020-01-23 20:49:59 -05:00
|
|
|
)
|
2019-06-26 16:11:22 -04:00
|
|
|
endif ()
|
|
|
|
|
|
|
|
add_library(TeaSpeak STATIC ${SOURCE_FILES} ${HEADER_FILES})
|
2020-01-26 08:46:12 -05:00
|
|
|
target_link_libraries(TeaSpeak PUBLIC threadpool::static jsoncpp_lib)
|
|
|
|
if (TEASPEAK_SERVER)
|
|
|
|
target_link_libraries(TeaSpeak PUBLIC CXXTerminal::static)
|
|
|
|
endif ()
|
2020-01-24 09:46:28 -05:00
|
|
|
target_include_directories(TeaSpeak PUBLIC src/)
|
2019-07-01 20:22:04 -04:00
|
|
|
install(TARGETS TeaSpeak
|
2020-01-23 20:49:59 -05:00
|
|
|
ARCHIVE DESTINATION lib
|
2019-07-01 20:22:04 -04:00
|
|
|
)
|
|
|
|
INSTALL (
|
2020-01-23 20:49:59 -05:00
|
|
|
DIRECTORY ${CMAKE_SOURCE_DIR}/src/
|
|
|
|
DESTINATION include
|
|
|
|
FILES_MATCHING PATTERN "*.h*"
|
2019-07-01 20:22:04 -04:00
|
|
|
)
|
|
|
|
|
2019-06-26 16:11:22 -04:00
|
|
|
set(TEST_LIBRARIES
|
2020-01-24 14:17:29 -05:00
|
|
|
threadpool::static #Static
|
|
|
|
CXXTerminal::static #Static
|
|
|
|
${StringVariable_LIBRARIES_STATIC}
|
|
|
|
${YAML_CPP_LIBRARIES}
|
2020-01-23 20:49:59 -05:00
|
|
|
pthread
|
|
|
|
stdc++fs
|
2020-01-24 14:17:29 -05:00
|
|
|
libevent::core libevent::pthreads
|
|
|
|
opus::static
|
|
|
|
yaml-cpp
|
|
|
|
${LIBRARY_PATH_PROTOBUF}
|
2019-06-26 16:11:22 -04:00
|
|
|
|
2020-01-24 14:17:29 -05:00
|
|
|
#We're forsed to use boringssl caused by the fact that boringssl is already within webrtc!
|
|
|
|
|
|
|
|
#Require a so
|
|
|
|
sqlite3
|
2019-06-26 16:11:22 -04:00
|
|
|
|
2020-01-24 14:17:29 -05:00
|
|
|
breakpad::static
|
|
|
|
protobuf::libprotobuf
|
|
|
|
jemalloc::shared
|
|
|
|
|
|
|
|
tomcrypt::static
|
|
|
|
tommath::static
|
|
|
|
|
|
|
|
mysqlclient.a
|
|
|
|
jsoncpp_lib
|
|
|
|
${ed25519_LIBRARIES_STATIC}
|
|
|
|
${DataPipes_LIBRARIES_SHARED}
|
2020-01-25 17:42:36 -05:00
|
|
|
ffi
|
2020-01-24 14:17:29 -05:00
|
|
|
openssl::ssl::shared
|
|
|
|
openssl::crypto::shared
|
2020-01-23 20:49:59 -05:00
|
|
|
dl
|
|
|
|
z
|
2019-06-26 16:11:22 -04:00
|
|
|
)
|
|
|
|
include_directories(src/)
|
2019-07-01 20:15:17 -04:00
|
|
|
option(BUILD_TESTS "Enable/disable test building" ON)
|
|
|
|
if(BUILD_TESTS)
|
2020-01-23 20:49:59 -05:00
|
|
|
add_executable(RingTest test/RingTest.cpp ${SOURCE_FILES})
|
|
|
|
target_link_libraries(RingTest ${TEST_LIBRARIES})
|
2019-07-01 20:15:17 -04:00
|
|
|
|
2020-01-23 20:49:59 -05:00
|
|
|
if(NOT WIN32)
|
2020-01-24 14:17:29 -05:00
|
|
|
add_executable(CommandTest ${SOURCE_FILES} ${HEADER_FILES} test/CommandTest.cpp src/log/LogSinks.cpp src/log/LogSinks.h ../server/MySQLLibSSLFix.c)
|
2020-01-23 20:49:59 -05:00
|
|
|
target_link_libraries(CommandTest ${TEST_LIBRARIES})
|
2019-06-26 16:11:22 -04:00
|
|
|
|
2020-01-23 20:49:59 -05:00
|
|
|
add_executable(WebsocketTest ${SOURCE_FILES} ${HEADER_FILES} test/WSSTest.cpp src/log/LogSinks.cpp src/log/LogSinks.h)
|
|
|
|
target_link_libraries(WebsocketTest ${TEST_LIBRARIES})
|
2019-06-26 16:11:22 -04:00
|
|
|
|
2020-01-23 20:49:59 -05:00
|
|
|
add_executable(SQLTest ${SOURCE_FILES} ${HEADER_FILES} test/SQLTest.cpp src/log/LogSinks.cpp src/log/LogSinks.h)
|
|
|
|
target_link_libraries(SQLTest ${TEST_LIBRARIES})
|
2019-06-26 16:11:22 -04:00
|
|
|
|
2020-01-23 20:49:59 -05:00
|
|
|
add_executable(ChannelTest ${SOURCE_FILES} ${HEADER_FILES} test/ChannelTest.cpp src/log/LogSinks.cpp src/log/LogSinks.h)
|
|
|
|
target_link_libraries(ChannelTest ${TEST_LIBRARIES})
|
2019-06-26 16:11:22 -04:00
|
|
|
|
2020-01-23 20:49:59 -05:00
|
|
|
add_executable(EndianessTest ${SOURCE_FILES} ${HEADER_FILES} test/EndianessTest.cpp src/log/LogSinks.cpp src/log/LogSinks.h)
|
|
|
|
target_link_libraries(EndianessTest ${TEST_LIBRARIES})
|
2019-06-26 16:11:22 -04:00
|
|
|
|
2020-01-23 20:49:59 -05:00
|
|
|
include_directories(/usr/local/include/breakpad)
|
|
|
|
add_executable(CrashTest test/CrashTest.cpp ${SOURCE_FILES})
|
|
|
|
target_link_libraries(CrashTest ${TEST_LIBRARIES})
|
2019-06-26 16:11:22 -04:00
|
|
|
|
2020-01-23 20:49:59 -05:00
|
|
|
add_executable(PorpertyTest test/PropertyTest.cpp ${SOURCE_FILES})
|
|
|
|
target_link_libraries(PorpertyTest ${TEST_LIBRARIES})
|
2019-06-26 16:11:22 -04:00
|
|
|
|
2020-01-25 17:42:36 -05:00
|
|
|
add_executable(BBTest test/BBTest.cpp ${SOURCE_FILES} src/query/command_unused.h src/converters/converter.cpp src/query/command_handler.h)
|
2020-01-23 20:49:59 -05:00
|
|
|
target_link_libraries(BBTest ${TEST_LIBRARIES})
|
2019-06-26 16:11:22 -04:00
|
|
|
|
2020-01-23 20:49:59 -05:00
|
|
|
add_executable(LinkedTest test/LinkedTest.cpp ${SOURCE_FILES})
|
|
|
|
target_link_libraries(LinkedTest ${TEST_LIBRARIES})
|
2019-07-17 12:24:43 -04:00
|
|
|
|
2020-01-23 20:49:59 -05:00
|
|
|
add_executable(PermissionTest test/PermissionTest.cpp ${SOURCE_FILES})
|
|
|
|
target_link_libraries(PermissionTest ${TEST_LIBRARIES})
|
|
|
|
endif()
|
2019-06-26 16:20:33 -04:00
|
|
|
endif()
|