gd-tools/CMakeLists.txt

141 lines
3.5 KiB
CMake
Raw Normal View History

2024-02-04 18:24:04 +00:00
cmake_minimum_required(VERSION 3.14)
include(cmake/prelude.cmake)
project(
gd-tools
2024-02-07 20:32:30 +00:00
VERSION 1.5
2024-02-04 18:24:04 +00:00
DESCRIPTION "A set of helpful programs to enhance goldendict for immersion learning."
HOMEPAGE_URL "https://github.com/Ajatt-Tools/gd-tools"
LANGUAGES CXX
)
2024-02-15 06:01:00 +00:00
option(GUIX "Build for Guix" OFF) # OFF by default
2024-02-04 18:24:04 +00:00
include(cmake/project-is-top-level.cmake)
include(cmake/variables.cmake)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
2024-02-14 12:17:31 +00:00
if (APPLE)
message(STATUS "Building for Mac")
endif()
if (WIN32)
message(STATUS "Building for Widnows")
endif()
if(${GUIX})
message(STATUS "Building for GUIX")
endif()
if (NOT ${GUIX})
2024-02-07 20:32:30 +00:00
# ---- Non GUIX Platforms ----
2024-02-04 18:24:04 +00:00
2024-02-14 12:17:31 +00:00
2024-02-07 20:32:30 +00:00
# ---- Download Dependencies ----
include(FetchContent)
2024-02-04 18:24:04 +00:00
2024-02-07 20:32:30 +00:00
# Testing library
FetchContent_Declare(catch GIT_REPOSITORY https://github.com/catchorg/Catch2.git GIT_TAG v3.5.2)
FetchContent_MakeAvailable(catch)
2024-02-04 18:24:04 +00:00
2024-02-07 20:32:30 +00:00
FetchContent_Declare(cpr GIT_REPOSITORY https://github.com/libcpr/cpr.git
GIT_TAG 3b15fa82ea74739b574d705fea44959b58142eb8)
FetchContent_MakeAvailable(cpr)
2024-02-04 18:24:04 +00:00
2024-02-07 20:32:30 +00:00
FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz)
FetchContent_MakeAvailable(json)
2024-02-14 12:17:31 +00:00
FetchContent_Declare(rdricpp URL https://codeberg.org/xieamoe/rdricpp/archive/main.tar.gz) #FIXME Use main repo
FetchContent_MakeAvailable(rdricpp)
endif()
# ---- Non GUIX Platforms With PKG manager ----
2024-02-07 20:32:30 +00:00
#[===[ Find Local Libs
add_subdirectory(json)
add_subdirectory(rdricpp)
]===]
#[===[ NON GUIX PKG MANAGERS
find_package(marisa REQUIRED)
find_package(rdricpp REQUIRED)
find_package(nlohmann-json REQUIRED)
]===]
# ------------------
2024-02-14 12:17:31 +00:00
#Obsolete
2024-02-07 20:32:30 +00:00
#Guix/Unix/Mac/Windows
#add_subdirectory(rdricpp)
#Guix/Unix/Mac
#add_subdirectory(cpr-1.10.5)
2024-02-04 18:24:04 +00:00
# ---- Declare executable ----
2024-02-07 20:32:30 +00:00
#Windows
2024-02-14 12:17:31 +00:00
if (WIN32)
set(SOURCES src/anki_search.cpp src/echo.cpp src/massif.cpp src/images.cpp src/marisa.cpp src/util.cpp src/kana_conv.cpp)
set(HEADERS src/anki_search.h src/unistd_win.h src/echo.h src/massif.h src/images.h src/marisa.h src/util.h src/kana_conv.h)
endif()
2024-02-07 20:32:30 +00:00
#Guix/Unix
2024-02-14 12:17:31 +00:00
if (APPLE OR UNIX OR ${GUIX})
set(SOURCES src/anki_search.cpp src/echo.cpp src/massif.cpp src/images.cpp src/marisa.cpp src/util.cpp src/kana_conv.cpp)
set(HEADERS src/anki_search.h src/echo.h src/massif.h src/images.h src/marisa.h src/util.h src/kana_conv.h)
endif()
2024-02-07 20:32:30 +00:00
2024-02-04 18:24:04 +00:00
add_executable(gd-tools_exe src/main.cpp ${SOURCES} ${HEADERS})
add_executable(gd-tools::exe ALIAS gd-tools_exe)
2024-02-07 20:32:30 +00:00
# ---- Compile ----
set_property(TARGET gd-tools_exe PROPERTY OUTPUT_NAME gd-tools)
2024-02-04 18:24:04 +00:00
target_compile_features(gd-tools_exe PRIVATE cxx_std_23)
2024-02-07 20:32:30 +00:00
#Guix
2024-02-14 12:17:31 +00:00
if (${GUIX})
2024-02-07 20:32:30 +00:00
target_link_libraries(gd-tools_exe PRIVATE cpr marisa rdricpp)
2024-02-14 12:17:31 +00:00
endif()
2024-02-07 20:32:30 +00:00
#Windows
2024-02-14 12:17:31 +00:00
#if (WIN32)
# target_link_libraries(gd-tools_exe PRIVATE libmarisa.a cpr::cpr nlohmann_json::nlohmann_json rdricpp::rdricpp)
#endif()
2024-02-07 20:32:30 +00:00
2024-02-14 12:17:31 +00:00
#Apple and other
if (NOT ${GUIX})
target_link_libraries(gd-tools_exe PRIVATE marisa cpr::cpr nlohmann_json::nlohmann_json rdricpp::rdricpp)
endif()
2024-02-04 18:24:04 +00:00
# ---- Install rules ----
if(NOT CMAKE_SKIP_INSTALL_RULES)
include(cmake/install-rules.cmake)
endif()
2024-02-07 20:32:30 +00:00
include(cmake/dev-mode.cmake)
2024-02-14 12:17:31 +00:00
2024-02-04 18:24:04 +00:00
# ---- Developer mode ----
2024-02-07 20:32:30 +00:00
option(gd-tools_DEVELOPER_MODE "Test gd-tools" ON)
2024-02-04 18:24:04 +00:00
if(NOT gd-tools_DEVELOPER_MODE)
return()
elseif(NOT PROJECT_IS_TOP_LEVEL)
2024-02-14 12:17:31 +00:00
message(AUTHOR_WARNING "Developer mode enabled")
target_link_libraries(gd-tools_exe PRIVATE -lasan -lubsan)
2024-02-04 18:24:04 +00:00
endif()
2024-02-07 20:32:30 +00:00