TeaSpeakLibrary/CMakeLists.txt

250 lines
6.2 KiB
CMake
Raw Normal View History

2019-06-26 16:11:22 -04:00
cmake_minimum_required(VERSION 3.6)
project(TeaSpeak-Shared)
set(CMAKE_CXX_STANDARD 17)
if(NOT WIN32)
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)
endif()
2019-07-01 20:15:17 -04:00
if(CMAKE_PLATFORM_INCLUDE AND NOT CMAKE_PLATFORM_INCLUDE STREQUAL "")
include(${CMAKE_PLATFORM_INCLUDE})
endif()
2019-07-01 20:02:50 -04:00
2019-07-01 20:15:17 -04:00
if(NOT TEASPEAK_SERVER)
2019-06-26 16:11:22 -04:00
find_package(TomMath REQUIRED)
include_directories(${TomMath_INCLUDE_DIR})
find_package(TomCrypt REQUIRED)
include_directories(${TomCrypt_INCLUDE_DIR})
find_package(DataPipes REQUIRED)
include_directories(${DataPipes_INCLUDE_DIR})
message("Include: ${DataPipes_INCLUDE_DIR}")
2019-07-01 20:15:17 -04:00
find_package(Libevent REQUIRED)
2019-06-26 16:11:22 -04:00
include_directories(${LIBEVENT_INCLUDE_DIRS})
find_package(StringVariable REQUIRED)
include_directories(${StringVariable_INCLUDE_DIR})
2019-07-01 20:15:17 -04:00
find_package(Ed25519 REQUIRED)
2019-06-26 16:11:22 -04:00
include_directories(${ed25519_INCLUDE_DIR})
find_package(ThreadPool REQUIRED)
include_directories(${ThreadPool_INCLUDE_DIR})
2019-07-01 20:15:17 -04:00
if(WIN32)
add_definitions(-DWINDOWS) #Required for ThreadPool
endif()
find_package(spdlog CONFIG REQUIRED)
2019-06-26 16:11:22 -04:00
link_libraries(spdlog::spdlog) #Its a header only lib so we should be fine :)
add_definitions(-DNO_OPEN_SSL)
add_definitions(-D_HAS_STD_BYTE)
#FML
else()
add_definitions(-DHAVE_CXX_TERMINAL)
add_definitions(-DHAVE_JSON)
set(HAVE_SQLITE3 ON)
set(HAVE_OPEN_SSL ON)
message("HAVE JSON!")
endif()
if (MSVC)
set(CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
2019-09-05 06:30:07 -04:00
)
2019-06-26 16:11:22 -04:00
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
else()
set(CMAKE_CXX_FLAGS_RELEASE "-O3") #-DNDEBUG We want assert!
endif()
add_definitions(-DUSE_BORINGSSL)
include_directories(${LIBRARY_PATH}/boringssl/include/)
set(SOURCE_FILES
src/misc/rnd.cpp
src/misc/time.cpp
src/misc/memtracker.cpp
src/misc/digest.cpp
2019-07-01 20:15:17 -04:00
src/misc/base64.cpp
2019-06-26 16:11:22 -04:00
#Logger
src/log/LogUtils.cpp
src/log/LogSinks.cpp
src/qlz/QuickLZ.cpp
src/qlz/QuickLZ_L3.cpp
src/qlz/QuickLZ_L1.cpp
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
)
set(HEADER_FILES
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/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
src/channel/TreeView.h
)
if(HAVE_SQLITE3)
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
)
endif()
if(HAVE_OPEN_SSL)
set(SOURCE_FILES ${SOURCE_FILES}
src/ssl/SSLManager.cpp
)
set(HEADER_FILES ${HEADER_FILES}
src/ssl/SSLManager.h
)
endif()
if (NOT WIN32)
2019-07-01 20:15:17 -04:00
#TODO: Do we really need that anymroe?
2019-06-26 16:11:22 -04:00
set(SOURCE_FILES ${SOURCE_FILES}
2019-07-01 20:15:17 -04:00
#src/misc/TraceUtils.cpp
2019-06-26 16:11:22 -04:00
)
set(HEADER_FILES ${HEADER_FILES}
)
endif ()
add_library(TeaSpeak STATIC ${SOURCE_FILES} ${HEADER_FILES})
2019-07-01 20:22:04 -04:00
install(TARGETS TeaSpeak
ARCHIVE DESTINATION lib
)
INSTALL (
DIRECTORY ${CMAKE_SOURCE_DIR}/src/
DESTINATION include
FILES_MATCHING PATTERN "*.h*"
)
2019-06-26 16:11:22 -04:00
set(TEST_LIBRARIES
sqlite3
${LIBRARY_PATH_THREAD_POOL} #Static
${LIBRARY_PATH_TERMINAL} #Static
${LIBRARY_PATH_VARIBALES}
${LIBRARY_PATH_YAML}
pthread
stdc++fs
${TOM_LIBRARIES}
${LIBEVENT_PATH}/libevent.a
${LIBEVENT_PATH}/libevent_pthreads.a
${LIBRARY_PATH_ED255}
${LIBRARY_PATH_JSON}
${LIBRARY_TOM_CRYPT}
2019-09-05 06:30:07 -04:00
mysqlclient.a
2019-06-26 16:11:22 -04:00
${LIBRARY_PATH_DATA_PIPES}
${LIBRARY_PATH_BORINGSSL_SSL}
${LIBRARY_PATH_BORINGSSL_CRYPTO} #Crypto must be linked after
2019-09-05 06:30:07 -04: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)
add_executable(RingTest test/RingTest.cpp ${SOURCE_FILES})
target_link_libraries(RingTest ${TEST_LIBRARIES})
if(NOT WIN32)
add_executable(CommandTest ${SOURCE_FILES} ${HEADER_FILES} test/CommandTest.cpp src/log/LogSinks.cpp src/log/LogSinks.h)
target_link_libraries(CommandTest ${TEST_LIBRARIES})
2019-06-26 16:11:22 -04:00
2019-07-01 20:15:17 -04: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
2019-07-01 20:15:17 -04: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
2019-07-01 20:15:17 -04: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
2019-07-01 20:15:17 -04: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
2019-07-01 20:15:17 -04: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
2019-07-01 20:15:17 -04:00
add_executable(PorpertyTest test/PropertyTest.cpp ${SOURCE_FILES})
target_link_libraries(PorpertyTest ${TEST_LIBRARIES})
2019-06-26 16:11:22 -04:00
2019-07-01 20:15:17 -04:00
add_executable(BBTest test/BBTest.cpp ${SOURCE_FILES})
target_link_libraries(BBTest ${TEST_LIBRARIES})
2019-06-26 16:11:22 -04:00
2019-07-01 20:15:17 -04:00
add_executable(LinkedTest test/LinkedTest.cpp ${SOURCE_FILES})
target_link_libraries(LinkedTest ${TEST_LIBRARIES})
2019-07-17 12:24:43 -04:00
add_executable(PermissionTest test/PermissionTest.cpp ${SOURCE_FILES})
target_link_libraries(PermissionTest ${TEST_LIBRARIES})
2019-07-01 20:15:17 -04:00
endif()
2019-06-26 16:20:33 -04:00
endif()