141 lines
3.5 KiB
CMake
141 lines
3.5 KiB
CMake
cmake_minimum_required(VERSION 3.14)
|
|
|
|
include(cmake/prelude.cmake)
|
|
|
|
project(
|
|
gd-tools
|
|
VERSION 1.5
|
|
DESCRIPTION "A set of helpful programs to enhance goldendict for immersion learning."
|
|
HOMEPAGE_URL "https://github.com/Ajatt-Tools/gd-tools"
|
|
LANGUAGES CXX
|
|
)
|
|
option(GUIX "Build for Guix" OFF) # OFF by default
|
|
|
|
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)
|
|
|
|
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})
|
|
# ---- Non GUIX Platforms ----
|
|
|
|
|
|
# ---- Download Dependencies ----
|
|
|
|
include(FetchContent)
|
|
|
|
# Testing library
|
|
FetchContent_Declare(catch GIT_REPOSITORY https://github.com/catchorg/Catch2.git GIT_TAG v3.5.2)
|
|
FetchContent_MakeAvailable(catch)
|
|
|
|
FetchContent_Declare(cpr GIT_REPOSITORY https://github.com/libcpr/cpr.git
|
|
GIT_TAG 3b15fa82ea74739b574d705fea44959b58142eb8)
|
|
FetchContent_MakeAvailable(cpr)
|
|
|
|
FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz)
|
|
FetchContent_MakeAvailable(json)
|
|
|
|
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 ----
|
|
#[===[ 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)
|
|
]===]
|
|
# ------------------
|
|
|
|
#Obsolete
|
|
#Guix/Unix/Mac/Windows
|
|
#add_subdirectory(rdricpp)
|
|
|
|
#Guix/Unix/Mac
|
|
#add_subdirectory(cpr-1.10.5)
|
|
|
|
|
|
|
|
# ---- Declare executable ----
|
|
|
|
#Windows
|
|
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()
|
|
|
|
#Guix/Unix
|
|
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()
|
|
|
|
add_executable(gd-tools_exe src/main.cpp ${SOURCES} ${HEADERS})
|
|
add_executable(gd-tools::exe ALIAS gd-tools_exe)
|
|
|
|
|
|
# ---- Compile ----
|
|
|
|
set_property(TARGET gd-tools_exe PROPERTY OUTPUT_NAME gd-tools)
|
|
target_compile_features(gd-tools_exe PRIVATE cxx_std_23)
|
|
|
|
#Guix
|
|
if (${GUIX})
|
|
target_link_libraries(gd-tools_exe PRIVATE cpr marisa rdricpp)
|
|
endif()
|
|
|
|
#Windows
|
|
#if (WIN32)
|
|
# target_link_libraries(gd-tools_exe PRIVATE libmarisa.a cpr::cpr nlohmann_json::nlohmann_json rdricpp::rdricpp)
|
|
#endif()
|
|
|
|
#Apple and other
|
|
if (NOT ${GUIX})
|
|
target_link_libraries(gd-tools_exe PRIVATE marisa cpr::cpr nlohmann_json::nlohmann_json rdricpp::rdricpp)
|
|
endif()
|
|
|
|
# ---- Install rules ----
|
|
|
|
if(NOT CMAKE_SKIP_INSTALL_RULES)
|
|
include(cmake/install-rules.cmake)
|
|
endif()
|
|
|
|
include(cmake/dev-mode.cmake)
|
|
|
|
# ---- Developer mode ----
|
|
|
|
option(gd-tools_DEVELOPER_MODE "Test gd-tools" ON)
|
|
|
|
if(NOT gd-tools_DEVELOPER_MODE)
|
|
return()
|
|
elseif(NOT PROJECT_IS_TOP_LEVEL)
|
|
message(AUTHOR_WARNING "Developer mode enabled")
|
|
target_link_libraries(gd-tools_exe PRIVATE -lasan -lubsan)
|
|
endif()
|
|
|
|
|