-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
44 lines (29 loc) · 1.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
cmake_minimum_required(VERSION 3.1..3.25)
# project name
project(machine_learning_S6)
# where do get the headers files
include_directories(include)
# making the list of sources files
file(GLOB_RECURSE SOURCE_FILES src/*)
# creating the library with the sources files
add_library(${PROJECT_NAME} ${SOURCE_FILES})
# creating the executable from src/main.cpp
add_executable(run src/main.cpp)
# linking the executable with the library
target_link_libraries(run ${PROJECT_NAME})
# Unitary testing
enable_testing()
message(STATUS "Adding tests : ")
# getting test files
file(GLOB_RECURSE TEST_FILES tests/*.cpp)
foreach(TEST_FILES ${TEST_FILES})
# get the name without the extension
get_filename_component(TEST_NAME ${TEST_FILES} NAME_WE)
# creating the executable
add_executable(${TEST_NAME}.out ${TEST_FILES})
# linking the executable with the library
target_link_libraries(${TEST_NAME}.out ${PROJECT_NAME})
# addind the test_name which uses test_name.out executable
add_test(${TEST_NAME} ${TEST_NAME}.out)
message(" - ${TEST_NAME}")
endforeach()