-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
72 lines (57 loc) · 2.12 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
cmake_minimum_required(VERSION 3.18)
project(ChunkTypesProject CXX)
# Set directory vars
set(SOURCE_DIR "source")
set(INCLUDE_DIR "include")
set(SOURCE_TESTS_DIR "source_tests")
set(INCLUDE_TESTS_DIR "include_tests")
if(DEFINED ENV{IDF_PATH}) # this is normally only set when running in an esp idf terminal
message(STATUS "Building for ESP32")
idf_component_register(
SRCS
${SOURCE_DIR}/BaseChunk.cpp
${SOURCE_DIR}/TimeChunk.cpp
${SOURCE_DIR}/UDPChunk.cpp
${SOURCE_DIR}/WAVChunk.cpp
${SOURCE_DIR}/WatchdogChunk.cpp
${SOURCE_DIR}/FFTChunk.cpp
INCLUDE_DIRS
${INCLUDE_DIR}
)
else()
message(STATUS "Building for Unix")
# Set C++ standard
set(CMAKE_CXX_STANDARD 20)
# Main executable
file(GLOB SOURCES "${SOURCE_DIR}/*.cpp")
add_library(ChunkTypesLib
${SOURCES}
)
# Test executable
add_executable(ChunkTypesTests
${SOURCE_TESTS_DIR}/ChunkTypesTest.cpp
)
# Include directories for main code and tests
target_include_directories(ChunkTypesLib
PRIVATE ${INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/components/Nlohmann_JSON/include
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/components/Nlohmann_JSON/include/nlohmann
)
target_include_directories(ChunkTypesTests
PRIVATE ${INCLUDE_DIR}
PRIVATE ${INCLUDE_TESTS_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/components/doctest/doctest
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/components/Nlohmann_JSON/include
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/components/Nlohmann_JSON/include/nlohmann
)
# Add components (even if no CMakeLists.txt)
add_subdirectory(components/doctest)
# Link with required libraries for the main executable
target_link_libraries(ChunkTypesLib PRIVATE doctest::doctest)
# Link with required libraries for the test executable
target_link_libraries(ChunkTypesTests PRIVATE ChunkTypesLib doctest::doctest)
# Enable testing
enable_testing()
# Add tests to CTest
add_test(NAME ChunkTypesTests COMMAND ChunkTypesTests)
endif()