1
- cmake_minimum_required (VERSION 3.12 )
1
+ cmake_minimum_required (VERSION 3.23 )
2
2
project (lslexamples
3
3
LANGUAGES C CXX
4
4
VERSION 0.2.0 )
5
5
find_package (LSL REQUIRED
6
- HINTS ${LSL_INSTALL_ROOT}
7
- "${CMAKE_CURRENT_LIST_DIR} /../build"
8
- "${CMAKE_CURRENT_LIST_DIR} /../out/x64-Release"
9
- PATH_SUFFIXES share/LSL )
6
+ HINTS
7
+ ${LSL_INSTALL_ROOT}
8
+ "${CMAKE_CURRENT_LIST_DIR} /../install" # GHA scripts default install directory
9
+ "${CMAKE_CURRENT_LIST_DIR} /../cmake-build-release/install" # CLion default if using -DCMAKE_INSTALL_PREFIX=install
10
+ "${CMAKE_CURRENT_LIST_DIR} /../out/x64-Release/install" # MSVC default if using -DCMAKE_INSTALL_PREFIX=install TODO: Check this
11
+ PATH_SUFFIXES share/LSL
12
+ )
10
13
get_filename_component (LSL_PATH ${LSL_CONFIG} DIRECTORY )
11
14
message (STATUS "Found LSL lib in ${LSL_PATH} " )
12
- message (STATUS "LSL BIN DIR: ${liblsl_BINARY_DIR} & ${LIBLSL_BINARY_DIR} " )
15
+
16
+ # Include the LSLCMake.cmake file, just for testing.
17
+ # This doesn't do much for us now that we don't use installLSLApp() anymore.
18
+ include ("${LSL_PATH} /LSLCMake.cmake" )
13
19
14
20
# convenience function to add an example file
15
21
# this creates a target, links the necessary libraries and
@@ -20,7 +26,39 @@ function(addlslexample name extension)
20
26
)
21
27
target_link_libraries (${name} PRIVATE LSL::lsl )
22
28
target_compile_features (${name} PRIVATE cxx_constexpr )
23
- installLSLApp (${name} )
29
+
30
+ # Set RPATH properties for macOS and Linux
31
+ set_target_properties (${name} PROPERTIES
32
+ INSTALL_RPATH_USE_LINK_PATH TRUE
33
+ BUILD_WITH_INSTALL_RPATH FALSE
34
+ )
35
+
36
+ # One might also want to do the following, to give the option of copying the
37
+ # LSL library to the same directory or install tree as the executable.
38
+ # However, this is not necessary for the examples, as they are not intended to be relocated.
39
+ # if(APPLE)
40
+ # set_target_properties(${name} PROPERTIES
41
+ # INSTALL_RPATH "@loader_path;@loader_path/../lib"
42
+ # )
43
+ # elseif(UNIX)
44
+ # set_target_properties(${name} PROPERTIES
45
+ # INSTALL_RPATH "$ORIGIN:$ORIGIN/../lib"
46
+ # )
47
+ # endif()
48
+
49
+ install (TARGETS ${name}
50
+ COMPONENT ${PROJECT_NAME}
51
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
52
+ )
53
+ if (WIN32 )
54
+ # On Windows, we need to copy the DLLs to the same directory as the executable
55
+ # if we wish to run the example without putting the DLLs in the PATH.
56
+ install (
57
+ FILES $< TARGET_FILE:LSL::lsl>
58
+ DESTINATION ${CMAKE_INSTALL_BINDIR}
59
+ COMPONENT ${PROJECT_NAME}
60
+ )
61
+ endif (WIN32 )
24
62
endfunction ()
25
63
26
64
find_package (Threads )
@@ -46,4 +84,3 @@ addlslexample(SendStringMarkersC c)
46
84
addlslexample (TestSyncWithoutData cpp )
47
85
48
86
target_link_libraries (TestSyncWithoutData PRIVATE Threads::Threads )
49
-
0 commit comments