aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: b46834cb2b7fe1a85613566554aabab6b7d57ab4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
cmake_minimum_required(VERSION "3.30.0")

project("newtype"
  LANGUAGES CXX
  DESCRIPTION "A library of types and functions to create strong type aliases"
  VERSION "2.0.0"
)

# Project Options

option(NEWTYPE_BUILD_DOCS      "Build the library documentation" OFF)
option(NEWTYPE_BUILD_EXAMPLES  "Build the library examples" OFF)
option(NEWTYPE_BUILD_TESTS     "Build the library tests" OFF)

# Project Dependencies

include("FetchContent")

if(NEWTYPE_BUILD_TESTS)
  FetchContent_Declare(
    "Catch2"
    URL "https://github.com/catchorg/Catch2/archive/refs/tags/v3.7.0.zip"
    URL_HASH "SHA256=75b04c94471a70680f10f5d0d985bd1a96b8941d040d6a7bfd43f6c6b1de9daf"
    EXCLUDE_FROM_ALL
    FIND_PACKAGE_ARGS
    "3.7.0" EXACT
    COMPONENTS "Catch2WithMain"
  )

  FetchContent_MakeAvailable("Catch2")

  include("Catch")
endif()

# Project Components

add_subdirectory("lib")

if(NEWTYPE_BUILD_DOCS)
  add_subdirectory("doc")
endif()

if(NEWTYPE_BUILD_EXAMPLES)
  include("cmake/Modules/AddExample.cmake")
  add_subdirectory("examples")
endif()

if(NEWTYPE_BUILD_TESTS)
  enable_testing()
  add_subdirectory("tests")
endif()