-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
117 lines (94 loc) · 2.64 KB
/
Copy pathCMakeLists.txt
File metadata and controls
117 lines (94 loc) · 2.64 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
cmake_minimum_required(VERSION 3.14)
project(concordia C CXX)
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()
if(POLICY CMP0169)
cmake_policy(SET CMP0169 OLD)
endif()
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 14)
if(MSVC)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
endif()
# --- Version Info ---
find_package(Git)
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --always --dirty
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
else()
set(GIT_VERSION "unknown")
set(GIT_HASH "unknown")
endif()
if("${GIT_VERSION}" STREQUAL "")
set(GIT_VERSION "dev")
endif()
add_compile_definitions(CND_VERSION="${GIT_VERSION}")
add_compile_definitions(CND_GIT_HASH="${GIT_HASH}")
# --- Compiler Warnings ---
option(ENABLE_PEDANTIC "Enable pedantic warnings" ON)
if(ENABLE_PEDANTIC)
if(MSVC)
add_compile_options(/W4 /permissive-)
else()
add_compile_options(-Wall -Wextra -pedantic)
endif()
endif()
# --- Dependencies ---
include(FetchContent)
# GoogleTest
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/refs/heads/main.zip
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
# Google Benchmark
FetchContent_Declare(
benchmark
URL https://github.com/google/benchmark/archive/refs/tags/v1.9.1.zip
)
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE)
set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(benchmark)
# cJSON
FetchContent_Declare(
cjson
URL https://github.com/DaveGamble/cJSON/archive/refs/heads/master.zip
)
FetchContent_GetProperties(cjson)
if(NOT cjson_POPULATED)
FetchContent_Populate(cjson)
# Add library manually to bypass legacy CMakeLists.txt issues
add_library(cjson ${cjson_SOURCE_DIR}/cJSON.c)
target_include_directories(cjson PUBLIC ${cjson_SOURCE_DIR})
endif()
# --- Subdirectories ---
enable_testing()
# Core Libraries
add_subdirectory(src/vm)
add_subdirectory(src/compiler)
# Tools & CLI
add_subdirectory(src/tools)
add_subdirectory(src/cli)
# Tests & Benchmarks
add_subdirectory(tests)
add_subdirectory(benchmarks)
# Examples & Demos
add_subdirectory(demos)
add_subdirectory(examples)
# --- Installation ---
include(GNUInstallDirs)
# Install headers
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})