-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
114 lines (85 loc) · 3.36 KB
/
CMakeLists.txt
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
# ----------------------------------- SETTINGS ---------------------------------
cmake_minimum_required(VERSION 3.0.0)
project(lamscript)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
# ----------------------------------- OPTIONS ----------------------------------
option(LAMSCRIPT_BUILD_EXECUTABLE "Build lamscript as an executable" ON)
option(LAMSCRIPT_BUILD_LIBRARY "Build lamscript as a static library" ON)
option(
LAMSCRIPT_BUILD_TESTS
"Build the tests for lamscript. (Must be building as a library)"
ON)
option(
LAMSCRIPT_ENABLE_EXPERIMENTATION
"Enable experimentation features."
OFF)
option(
LAMSCRIPTEN_BUILD_EXECUTABLE
"Build lamscripten. Requires LAMSCRIPT_INCLUDE_EXPERIMENTATION to be ON."
ON)
# -------------------------------- DEPENDENCIES --------------------------------
# SPDLog -- Utilized for fast logging output and control.
add_subdirectory(${CMAKE_SOURCE_DIR}/vendor/spdlog)
# ----------------------------------- LAMSCRIPT --------------------------------
if (LAMSCRIPT_BUILD_EXECUTABLE)
file(
GLOB_RECURSE
LAMSCRIPT_SRC
${CMAKE_SOURCE_DIR}/src/Lamscript/*.cpp
${CMAKE_SOURCE_DIR}/src/Lamscript/*.h)
add_executable(lamscript ${LAMSCRIPT_SRC})
target_link_libraries(lamscript spdlog::spdlog)
target_compile_definitions(
lamscript
PUBLIC LAMSCRIPT_BUILD_AS_EXECUTABLE)
target_include_directories(lamscript PUBLIC ${CMAKE_SOURCE_DIR}/src)
endif()
# -------------------------------- LAMSCRIPT LIB -------------------------------
if (LAMSCRIPT_BUILD_LIBRARY)
add_library(lamscript_lib STATIC ${LAMSCRIPT_SRC})
target_include_directories(lamscript_lib PUBLIC ${CMAKE_SOURCE_DIR}/src)
target_link_libraries(lamscript_lib spdlog::spdlog)
if (${CMAKE_BUILD_TYPE} EQUAL Debug)
target_compile_definitions(
lamscript
PUBLIC LAMSCRIPT_LOGGING_ENABLED)
target_compile_definitions(
lamscript_lib
PUBLIC LAMSCRIPT_LOGGING_ENABLED)
endif()
endif()
# ----------------------------------- TESTING ----------------------------------
if (LAMSCRIPT_BUILD_TESTS)
add_subdirectory(${CMAKE_SOURCE_DIR}/vendor/googletest)
file(
GLOB_RECURSE
LAMSCRIPT_TEST_SRC
${CMAKE_SOURCE_DIR}/tests/*.cpp)
add_executable(lamscript_tests ${LAMSCRIPT_TEST_SRC})
add_test(NAME lamscript_tests COMMAND lamscript_tests)
target_link_libraries(
lamscript_tests
PUBLIC lamscript_lib gtest)
target_include_directories(
lamscript_tests
PUBLIC ${CMAKE_SOURCE_DIR}/src)
endif()
# ----------------------------- EXPERIMENTATION --------------------------------
if (LAMSCRIPT_ENABLE_EXPERIMENTATION)
if (LAMSCRIPTEN_BUILD_EXECUTABLE)
file(
GLOB_RECURSE
LAMSCRIPTEN_SRC
${CMAKE_SOURCE_DIR}/src/Lamscripten/*.cpp
${CMAKE_SOURCE_DIR}/src/Lamscripten/*.h)
add_executable(lamscripten ${LAMSCRIPTEN_SRC})
target_include_directories(lamscripten PUBLIC ${CMAKE_SOURCE_DIR}/src)
endif()
endif()