mdml-cgi/CMakeLists.txt

144 lines
3.5 KiB
CMake
Raw Permalink Normal View History

cmake_minimum_required(VERSION 3.26)
2023-08-31 23:55:47 +00:00
set(mdml_CMAKE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(mdml_INCLUDE_DIR ${mdml_CMAKE_SOURCE_DIR}/include)
# Additional paths to search for custom and third-party CMake modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
2023-09-13 00:35:14 +00:00
include(BuildProperties)
prevent_in_source_build()
disable_deprecated_features()
# When this package is included as a subproject, there's no need to
# build and run the unit-tests.
# This sets -DENABLE_TESTS to false by default if this is a third-party lib build
# This check must appear before project()
disable_tests_if_subproject()
project(mdml
VERSION 0.3.0
LANGUAGES C CXX
# HOMEPAGE_URL
DESCRIPTION "A CGI script written in C++ that converts markdown to HTML"
2023-09-12 20:40:06 +00:00
)
include(CPM)
# Detect if the current operating system is Linux
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
option(USE_BOOST_STACKTRACE "Use Boost for stacktraces, instead of execinfo.h" ON)
else()
option(USE_BOOST_STACKTRACE "Use Boost for stacktraces, instead of execinfo.h" OFF)
endif()
IF( NOT CMAKE_BUILD_TYPE )
SET( CMAKE_BUILD_TYPE Debug )
ENDIF()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 17)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_CXX_EXTENSIONS OFF)
# Search for the code caching compiler wrapper, ccache and enable it
# if found. This will speed up repeated builds.
if (USE_CCACHE)
message(CHECK_START "Detecting cacche")
2023-09-08 05:35:15 +00:00
find_program(CCACHE_PATH ccache)
if(CCACHE_PATH)
message(CHECK_PASS("found"))
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_PATH})
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE_PATH})
endif()
list(APPEND CMAKE_MESSAGE_INDENT " ")
message(STATUS "(set -DUSE_CCACHE=Off to disable)")
list(POP_BACK CMAKE_MESSAGE_INDENT)
endif()
# Import standard dependency management CMake modules
2023-08-31 23:55:47 +00:00
include(FetchContent)
include(CheckIncludeFile)
CPMFindPackage(NAME cmark
GITHUB_REPOSITORY commonmark/cmark
GIT_TAG 0.31.0
OPTIONS
"BUILD_SHARED_LIBS OFF"
"BUILD_TESTING OFF"
)
if (cmark_ADDED AND TARGET cmark_exe)
set_target_properties(cmark_exe PROPERTIES EXCLUDE_FROM_ALL 1)
endif()
if(cmark_FOUND)
list(APPEND CMAKE_MODULE_PATH ${cmark_DIR})
endif()
CPMFindPackage(NAME nlohmann_json
GITHUB_REPOSITORY nlohmann/json
GIT_TAG 3.11.2
OPTIONS
"BUILD_SHARED_LIBS OFF"
"BUILD_TESTING OFF"
)
CPMAddPackage(NAME IOCore
#GIT_REPOSITORY "file://${CMAKE_CURRENT_SOURCE_DIR}/../IOCore"
#GIT_TAG HEAD
GIT_REPOSITORY "https://gitea.beniquez.me/sdaveb/IOCore.git"
GIT_TAG v0.2.10
OPTIONS
"BUILD_SHARED_LIBS OFF"
"BUILD_TESTING OFF"
)
if (BUILD_TESTING)
CPMFindPackage(NAME Catch2
GITHUB_REPOSITORY catchorg/Catch2
VERSION 3.4.0
OPTIONS
"CATCH_DEVELOPMENT_BUILD OFF"
"CATCH_BUILD_TESTING OFF"
)
CPMFindPackage(NAME FakeIt
GITHUB_REPOSITORY eranpeer/FakeIt
GIT_TAG 2.4.0
OPTIONS
"ENABLE_TESTING OFF"
)
if (Catch2_ADDED)
if (TARGET Catch2)
set_target_properties(Catch2 PROPERTIES
CXX_STANDARD 20
)
endif()
if (TARGET Catch2WithMain)
set_target_properties(Catch2WithMain PROPERTIES
CXX_STANDARD 20
)
endif()
list(APPEND CMAKE_MODULE_PATH ${Catch2_SOURCE_DIR}/extras)
else()
list(APPEND CMAKE_MODULE_PATH ${Catch2_DIR})
message("Using internal cmake")
endif()
endif()
add_data_target(NAME prod-data
PATH "${mdml_CMAKE_SOURCE_DIR}/data"
DESTINATION ${CMAKE_BINARY_DIR}/share/
)
set_artifact_dir(${CMAKE_BINARY_DIR}/out)
2023-08-31 23:55:47 +00:00
add_subdirectory(src)
if (BUILD_TESTING)
add_subdirectory(tests)
endif()
# vim: ft=cmake sw=4 ts=4 noet sts=4 foldmethod=indent :