-
Notifications
You must be signed in to change notification settings - Fork 3
/
CmakeLists.txt
48 lines (33 loc) · 1.43 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
cmake_minimum_required (VERSION 3.0)
project (matching_engine)
# Make your header file accessible to the compiler
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib)
# used by rtags
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# -g for lldb debugging
set(CMAKE_CXX_FLAGS "-g -Wall -std=c++14 -stdlib=libc++")
file(GLOB SOURCES "src/*.cpp")
add_library(libmatching_engine SHARED ${SOURCES})
enable_testing()
find_package(Boost 1.60 COMPONENTS unit_test_framework)
include_directories (${Boost_INCLUDE_DIRS})
## Test units
file(GLOB TEST_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} test/*.cpp)
#Run through each source
foreach(testSrc ${TEST_SRCS})
#Extract the filename without an extension (NAME_WE)
get_filename_component(testName ${testSrc} NAME_WE)
#Add compile target
add_executable(${testName} ${testSrc})
#link to Boost libraries AND your targets and dependencies
target_link_libraries(${testName} ${Boost_LIBRARIES} libmatching_engine)
# move testing binaries into a testBin directory
set_target_properties(${testName} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
#Add it to test execution -
add_test(NAME ${testName}
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${testName})
endforeach(testSrc)