-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
74 lines (59 loc) · 2.09 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
#==============================================================
# Simple CMake used to run the demo application
#==============================================================
set(APP_NAME "demo")
cmake_minimum_required(VERSION 3.8) # set minimum
project(${APP_NAME} C CXX) # set project name
# C and C++ standards
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Test Configuration
include(CTest)
enable_testing()
#Include root directory for header lookup
include_directories(..)
#include the scheduler library
add_subdirectory(scheduler)
#build the demo application
add_executable(${APP_NAME} sample/demo.cpp)
#link the LEAN_SCHEDULER library
target_link_libraries(
${APP_NAME}
PUBLIC LEAN_SCHEDULER
)
# Pull CppUTest suite
#==============================================================
if(BUILD_TESTING)
# Fetch CppUTest
include(FetchContent)
FetchContent_Declare(
CppUTest
GIT_REPOSITORY https://github.com/cpputest/cpputest.git
GIT_TAG latest-passing-build # or use release tag, eg. v3.8
)
# Set this to ON if you want to have the CppUTests in your project as well.
set(TESTS OFF CACHE BOOL "Switch off CppUTest Test build")
FetchContent_MakeAvailable(CppUTest)
#Build the test
add_executable(TEST_LEAN_SCHEDULER
tests/AllTests.cpp
tests/test_Lean_Scheduler.cpp)
# The code below is NECESSARY to provide the subdirectories
# include access to the pulled resource (CppUTest)
# Otherwise, the ff. line will not see the TARGET and hence will throw a CMake Error
target_include_directories(TEST_LEAN_SCHEDULER PRIVATE ${CppUTest_SOURCE_DIR}/include)
add_definitions(-ln -lg -c)
target_include_directories(TEST_LEAN_SCHEDULER PRIVATE scheduler)
# Link the code under test and the CppUTest libraryto the test suite
target_link_libraries(TEST_LEAN_SCHEDULER PUBLIC
LEAN_SCHEDULER
CppUTest
CppUTestExt
)
# Add test
add_test(
NAME TEST_LEAN_SCHEDULER
COMMAND TEST_LEAN_SCHEDULER.exe -c
)
endif()