-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
62 lines (45 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
# CMake version and project name
cmake_minimum_required(VERSION 3.10)
project(TinyML VERSION 1.0 LANGUAGES CXX)
# Set the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# Set output directories for binaries
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# Collect all source files from the src directory
file(GLOB_RECURSE SOURCES "src/*.cpp")
# Print out the source files collected
message(STATUS "Source files: ${SOURCES}")
# Create the main library target
add_library(TinyML ${SOURCES})
# Ensure that the include directories for the library are available to targets that link with the library
target_include_directories(TinyML PUBLIC ${PROJECT_SOURCE_DIR}/include)
# Print the include directories being set
message(STATUS "Include directory for TinyML: ${PROJECT_SOURCE_DIR}/include")
# GoogleTest integration (optional)
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/refs/tags/release-1.12.1.zip
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
# Tests
file(GLOB_RECURSE TEST_SOURCES "tests/*.cpp")
# Print out the test source files collected
message(STATUS "Test source files: ${TEST_SOURCES}")
# Create test executable
add_executable(TinyMLTests ${TEST_SOURCES})
# Link the test executable with Google Test and your library
target_link_libraries(TinyMLTests TinyML gtest gtest_main)
# Ensure the test target also gets the correct include directories
target_include_directories(TinyMLTests PUBLIC ${PROJECT_SOURCE_DIR}/include)
# Print the include directories being set for the test target
message(STATUS "Include directory for TinyMLTests: ${PROJECT_SOURCE_DIR}/include")
# Add test to CMake's testing framework
add_test(NAME TinyMLTests COMMAND TinyMLTests)
# Debugging: Print the include directories that will be passed to the compiler
get_target_property(INCLUDE_DIRS TinyML INCLUDE_DIRECTORIES)
message(STATUS "TinyML include directories: ${INCLUDE_DIRS}")
get_target_property(INCLUDE_DIRS_TEST TinyMLTests INCLUDE_DIRECTORIES)
message(STATUS "TinyMLTests include directories: ${INCLUDE_DIRS_TEST}")