Skip to content

Commit

Permalink
Fixed compilation errors
Browse files Browse the repository at this point in the history
- Moved include of GNUInstallDirs module in cmake-routine
- Removed old ci-leftover in Makefile
- cmake: Fixed name pattern for libusb module (Fixes #940)
- Wrong command option formatting for 7zip (Fixes #936)

Extraction of downloaded libusb archive on Windows failed since commit 
a8c1f41.
  • Loading branch information
Nightwalker-87 committed Apr 21, 2020
1 parent 05cf375 commit 9b19f92
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
6 changes: 2 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@ set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_SOURCE_DIR}/cmake/modules")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

# Define GNU standard installation directories
include(GNUInstallDirs)


###
# General project settings
###

project(stlink C)
set(PROJECT_DESCRIPTION "Open source version of the STMicroelectronics ST-LINK Tools")
include(GNUInstallDirs) # Define GNU standard installation directories

set(STLINK_UDEV_RULES_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/udev/rules.d" CACHE PATH "udev rules directory")
set(STLINK_MODPROBED_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/modprobe.d" CACHE PATH "modprobe.d directory")
Expand Down Expand Up @@ -67,7 +65,7 @@ endif ()
# Dependencies
###

find_package(_libusb REQUIRED)
find_package(libusb REQUIRED)

if (NOT WIN32 AND NOT CMAKE_CROSSCOMPILING)
find_package(PkgConfig)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ MAKEFLAGS += -s
CMAKEFLAGS +=

all: release
ci: debug release binary test
ci: debug release test

help:
@echo " debug: Run a debug build"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Find_7zip.cmake
# Find7zip.cmake
# Detect 7zip file archiver on Windows systems to extract (zip-)archives

find_program(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Find_libusb.cmake
# Findlibusb.cmake
# Once done this will define
#
# LIBUSB_FOUND libusb present on system
Expand All @@ -19,7 +19,7 @@ if (APPLE) # macOS
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
HINTS /usr /usr/local /opt
)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR)
mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY)
if (NOT LIBUSB_FOUND)
message(FATAL_ERROR "No libusb library found on your system! Install libusb-1.0 from Homebrew or MacPorts")
Expand All @@ -35,7 +35,7 @@ elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # FreeBSD; libusb is integrated
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
HINTS /usr /usr/local /opt
)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR)
mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY)
if (NOT LIBUSB_FOUND)
message(FATAL_ERROR "Expected libusb library not found on your system! Verify your system integrity.")
Expand Down Expand Up @@ -73,7 +73,7 @@ elseif (WIN32) # Windows

if (NOT LIBUSB_FOUND OR EXISTS "/etc/debian_version")
# Preparations for installing libusb library
find_package(_7zip REQUIRED)
find_package(7zip REQUIRED)
set(LIBUSB_WIN_VERSION 1.0.23) # set libusb version
set(LIBUSB_WIN_ARCHIVE libusb-${LIBUSB_WIN_VERSION}.7z)
set(LIBUSB_WIN_ARCHIVE_PATH ${CMAKE_BINARY_DIR}/${LIBUSB_WIN_ARCHIVE})
Expand All @@ -100,8 +100,8 @@ elseif (WIN32) # Windows
)
else ()
execute_process(
COMMAND ${ZIP_EXECUTABLE} x -y ${LIBUSB_WIN_ARCHIVE_PATH} -o ${LIBUSB_WIN_OUTPUT_FOLDER}
)
COMMAND ${ZIP_EXECUTABLE} x -y ${LIBUSB_WIN_ARCHIVE_PATH} -o${LIBUSB_WIN_OUTPUT_FOLDER}
) # <-- Note the absence of a space character following the -o option!
endif ()

# Find path to libusb library
Expand Down Expand Up @@ -131,7 +131,7 @@ elseif (WIN32) # Windows
endif ()
message(STATUS "Missing libusb library has been installed")
endif ()
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR)
mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY)

else () # all other OS (unix-based)
Expand All @@ -145,7 +145,7 @@ else () # all other OS (unix-based)
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
HINTS /usr /usr/local /opt
)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR)
mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY)

if (NOT LIBUSB_FOUND)
Expand Down

0 comments on commit 9b19f92

Please sign in to comment.