Skip to content

Commit 046c9d2

Browse files
author
Stuart Alldritt
authored
Fix dependency binplace on Windows and Linux (opencv#15)
* Fixing Windows build issue * Fix windows build and nodelet lib search
1 parent 77f5197 commit 046c9d2

File tree

3 files changed

+31
-23
lines changed

3 files changed

+31
-23
lines changed

CMakeLists.txt

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
166166
# Try to find K4A installed to Program Files
167167
find_package(azure-kinect-sensor-sdk 1.1.0 EXACT QUIET PATHS "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
168168

169-
if (${k4a_FOUND})
169+
if (${azure-kinect-sensor-sdk_FOUND})
170170
message("K4A SDK found in Program Files!")
171171

172172
list(APPEND K4A_LIBS ${azure-kinect-sensor-sdk_LIBRARIES})
@@ -211,24 +211,22 @@ if (${K4A_INSTALL_NEEDED})
211211
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${K4A_DLL_FILES})
212212

213213
# We need to copy the DLLs into the CATKIN_PACKAGE_LIB_DESTINATION so
214-
# the node executable can find them on launch
215-
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
216-
set(DLL_COPY_DIRECTORY "${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_BIN_DESTINATION}")
217-
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
218-
set(DLL_COPY_DIRECTORY "${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_LIB_DESTINATION}")
219-
endif()
214+
# the node executable can find them on launch, and CATKIN_PACKAGE_BIN_DESTINATION
215+
# so the nodelet can find them on launch
216+
set(DLL_COPY_DIRECTORY "${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_BIN_DESTINATION};${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_LIB_DESTINATION}")
220217

221-
file(MAKE_DIRECTORY "${DLL_COPY_DIRECTORY}")
218+
foreach(DIRECTORY ${DLL_COPY_DIRECTORY})
219+
file(MAKE_DIRECTORY "${DIRECTORY}")
220+
endforeach(DIRECTORY)
222221

223222
foreach(DLL ${K4A_DLL_FILES})
224-
file(COPY "${DLL}" DESTINATION "${DLL_COPY_DIRECTORY}")
225-
226-
get_filename_component(DLL_NAME ${DLL} NAME)
227-
228-
message(STATUS "Copied dll from ${DLL_NAME} to ${DLL_COPY_DIRECTORY}")
229-
230-
# Tell cmake that we need to clean up these DLLs on a "make clean"
231-
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${DLL_COPY_DIRECTORY}/${DLL_NAME}")
223+
foreach(DIRECTORY ${DLL_COPY_DIRECTORY})
224+
file(COPY "${DLL}" DESTINATION "${DIRECTORY}")
225+
get_filename_component(DLL_NAME ${DLL} NAME)
226+
message(STATUS "Copied dll from ${DLL_NAME} to ${DIRECTORY}")
227+
# Tell cmake that we need to clean up these DLLs on a "make clean"
228+
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${DIRECTORY}/${DLL_NAME}")
229+
endforeach(DIRECTORY)
232230
endforeach(DLL)
233231

234232
endif()

cmake/azure-kinect-sensor-sdk-config-version.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ find_file(versionfile "version.txt"
77
NO_DEFAULT_PATH)
88

99
if(NOT versionfile)
10-
message(FATAL_ERROR "Azure Kinect SDK is not installed properly. It must be installed to the standard install location.")
10+
message(STATUS "Azure Kinect SDK is not installed to Program Files.")
11+
return()
1112
endif()
1213

1314
set(versionfilecontents "0.0.0")

cmake/azure-kinect-sensor-sdk-install.cmake

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,20 @@
22
# Licensed under the MIT License.
33

44
message("-- Custom K4A install -- ")
5-
file(MAKE_DIRECTORY "${DLL_COPY_DIRECTORY}")
6-
message("Installing to: ${DLL_COPY_DIRECTORY}")
5+
# Tell cmake that we need to reconfigure if any of the DLL files change
6+
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${K4A_DLL_FILES})
77

8-
foreach(DLL ${K4A_DLL_FILES})
9-
message("Copying DLL from ${DLL} to ${DLL_COPY_DIRECTORY}")
10-
file(COPY "${DLL}" DESTINATION "${DLL_COPY_DIRECTORY}")
11-
endforeach(DLL)
8+
foreach(DIRECTORY ${DLL_COPY_DIRECTORY})
9+
file(MAKE_DIRECTORY "${DIRECTORY}")
10+
endforeach(DIRECTORY)
11+
12+
foreach(DLL ${K4A_DLL_FILES})
13+
foreach(DIRECTORY ${DLL_COPY_DIRECTORY})
14+
file(COPY "${DLL}" DESTINATION "${DIRECTORY}")
15+
get_filename_component(DLL_NAME ${DLL} NAME)
16+
message(STATUS "Copied dll from ${DLL_NAME} to ${DIRECTORY}")
17+
# Tell cmake that we need to clean up these DLLs on a "make clean"
18+
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${DIRECTORY}/${DLL_NAME}")
19+
endforeach(DIRECTORY)
20+
endforeach(DLL)
1221
message("-- Custom K4A install finished -- ")

0 commit comments

Comments
 (0)