Skip to content

Commit

Permalink
Post release patch for v1.8.0
Browse files Browse the repository at this point in the history
- Fixed terminal screen output (Closes #1363)
- Fixed compatibility with gcc-14 (Closes #1365)
- Updated contact info in CODE_OF_CONDUCT
- Updated man files & related install path
- Updated libusb to v1.0.27 for Windows builds
- Updated cmake_policy to CM0153 NEW
  • Loading branch information
Nightwalker-87 committed Feb 16, 2024
1 parent 65f062f commit 6a6718b
Show file tree
Hide file tree
Showing 18 changed files with 93 additions and 104 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
build
build-mingw-32
build-mingw-64
3rdparty

.project
.cmake/
Expand Down
61 changes: 24 additions & 37 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
###

cmake_minimum_required(VERSION 3.10.2)
cmake_policy(SET CMP0042 NEW)
cmake_policy(SET CMP0153 NEW)
set(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)
Expand Down Expand Up @@ -254,35 +254,22 @@ add_library(${STLINK_LIB_SHARED} SHARED ${STLINK_HEADERS} ${STLINK_SOURCE})

set(STLINK_SHARED_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
message(STATUS "STLINK_LIB_SHARED: ${STLINK_LIB_SHARED}")
message(STATUS "PROJECT_VERSION_MAJOR: ${PROJECT_VERSION_MAJOR}")
message(STATUS "VERSION: ${STLINK_SHARED_VERSION}")

set_target_properties(${STLINK_LIB_SHARED} PROPERTIES
SOVERSION ${PROJECT_VERSION_MAJOR}
VERSION ${STLINK_SHARED_VERSION}
OUTPUT_NAME ${PROJECT_NAME}
)
SOVERSION ${PROJECT_VERSION_MAJOR}
VERSION ${STLINK_SHARED_VERSION}
OUTPUT_NAME ${PROJECT_NAME}
)

# Link shared library
if (WIN32) # ... with Windows libraries
if (WIN32)
target_link_libraries(${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY} ${SSP_LIB} wsock32 ws2_32)
else ()
target_link_libraries(${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY} ${SSP_LIB})
endif()

install(TARGETS ${STLINK_LIB_SHARED}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# Copy libusb DLL-library to binary output folder
if (WIN32)
file(COPY ${LIBUSB_WIN_OUTPUT_FOLDER}/MinGW64/dll/libusb-1.0.dll
DESTINATION ${CMAKE_INSTALL_BINDIR})
file(COPY ${LIBUSB_WIN_OUTPUT_FOLDER}/MinGW64/dll/libusb-1.0.dll
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR})
endif()
install(TARGETS ${STLINK_LIB_SHARED} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})


###
Expand All @@ -300,17 +287,16 @@ add_library(${STLINK_LIB_STATIC} STATIC ${STLINK_HEADERS} ${STLINK_SOURCE})

set(STLINK_STATIC_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
message(STATUS "STLINK_LIB_STATIC: ${STLINK_LIB_STATIC}")
message(STATUS "PROJECT_VERSION_MAJOR: ${PROJECT_VERSION_MAJOR}")
message(STATUS "VERSION: ${STLINK_STATIC_VERSION}")

set_target_properties(${STLINK_LIB_STATIC} PROPERTIES
SOVERSION ${PROJECT_VERSION_MAJOR}
VERSION ${STLINK_STATIC_VERSION}
OUTPUT_NAME ${STLINK_LIB_STATIC_OUTPUT_NAME}
)
SOVERSION ${PROJECT_VERSION_MAJOR}
VERSION ${STLINK_STATIC_VERSION}
OUTPUT_NAME ${STLINK_LIB_STATIC_OUTPUT_NAME}
)

# Link static library
if (WIN32) # ... with Windows libraries
if (WIN32)
target_link_libraries(${STLINK_LIB_STATIC} ${LIBUSB_LIBRARY} ${SSP_LIB} wsock32 ws2_32)
else ()
target_link_libraries(${STLINK_LIB_STATIC} ${LIBUSB_LIBRARY} ${SSP_LIB})
Expand Down Expand Up @@ -341,15 +327,15 @@ add_executable(st-util ${ST-UTIL_SOURCES})
add_executable(st-trace ${ST-TRACE_SOURCES})

if (WIN32)
target_link_libraries(st-flash ${STLINK_LIB_STATIC} ${SSP_LIB})
target_link_libraries(st-info ${STLINK_LIB_STATIC} ${SSP_LIB})
target_link_libraries(st-util ${STLINK_LIB_STATIC} ${SSP_LIB})
target_link_libraries(st-trace ${STLINK_LIB_STATIC} ${SSP_LIB})
target_link_libraries(st-flash ${STLINK_LIB_STATIC})
target_link_libraries(st-info ${STLINK_LIB_STATIC})
target_link_libraries(st-util ${STLINK_LIB_STATIC})
target_link_libraries(st-trace ${STLINK_LIB_STATIC})
else ()
target_link_libraries(st-flash ${STLINK_LIB_SHARED} ${SSP_LIB})
target_link_libraries(st-info ${STLINK_LIB_SHARED} ${SSP_LIB})
target_link_libraries(st-util ${STLINK_LIB_SHARED} ${SSP_LIB})
target_link_libraries(st-trace ${STLINK_LIB_SHARED} ${SSP_LIB})
target_link_libraries(st-flash ${STLINK_LIB_SHARED})
target_link_libraries(st-info ${STLINK_LIB_SHARED})
target_link_libraries(st-util ${STLINK_LIB_SHARED})
target_link_libraries(st-trace ${STLINK_LIB_SHARED})
endif()

install(TARGETS st-flash DESTINATION ${CMAKE_INSTALL_BINDIR})
Expand Down Expand Up @@ -380,10 +366,10 @@ endif()

# MCU configuration files
if (WIN32)
set(CMAKE_CHIPS_DIR ${CMAKE_INSTALL_PREFIX}/config/chips)
set(CMAKE_CHIPS_DIR ${CMAKE_INSTALL_PREFIX}/config/chips)
else ()
set(CMAKE_CHIPS_DIR ${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/chips)
endif ()
set(CMAKE_CHIPS_DIR ${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/config/chips)
endif()
add_definitions( -DSTLINK_CHIPS_DIR="${CMAKE_CHIPS_DIR}" )
file(GLOB CHIP_FILES ${CMAKE_SOURCE_DIR}/config/chips/*.chip)
install(FILES ${CHIP_FILES} DESTINATION ${CMAKE_CHIPS_DIR})
Expand All @@ -396,6 +382,7 @@ add_subdirectory(src/stlink-gui) # contains subordinate CMakeLists to build GUI
add_subdirectory(tests) # contains subordinate CMakeLists to build test executables
add_subdirectory(cmake/packaging) # contains subordinate CMakeLists to build packages


###
# Uninstall target
###
Expand Down
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at texane@gmail.com. All
reported by contacting the project team [here](https://github.com/stlink-org/stlink/discussions). All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Expand Down
58 changes: 33 additions & 25 deletions cmake/modules/Findlibusb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,49 @@

include(FindPackageHandleStandardArgs)

if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # FreeBSD; libusb is integrated into the system
if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # FreeBSD; libusb is integrated into the system
# libusb header file
FIND_PATH(
LIBUSB_INCLUDE_DIR NAMES libusb.h
HINTS /usr/include
)

# libusb library
set(LIBUSB_NAME usb)
find_library(
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
HINTS /usr /usr/local /opt
)

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.")
endif()

elseif (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") # OpenBSD; libusb-1.0 is available from ports
elseif (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") # OpenBSD; libusb is available from ports
# libusb header file
FIND_PATH(
LIBUSB_INCLUDE_DIR NAMES libusb.h
HINTS /usr/local/include
PATH_SUFFIXES libusb-1.0
)

# libusb library
set(LIBUSB_NAME usb-1.0)
find_library(
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
HINTS /usr/local
)

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-1.0 library found on your system! Install libusb-1.0 from ports or packages.")
endif()

elseif (WIN32 OR (EXISTS "/etc/debian_version" AND MINGW)) # Windows or MinGW-toolchain on Debian
# MinGW/MSYS/MSVC: 64-bit or 32-bit?
elseif (WIN32 OR (MINGW AND EXISTS "/etc/debian_version")) # Windows OR cross-build with MinGW-toolchain on Debian
# MinGW: 64-bit or 32-bit?
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
message(STATUS "=== Building for Windows (x86-64) ===")
set(ARCH 64)
Expand All @@ -53,26 +61,20 @@ elseif (WIN32 OR (EXISTS "/etc/debian_version" AND MINGW)) # Windows or MinGW-to
set(ARCH 32)
endif()

if (WIN32 AND NOT EXISTS "/etc/debian_version") # Skip this for Debian...
if (NOT LIBUSB_FOUND)
# Preparations for installing libusb library
set(LIBUSB_WIN_VERSION 1.0.25) # set libusb version
set(LIBUSB_WIN_ARCHIVE libusb-${LIBUSB_WIN_VERSION}.7z)
if (WIN32 AND NOT EXISTS "/etc/debian_version") # ... on native Windows systems
set(LIBUSB_WIN_ARCHIVE_PATH ${CMAKE_BINARY_DIR}/${LIBUSB_WIN_ARCHIVE})
set(LIBUSB_WIN_OUTPUT_FOLDER ${CMAKE_BINARY_DIR}/3rdparty/libusb-${LIBUSB_WIN_VERSION})
elseif (EXISTS "/etc/debian_version" AND MINGW) # ... only for cross-building on Debian
set(LIBUSB_WIN_ARCHIVE_PATH ${CMAKE_SOURCE_DIR}/build-mingw-${ARCH}/${LIBUSB_WIN_ARCHIVE})
set(LIBUSB_WIN_OUTPUT_FOLDER ${CMAKE_SOURCE_DIR}/build-mingw-${ARCH}/3rdparty/libusb-${LIBUSB_WIN_VERSION})
endif()
set(LIBUSB_WIN_VERSION 1.0.27) # set libusb version
set(LIBUSB_WIN_ARCHIVE_PATH ${CMAKE_SOURCE_DIR}/3rdparty/libusb-${LIBUSB_WIN_VERSION}.7z)
set(LIBUSB_WIN_OUTPUT_FOLDER ${CMAKE_SOURCE_DIR}/3rdparty/libusb-${LIBUSB_WIN_VERSION})

# Get libusb package
if (EXISTS ${LIBUSB_WIN_ARCHIVE_PATH}) # ... should the package be already there (for whatever reason)
if (EXISTS ${LIBUSB_WIN_ARCHIVE_PATH}) # ... should the package be already there
message(STATUS "libusb archive already in build folder")
else () # ... download the package
message(STATUS "downloading libusb ${LIBUSB_WIN_VERSION}")
file(DOWNLOAD
https://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-${LIBUSB_WIN_VERSION}/libusb-${LIBUSB_WIN_VERSION}.7z/download
${LIBUSB_WIN_ARCHIVE_PATH} EXPECTED_MD5 aabe177bde869bfad34278335eaf8955
${LIBUSB_WIN_ARCHIVE_PATH} EXPECTED_MD5 c72153fc5a32f3b942427b0671897a1a
)
endif()

Expand All @@ -84,7 +86,7 @@ elseif (WIN32 OR (EXISTS "/etc/debian_version" AND MINGW)) # Windows or MinGW-to
WORKING_DIRECTORY ${LIBUSB_WIN_OUTPUT_FOLDER}
)

# Find path to libusb library
# libusb header file
FIND_PATH(
LIBUSB_INCLUDE_DIR NAMES libusb.h
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/include
Expand All @@ -94,15 +96,16 @@ elseif (WIN32 OR (EXISTS "/etc/debian_version" AND MINGW)) # Windows or MinGW-to
)

if (MINGW OR MSYS)
# libusb library (static)
set(LIBUSB_NAME usb-1.0)
find_library(
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MinGW${ARCH}/static
NO_DEFAULT_PATH
NO_CMAKE_FIND_ROOT_PATH
)

elseif (MSVC)
else (MSVC)
# libusb library
set(LIBUSB_NAME libusb-1.0.lib)
find_library(
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
Expand All @@ -111,23 +114,28 @@ elseif (WIN32 OR (EXISTS "/etc/debian_version" AND MINGW)) # Windows or MinGW-to
NO_CMAKE_FIND_ROOT_PATH
)
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_INCLUDE_DIR LIBUSB_LIBRARY)
mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY)
message(STATUS "Missing libusb library has been installed")

else () # all other OS (unix-based)
else () # all other OS (unix-based)
# libusb header file
FIND_PATH(
LIBUSB_INCLUDE_DIR NAMES libusb.h
HINTS /usr /usr/local /opt
HINTS /usr/include
PATH_SUFFIXES libusb-1.0
)

# libusb library
set(LIBUSB_NAME usb-1.0)
find_library(
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
HINTS /usr /usr/local /opt
HINTS /usr /usr/local
)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR)

FIND_PACKAGE_HANDLE_STANDARD_ARGS(libusb DEFAULT_MSG LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY)
mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY)

if (NOT LIBUSB_FOUND)
Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/c_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if (NOT CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
add_cflag_if_supported("-Wredundant-decls")
endif()

if (NOT (WIN32 OR (EXISTS "/etc/debian_version" AND MINGW)))
if (NOT (WIN32 OR (MINGW AND EXISTS "/etc/debian_version")))
add_cflag_if_supported("-fPIC")
endif()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ elseif (WIN32) # Wi
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-${TOOLCHAIN_PREFIX}")
set(CPACK_INSTALL_PREFIX "")

elseif (EXISTS "/etc/debian_version" AND NOT EXISTS WIN32) # Package-build is available on Debian/Ubuntu only
elseif (EXISTS "/etc/debian_version" AND (NOT EXISTS WIN32)) # Package-build on Debian/Ubuntu
message(STATUS "Debian-based Linux OS detected")

set(CPACK_GENERATOR "DEB;RPM") # RPM requires package `rpm`
Expand Down
2 changes: 1 addition & 1 deletion cmake/packaging/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ add_subdirectory(deb)
add_subdirectory(rpm)
add_subdirectory(windows)

include(cpack_config.cmake)
include(${CMAKE_MODULE_PATH}/cpack_config.cmake)
6 changes: 3 additions & 3 deletions cmake_uninstall.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ string(REGEX REPLACE "\n" ";" files "${files}")
foreach (file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if (IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program("@CMAKE_COMMAND@"
ARGS "-E remove \"$ENV{DESTDIR}${file}\""
execute_process(
COMMAND "@CMAKE_COMMAND@" -E remove \"$ENV{DESTDIR}${file}\"
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
RESULT_VARIABLE rm_retval
)
if (NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
Expand Down
7 changes: 1 addition & 6 deletions doc/compiling.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,7 @@ Options:
Directory `<project_root>\build\Release` contains final executables.
(`st-util.exe` is located in `<project_root>\build\src\gdbserver\Release`).

**NOTE 1:**

Executables link against libusb.dll library. It has to be placed in the same directory as binaries or in PATH.
It can be copied from: `<project_root>\build\3rdparty\libusb-{version}\MS{arch}\dll\libusb-1.0.dll`.

**NOTE 2:**
**NOTE:**

[ST-LINK drivers](https://www.st.com/en/development-tools/stsw-link009.html) are required for `stlink` to work.

Expand Down
14 changes: 7 additions & 7 deletions doc/man/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Generate manpages
###

set(MANPAGES st-util st-flash st-info)
set(MANPAGES st-info st-flash st-util)

# Only generate manpages with pandoc in Debug builds
if (${STLINK_GENERATE_MANPAGES})
Expand All @@ -12,7 +12,7 @@ if (${STLINK_GENERATE_MANPAGES})
${manpage}.1
SOURCES ${manpage}.md
PANDOC_DIRECTIVES -s -t man
PRODUCT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
PRODUCT_DIRECTORY ${CMAKE_INSTALL_FULL_DATADIR}
)
endforeach ()
else ()
Expand All @@ -21,16 +21,16 @@ endif()

# Install from output folder or this folder
foreach (manpage ${MANPAGES})
if (EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${manpage}.1)
set(f "${CMAKE_CURRENT_BINARY_DIR}/${manpage}.1")
elseif (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${manpage}.1")
if (EXISTS ${CMAKE_INSTALL_FULL_DATADIR}/${manpage}.1)
set(f "${CMAKE_INSTALL_FULL_DATADIR}/${manpage}.1")
elseif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${manpage}.1)
set(f "${CMAKE_CURRENT_SOURCE_DIR}/${manpage}.1")
else()
else ()
message(AUTHOR_WARNING "Manpage ${manpage} not generated")
endif()

if (f AND NOT WIN32)
install(FILES ${f} DESTINATION ${CMAKE_INSTALL_DATADIR}/man/man1)
install(FILES ${f} DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/man/man1)
unset(f)
endif()
endforeach ()
4 changes: 2 additions & 2 deletions doc/man/st-flash.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
% st-flash(1) Open Source STMicroelectronics Stlink Tools | stlink
% st-flash(1) Open source version of the STMicroelectronics STLINK Tools | stlink
%
% Feb 2018
% Feb 2023

# NAME

Expand Down
4 changes: 2 additions & 2 deletions doc/man/st-info.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
% st-flash(1) Open Source STMicroelectronics Stlink Tools | stlink
% st-flash(1) Open source version of the STMicroelectronics STLINK Tools | stlink
%
% Oct 2020
% Feb 2023

# NAME
st-info - Provides information about connected STLink and STM32 devices
Expand Down
Loading

0 comments on commit 6a6718b

Please sign in to comment.