-
Notifications
You must be signed in to change notification settings - Fork 5
/
project_utils.cmake
41 lines (32 loc) · 1.18 KB
/
project_utils.cmake
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
# heaphook implementations
set(HEAPHOOK_SOURCES
${heaphook_SOURCE_DIR}/src/heaphook/heaptracer.cpp
${heaphook_SOURCE_DIR}/src/heaphook/hook_functions.cpp
${heaphook_SOURCE_DIR}/src/heaphook/heaphook.cpp
${heaphook_SOURCE_DIR}/src/heaphook/utils.cpp)
# build_library function
function(build_library LIB_NAME_AND_SOURCES)
list(GET ARGV 0 LIB_NAME)
list(REMOVE_AT ARGV 0)
set(SOURCES ${ARGV})
add_library(${LIB_NAME} SHARED
${SOURCES}
${HEAPHOOK_SOURCES})
target_include_directories(${LIB_NAME}
PRIVATE ${heaphook_SOURCE_DIR}/include)
set_target_properties(${LIB_NAME} PROPERTIES LINK_FLAGS "-Wl,--version-script=${heaphook_SOURCE_DIR}/Versions")
install(TARGETS ${LIB_NAME} DESTINATION lib)
endfunction()
# test_library function
function(test_library LIB_NAME_AND_SOURCES) # === test_library ===
list(GET ARGV 0 TEST_NAME)
list(REMOVE_AT ARGV 0)
set(SOURCES ${ARGV})
ament_add_gtest(${TEST_NAME}
${heaphook_SOURCE_DIR}/test/test_allocator.cpp
${SOURCES}
${HEAPHOOK_SOURCES})
target_include_directories(${TEST_NAME}
PRIVATE ${heaphook_SOURCE_DIR}/include)
install(TARGETS ${TEST_NAME} DESTINATION lib)
endfunction() # === test_library ===