1
0
mirror of synced 2024-12-22 12:40:00 +01:00

66 lines
1.9 KiB
CMake
Raw Permalink Normal View History

2024-11-07 14:42:03 +00:00
# Works with 3.15 and tested through 3.31
cmake_minimum_required(VERSION 3.15...3.31)
2019-08-07 05:06:55 +00:00
# Project name and a few useful settings. Other commands can pick up the results
2020-08-03 18:16:52 -04:00
project(
ModernCMakeExample
VERSION 0.1
DESCRIPTION "An example project with CMake"
LANGUAGES CXX)
2019-08-07 05:06:55 +00:00
# Only do these if this is the main project, and not if it is included through add_subdirectory
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
2020-08-03 18:16:52 -04:00
# Optionally set things like CMAKE_CXX_STANDARD, CMAKE_POSITION_INDEPENDENT_CODE here
2019-08-07 05:06:55 +00:00
2020-08-03 18:16:52 -04:00
# Let's ensure -std=c++xx instead of -std=g++xx
set(CMAKE_CXX_EXTENSIONS OFF)
2019-08-07 05:06:55 +00:00
2020-08-03 18:16:52 -04:00
# Let's nicely support folders in IDEs
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
2019-08-07 05:06:55 +00:00
2020-08-03 18:16:52 -04:00
# Testing only available if this is the main app
# Note this needs to be done in the main CMakeLists
# since it calls enable_testing, which must be in the
# main CMakeLists.
include(CTest)
2019-08-07 05:06:55 +00:00
2020-08-03 18:16:52 -04:00
# Docs only available if this is the main app
find_package(Doxygen)
if(Doxygen_FOUND)
add_subdirectory(docs)
else()
message(STATUS "Doxygen not found, not building docs")
endif()
endif()
2019-08-07 05:06:55 +00:00
# FetchContent added in CMake 3.11, downloads during the configure step
# FetchContent_MakeAvailable was added in CMake 3.14; simpler usage
2019-08-07 05:06:55 +00:00
include(FetchContent)
# Accumulator library
# This is header only, so could be replaced with git submodules or FetchContent
find_package(Boost REQUIRED)
# Adds Boost::boost
# Formatting library
FetchContent_Declare(
fmtlib
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
2020-08-03 18:16:52 -04:00
GIT_TAG 5.3.0)
2019-08-07 05:06:55 +00:00
FetchContent_MakeAvailable(fmtlib)
# Adds fmt::fmt
# The compiled library code is here
add_subdirectory(src)
# The executable code is here
add_subdirectory(apps)
# Testing only available if this is the main app
# Emergency override MODERN_CMAKE_BUILD_TESTING provided as well
2020-08-03 18:16:52 -04:00
if((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR MODERN_CMAKE_BUILD_TESTING)
AND BUILD_TESTING)
add_subdirectory(tests)
2019-08-07 05:06:55 +00:00
endif()