-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
94 lines (76 loc) · 1.73 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
cmake_minimum_required(VERSION 3.16.3)
project(leapc_example VERSION "1.0.0" LANGUAGES C)
if (WIN32)
set(ULTRALEAP_PATH_ROOT "$ENV{ProgramFiles}/Ultraleap")
elseif (APPLE)
set(ULTRALEAP_PATH_ROOT "/Applications/Ultraleap\ Hand\ Tracking.app/Contents/LeapSDK/lib/cmake/LeapSDK")
else()
# Linux and other OSs
set(ULTRALEAP_PATH_ROOT "")
endif()
find_package(LeapSDK
5
REQUIRED
PATHS
"${ULTRALEAP_PATH_ROOT}")
if (UNIX)
find_package(Threads REQUIRED)
endif (UNIX)
add_executable(
leapc_example
"leapc_main.c")
target_link_libraries(
leapc_example
PRIVATE
LeapSDK::LeapC
-lwsock32
-lws2_32)
get_target_property(
LEAPC_IMPORTED_CONFIG
LeapSDK::LeapC
IMPORTED_CONFIGURATIONS
)
get_target_property(
LEAPC_SHARED_LIB_PATH
LeapSDK::LeapC
IMPORTED_LOCATION_${LEAPC_IMPORTED_CONFIG}
)
add_custom_command(
TARGET
leapc_example
POST_BUILD
COMMAND
${CMAKE_COMMAND} -E copy
${LEAPC_SHARED_LIB_PATH}
$<TARGET_FILE_DIR:leapc_example>)
add_library(
libExampleConnection
OBJECT
"ExampleConnection.c")
target_link_libraries(
libExampleConnection
PUBLIC
LeapSDK::LeapC
-lwsock32
-lws2_32)
if (UNIX)
target_link_libraries(
libExampleConnection
PRIVATE
Threads::Threads)
endif()
target_include_directories(
libExampleConnection
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR})
# Add targets for each sample file.
function(add_sample sample_name sample_source_file)
add_executable(${sample_name} ${sample_source_file})
set_property(TARGET ${sample_name} PROPERTY FOLDER "Samples")
if(NOT WIN32)
target_link_libraries(${sample_name} PUBLIC libExampleConnection m)
else()
target_link_libraries(${sample_name} PUBLIC libExampleConnection)
endif()
endfunction()
add_sample("Seminar" "Seminar.c")