diff --git a/cmake/FixBundle.cmake.in b/cmake/FixBundle.cmake.in new file mode 100644 index 0000000..6e8f843 --- /dev/null +++ b/cmake/FixBundle.cmake.in @@ -0,0 +1,11 @@ +INCLUDE(BundleUtilities) + +# set bundle to the full path of the executable already existing in the install tree +SET(bundle "${CMAKE_INSTALL_PREFIX}/bin/nfc-list@CMAKE_EXECUTABLE_SUFFIX@") + +# set other_libs to a list of additional libs that cannot be reached by dependency analysis +SET(other_libs "") + +SET(dirs "@LIBUSB_LIBRARY_DIR@") + +fixup_bundle("${bundle}" "${other_libs}" "${dirs}") diff --git a/cmake/modules/FindLIBUSB.cmake b/cmake/modules/FindLIBUSB.cmake index ca26ea5..9766a10 100644 --- a/cmake/modules/FindLIBUSB.cmake +++ b/cmake/modules/FindLIBUSB.cmake @@ -28,7 +28,7 @@ IF(NOT LIBUSB_FOUND) IF(WIN32) FIND_PATH(LIBUSB_INCLUDE_DIRS usb.h "$ENV{ProgramFiles}/LibUSB-Win32/include" NO_SYSTEM_ENVIRONMENT_PATH) FIND_LIBRARY(LIBUSB_LIBRARIES NAMES libusb PATHS "$ENV{ProgramFiles}/LibUSB-Win32/lib/gcc") - SET(LIBUSB_DLL "$ENV{ProgramFiles}/LibUSB-Win32/bin/x86/libusb0_x86.dll") + SET(LIBUSB_LIBRARY_DIR "$ENV{ProgramFiles}/LibUSB-Win32/bin/x86/") ELSE(WIN32) # If not under Windows we use PkgConfig FIND_PACKAGE (PkgConfig) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index d8ce22a..0a63d6a 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -21,6 +21,13 @@ FOREACH(source ${EXAMPLES-SOURCES}) INSTALL(TARGETS ${source} RUNTIME DESTINATION bin COMPONENT examples) ENDFOREACH(source) +#install required libraries +IF(WIN32) + INCLUDE(InstallRequiredSystemLibraries) + CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/FixBundle.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FixBundle.cmake @ONLY) + INSTALL(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/FixBundle.cmake) +ENDIF(WIN32) + IF(NOT WIN32) # Manuals for the examples FILE(GLOB manuals "${CMAKE_CURRENT_SOURCE_DIR}/*.1") diff --git a/libnfc/CMakeLists.txt b/libnfc/CMakeLists.txt index 11e668b..090130d 100644 --- a/libnfc/CMakeLists.txt +++ b/libnfc/CMakeLists.txt @@ -34,8 +34,6 @@ IF(WIN32) # At compile time we need the .LIB file, we place it in the lib directory INSTALL(TARGETS nfc ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT headers) - - INSTALL(FILES ${LIBUSB_DLL} DESTINATION bin COMPONENT examples RENAME "libusb0.dll") ELSE(WIN32) INSTALL(TARGETS nfc LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) ENDIF(WIN32)