2020-09-09 21:03:19 +00:00
|
|
|
cmake_minimum_required(VERSION 3.16)
|
|
|
|
|
|
|
|
project(abaddon)
|
|
|
|
|
2021-07-03 01:41:05 +00:00
|
|
|
set(ABADDON_RESOURCE_DIR "/usr/share/abaddon" CACHE PATH "Fallback directory for resources on Linux")
|
|
|
|
|
2020-09-09 21:03:19 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2021-01-07 07:41:49 +00:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
|
2020-09-09 21:03:19 +00:00
|
|
|
|
2022-04-08 18:50:11 +00:00
|
|
|
option(USE_LIBHANDY "Enable features that require libhandy (default)" ON)
|
|
|
|
|
2021-01-07 07:41:49 +00:00
|
|
|
find_package(nlohmann_json REQUIRED)
|
|
|
|
find_package(CURL)
|
|
|
|
find_package(ZLIB REQUIRED)
|
|
|
|
find_package(SQLite3 REQUIRED)
|
|
|
|
find_package(gtkmm REQUIRED)
|
2020-10-12 22:17:53 +00:00
|
|
|
|
2021-10-11 05:03:31 +00:00
|
|
|
set(USE_TLS TRUE)
|
|
|
|
set(USE_OPEN_SSL TRUE)
|
|
|
|
find_package(IXWebSocket QUIET)
|
|
|
|
if (NOT IXWebSocket_FOUND)
|
2022-04-08 18:50:11 +00:00
|
|
|
message("ixwebsocket was not found and will be included as a submodule")
|
|
|
|
add_subdirectory(subprojects/ixwebsocket)
|
|
|
|
include_directories(IXWEBSOCKET_INCLUDE_DIRS)
|
|
|
|
endif ()
|
2020-09-09 21:03:19 +00:00
|
|
|
|
2022-04-08 18:50:11 +00:00
|
|
|
if (MINGW OR WIN32)
|
|
|
|
link_libraries(ws2_32)
|
|
|
|
endif ()
|
2020-09-09 21:03:19 +00:00
|
|
|
|
2022-04-08 18:50:11 +00:00
|
|
|
if (WIN32)
|
|
|
|
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
|
|
|
|
add_compile_definitions(NOMINMAX)
|
|
|
|
endif ()
|
2020-12-22 07:35:57 +00:00
|
|
|
|
2022-08-14 02:59:08 +00:00
|
|
|
include(TestBigEndian)
|
|
|
|
test_big_endian(IS_BIG_ENDIAN)
|
|
|
|
if (IS_BIG_ENDIAN)
|
|
|
|
add_compile_definitions(ABADDON_IS_BIG_ENDIAN)
|
|
|
|
endif ()
|
|
|
|
|
2021-11-23 04:21:56 +00:00
|
|
|
configure_file(${PROJECT_SOURCE_DIR}/src/config.h.in ${PROJECT_BINARY_DIR}/config.h)
|
2021-07-03 01:41:05 +00:00
|
|
|
|
2021-11-23 04:21:56 +00:00
|
|
|
file(GLOB_RECURSE ABADDON_SOURCES
|
2022-04-08 18:50:11 +00:00
|
|
|
"src/*.h"
|
|
|
|
"src/*.hpp"
|
|
|
|
"src/*.cpp"
|
|
|
|
)
|
2020-11-01 04:33:57 +00:00
|
|
|
|
|
|
|
add_executable(abaddon ${ABADDON_SOURCES})
|
2021-11-23 04:21:56 +00:00
|
|
|
target_include_directories(abaddon PUBLIC ${PROJECT_SOURCE_DIR}/src)
|
2021-07-03 01:41:05 +00:00
|
|
|
target_include_directories(abaddon PUBLIC ${PROJECT_BINARY_DIR})
|
2021-01-07 07:41:49 +00:00
|
|
|
target_include_directories(abaddon PUBLIC ${GTKMM_INCLUDE_DIRS})
|
|
|
|
target_include_directories(abaddon PUBLIC ${ZLIB_INCLUDE_DIRS})
|
|
|
|
target_include_directories(abaddon PUBLIC ${SQLite3_INCLUDE_DIRS})
|
2021-01-23 21:07:03 +00:00
|
|
|
target_include_directories(abaddon PUBLIC ${NLOHMANN_JSON_INCLUDE_DIRS})
|
2021-01-07 07:41:49 +00:00
|
|
|
|
|
|
|
if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR
|
2022-04-08 18:50:11 +00:00
|
|
|
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
|
|
|
|
((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR (CMAKE_CXX_COMPILER_VERSION LESS 9))))
|
|
|
|
target_link_libraries(abaddon stdc++fs)
|
|
|
|
endif ()
|
2021-01-07 07:41:49 +00:00
|
|
|
|
2021-10-11 05:03:31 +00:00
|
|
|
if (IXWebSocket_LIBRARIES)
|
2022-04-08 18:50:11 +00:00
|
|
|
target_link_libraries(abaddon ${IXWebSocket_LIBRARIES})
|
|
|
|
find_library(MBEDTLS_X509_LIBRARY mbedx509)
|
|
|
|
find_library(MBEDTLS_TLS_LIBRARY mbedtls)
|
|
|
|
find_library(MBEDTLS_CRYPTO_LIBRARY mbedcrypto)
|
|
|
|
if (MBEDTLS_TLS_LIBRARY)
|
|
|
|
target_link_libraries(abaddon ${MBEDTLS_TLS_LIBRARY})
|
|
|
|
endif ()
|
|
|
|
if (MBEDTLS_X509_LIBRARY)
|
|
|
|
target_link_libraries(abaddon ${MBEDTLS_X509_LIBRARY})
|
|
|
|
endif ()
|
|
|
|
if (MBEDTLS_CRYPTO_LIBRARY)
|
|
|
|
target_link_libraries(abaddon ${MBEDTLS_CRYPTO_LIBRARY})
|
|
|
|
endif ()
|
|
|
|
else ()
|
|
|
|
target_link_libraries(abaddon $<BUILD_INTERFACE:ixwebsocket>)
|
|
|
|
endif ()
|
2021-01-07 07:41:49 +00:00
|
|
|
|
|
|
|
find_package(Threads)
|
|
|
|
if (Threads_FOUND)
|
2022-04-08 18:50:11 +00:00
|
|
|
target_link_libraries(abaddon Threads::Threads)
|
|
|
|
endif ()
|
2021-01-07 07:41:49 +00:00
|
|
|
|
2022-05-22 02:59:53 +00:00
|
|
|
find_package(Fontconfig QUIET)
|
|
|
|
if (Fontconfig_FOUND)
|
|
|
|
target_link_libraries(abaddon Fontconfig::Fontconfig)
|
|
|
|
endif ()
|
|
|
|
|
2021-01-07 07:41:49 +00:00
|
|
|
target_link_libraries(abaddon ${SQLite3_LIBRARIES})
|
|
|
|
target_link_libraries(abaddon ${GTKMM_LIBRARIES})
|
|
|
|
target_link_libraries(abaddon ${CURL_LIBRARIES})
|
2020-12-11 02:32:02 +00:00
|
|
|
target_link_libraries(abaddon ${ZLIB_LIBRARY})
|
2021-01-07 07:41:49 +00:00
|
|
|
target_link_libraries(abaddon ${NLOHMANN_JSON_LIBRARIES})
|
2022-04-08 18:50:11 +00:00
|
|
|
|
|
|
|
if (USE_LIBHANDY)
|
|
|
|
find_package(libhandy)
|
|
|
|
if (NOT libhandy_FOUND)
|
|
|
|
message("libhandy could not be found. features requiring it have been disabled")
|
|
|
|
set(USE_LIBHANDY OFF)
|
|
|
|
else ()
|
|
|
|
target_include_directories(abaddon PUBLIC ${libhandy_INCLUDE_DIRS})
|
|
|
|
target_link_libraries(abaddon ${libhandy_LIBRARIES})
|
|
|
|
target_compile_definitions(abaddon PRIVATE WITH_LIBHANDY)
|
|
|
|
endif ()
|
|
|
|
endif ()
|