@@ -2,12 +2,16 @@ cmake_minimum_required(VERSION 3.23)
2
2
project (lslexamples
3
3
LANGUAGES C CXX
4
4
VERSION 0.2.0 )
5
+
6
+ include (GNUInstallDirs )
7
+
5
8
find_package (LSL REQUIRED
6
9
HINTS
7
10
${LSL_INSTALL_ROOT}
8
11
"${CMAKE_CURRENT_LIST_DIR} /../install" # GHA scripts default install directory
9
12
"${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
13
+ "${CMAKE_CURRENT_LIST_DIR} /../cmake-build-release-visual-studio/install" # CLion default if using VS compiler
14
+ "${CMAKE_CURRENT_LIST_DIR} /../out/build/x64-Release/install" # MSVC default if using -DCMAKE_INSTALL_PREFIX=install
11
15
PATH_SUFFIXES share/LSL
12
16
)
13
17
get_filename_component (LSL_PATH ${LSL_CONFIG} DIRECTORY )
@@ -50,15 +54,6 @@ function(addlslexample name extension)
50
54
COMPONENT ${PROJECT_NAME}
51
55
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
52
56
)
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 )
62
57
endfunction ()
63
58
64
59
find_package (Threads )
@@ -84,3 +79,19 @@ addlslexample(SendStringMarkersC c)
84
79
addlslexample (TestSyncWithoutData cpp )
85
80
86
81
target_link_libraries (TestSyncWithoutData PRIVATE Threads::Threads )
82
+
83
+ # Windows doesn't have RPATH so we put the dll into the same directory as the executable.
84
+ if (WIN32 )
85
+ # For one of the targets, copy the lsl.dll into the build directory so we can debug the examples if needed.
86
+ add_custom_command (TARGET HandleMetaData POST_BUILD
87
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
88
+ "$<TARGET_FILE:LSL::lsl>"
89
+ $< TARGET_FILE_DIR:HandleMetaData>
90
+ COMMENT "Copying lsl.dll to examples build directory"
91
+ )
92
+ # Install the lsl.dll to the same directory as the executable.
93
+ install (
94
+ CODE "file(INSTALL DESTINATION \" ${CMAKE_INSTALL_PREFIX} /${CMAKE_INSTALL_BINDIR} \" TYPE SHARED_LIBRARY FILES \" $<TARGET_FILE:LSL::lsl>\" )"
95
+ COMPONENT ${PROJECT_NAME}
96
+ )#install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different \"$<TARGET_FILE:LSL::lsl>\" \"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}\")")
97
+ endif ()
0 commit comments