-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
44 lines (32 loc) · 1.21 KB
/
CMakeLists.txt
File metadata and controls
44 lines (32 loc) · 1.21 KB
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
cmake_minimum_required(VERSION 3.20)
project(RPC_MARCEL_CODE)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_BUILD_TYPE Debug)
# Include directories
include_directories(headers headers/utils includes/Eigen)
# Find all header files
file(GLOB_RECURSE HEADERS "headers/*.hpp")
# Find all source files
file(GLOB_RECURSE SOURCES "sources/*.cpp")
# Exclude mainWork.cpp from the library sources
list(REMOVE_ITEM SOURCES "sources/mainWork.cpp")
# Create a library with all the common source files
add_library(rpc_lib STATIC ${SOURCES})
# Enable testing with CTest
enable_testing()
# Find all test files
file(GLOB_RECURSE TESTS "tests/*.cpp")
# Add a test for each test file
foreach(test_file ${TESTS})
# Get the test name from the file name
get_filename_component(test_name ${test_file} NAME_WE)
# Add the test executable and link it to the library
add_executable(${test_name} ${test_file})
target_link_libraries(${test_name} rpc_lib)
# Add the test to CTest
add_test(NAME ${test_name} COMMAND ${test_name})
endforeach()
# Add the main executable and link it to the library
add_executable(${PROJECT_NAME} sources/mainWork.cpp)
target_link_libraries(${PROJECT_NAME} rpc_lib)