-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
61 lines (46 loc) · 1.87 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
cmake_minimum_required(VERSION 3.20)
set (CMAKE_CXX_STANDARD 14)
project(BigBrian VERSION 1.0.0)
include(CTest)
add_subdirectory("./brian")
### UNIT TESTING
# So this was a process, but essentially for ease of compatibility with IDE
# debuggers, I'm making each unit test it's own executable, all stored in a
# similar fashion that they are when they are compiled execept inside the
# output directory.
set(TestsToRun
"test/src/sample.cpp"
"test/src/math/matrix/init.cpp"
"test/src/math/matrix/mult.cpp"
"test/src/math/matrix/mult_reuse.cpp"
"test/src/math/matrix/add.cpp"
"test/src/math/matrix/add_reuse.cpp"
"test/src/math/matrix/str.cpp"
"test/src/math/matrix/mutate.cpp"
"test/src/network/init.cpp"
"test/src/network/feedforward.cpp"
"test/src/network/score.cpp"
"test/src/network/backpropagation.cpp"
"test/src/population/train.cpp"
"test/src/util/parser_ds_csv.cpp"
)
set(UtilSource "test/src/util.cpp")
foreach(test ${TestsToRun})
get_filename_component(TestName ${test} NAME_WE)
# string(REGEX REPLACE "/[^/]*$" "" Dir ${test})
string(REGEX REPLACE "^test/src/" "" RemoveTestDir ${test})
if (RemoveTestDir MATCHES "/")
string(REGEX REPLACE "/[^/]*$" "" TestDirPath ${RemoveTestDir})
string(REGEX REPLACE "/" "_" TestDirName ${TestDirPath})
set(TestTarget ${TestDirName}_${TestName})
else()
set(TestDirPath "")
set(TestTarget ${TestName})
endif()
message("Adding Test: ${TestTarget}")
add_executable(${TestTarget} ${test} ${UtilSource})
set_target_properties(${TestTarget} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}tests/${TestDirPath}/")
target_link_libraries(${TestTarget} BigBrianLib)
target_include_directories(${TestTarget} PRIVATE "test/include/")
add_test(NAME ${TestTarget} COMMAND ${TestTarget})
endforeach()