kopia lustrzana https://github.com/stlink-org/stlink
Updated build-settings
- Added new build configs for Travis - Refactoring for cmake modules - Updated Travis build script - Makefile: binary build for Windowspull/935/head
rodzic
cadfa94162
commit
6eb9103a23
40
.travis.sh
40
.travis.sh
|
@ -5,15 +5,43 @@ ls -1 /usr/bin/clang*
|
|||
ls -1 /usr/bin/scan-build*
|
||||
echo "----"
|
||||
|
||||
echo "WORK DIR:$DIR"
|
||||
DIR=$PWD
|
||||
|
||||
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
|
||||
sudo apt-get update -qq || true
|
||||
sudo apt-get install -qq -y --no-install-recommends libgtk-3-dev
|
||||
|
||||
echo "--> Building Debug..."
|
||||
mkdir -p build/Debug && cd build/Debug
|
||||
echo "-DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/_install"
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/_install ../../
|
||||
make && make package && cd -
|
||||
|
||||
echo "--> Building Release..."
|
||||
mkdir -p build/Release && cd build/Release
|
||||
echo "-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install"
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install ../../
|
||||
make && make package && cd -
|
||||
|
||||
echo "--> Building Binary..."
|
||||
mkdir -p build/Binary && cd build/Binary
|
||||
cho "-DCMAKE_BUILD_TYPE=Binary -DCMAKE_INSTALL_PREFIX=$PWD/_install"
|
||||
cmake -DCMAKE_BUILD_TYPE=Binary -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$PWD/_install ../../
|
||||
make && make package && cd -
|
||||
|
||||
else #("$TRAVIS_OS_NAME" == "osx")
|
||||
brew install libusb
|
||||
|
||||
echo "--> Building Debug..."
|
||||
mkdir -p build/Debug && cd build/Debug
|
||||
echo "-DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/_install"
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/_install ../../
|
||||
make && make package && cd -
|
||||
|
||||
echo "--> Building Release..."
|
||||
mkdir -p build/Release && cd build/Release
|
||||
echo "-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install"
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install ../../
|
||||
make && make package && cd -
|
||||
fi
|
||||
|
||||
echo "=== Building Debug"
|
||||
mkdir -p build/Debug && cd build/Debug && cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/_install ../../ && make && make package && cd -
|
||||
|
||||
echo "=== Building Release"
|
||||
mkdir -p build/Release && cd build/Release && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install ../../ && make && make package && cd -
|
||||
|
|
|
@ -38,6 +38,14 @@ matrix:
|
|||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-bionic-6.0']
|
||||
packages: ['clang-6.0', 'libusb-1.0.0-dev']
|
||||
- os: linux
|
||||
arch: x64
|
||||
compiler: clang-6.0
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-bionic-6.0']
|
||||
packages: ['clang-6.0', 'libusb-1.0.0-dev']
|
||||
env: CFLAGS=-m32 LDFLAGS=-m32
|
||||
|
||||
### 32-bit builds ###
|
||||
- os: linux
|
||||
|
|
14
Makefile
14
Makefile
|
@ -4,11 +4,12 @@
|
|||
MAKEFLAGS += -s
|
||||
|
||||
all: release
|
||||
ci: debug release test
|
||||
ci: debug release binary test
|
||||
|
||||
help:
|
||||
@echo " release: Run a release build"
|
||||
@echo " debug: Run a debug build"
|
||||
@echo " release: Run a release build"
|
||||
@echo " binary: Build Windows-Binary"
|
||||
@echo " lint: Lint check all source-code"
|
||||
@echo " test: Build and run tests"
|
||||
@echo " clean: Clean all build output"
|
||||
|
@ -17,6 +18,7 @@ help:
|
|||
rebuild_cache: build/Debug build/Release
|
||||
@$(MAKE) -C build/Debug rebuild_cache
|
||||
@$(MAKE) -C build/Release rebuild_cache
|
||||
@$(MAKE) -C build/Binary rebuild_cache
|
||||
|
||||
debug: build/Debug
|
||||
@echo "[DEBUG]"
|
||||
|
@ -26,6 +28,10 @@ release: build/Release
|
|||
@echo "[RELEASE]"
|
||||
@$(MAKE) -C build/Release
|
||||
|
||||
binary: build/Binary
|
||||
@echo "[BINARY]"
|
||||
@$(MAKE) -C build/Binary
|
||||
|
||||
package: build/Release
|
||||
@echo "[PACKAGE] Release"
|
||||
@$(MAKE) -C build/Release package
|
||||
|
@ -41,6 +47,10 @@ build/Release:
|
|||
@mkdir -p $@
|
||||
@cd $@ && cmake -Wno-dev -DCMAKE_BUILD_TYPE=Release $(CMAKEFLAGS) ../../
|
||||
|
||||
build/Binary:
|
||||
@mkdir -p $@
|
||||
@cd $@ && cmake -Wno-dev -DCMAKE_BUILD_TYPE=Binary $(CMAKEFLAGS) ../../
|
||||
|
||||
clean:
|
||||
@echo "[CLEAN]"
|
||||
@rm -Rf build
|
||||
|
|
|
@ -1,102 +1,90 @@
|
|||
# FindLibUSB.cmake
|
||||
# Once done this will define
|
||||
#
|
||||
# LIBUSB_FOUND - System has libusb
|
||||
# LIBUSB_INCLUDE_DIR - The libusb include directory
|
||||
# LIBUSB_LIBRARY - The libraries needed to use libusb
|
||||
# LIBUSB_DEFINITIONS - Compiler switches required for using libusb
|
||||
# LIBUSB_FOUND libusb present on system
|
||||
# LIBUSB_INCLUDE_DIR the libusb include directory
|
||||
# LIBUSB_LIBRARY the libraries needed to use libusb
|
||||
# LIBUSB_DEFINITIONS compiler switches required for using libusb
|
||||
|
||||
if (NOT (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")) # all OS apart from FreeBSD
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
if (APPLE) # macOS
|
||||
FIND_PATH(
|
||||
LIBUSB_INCLUDE_DIR NAMES libusb.h
|
||||
HINTS /usr /usr/local /opt
|
||||
PATH_SUFFIXES libusb-1.0
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (APPLE) # macOS
|
||||
set(LIBUSB_NAME libusb-1.0.a)
|
||||
find_library(
|
||||
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
HINTS /usr /usr/local /opt
|
||||
)
|
||||
|
||||
elseif (MINGW OR MSYS) # Windows with MinGW or MSYS
|
||||
set(LIBUSB_NAME usb-1.0)
|
||||
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8) # 64-bit
|
||||
find_library(
|
||||
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MinGW64/static
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
else () # 32-bit
|
||||
find_library(
|
||||
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MinGW32/static
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
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")
|
||||
endif ()
|
||||
|
||||
elseif (MSVC) # Windows with MSVC
|
||||
set(LIBUSB_NAME libusb-1.0.lib)
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8) # 64-bit
|
||||
find_library(
|
||||
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MS64/dll
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
else () # 32-bit
|
||||
find_library(
|
||||
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MS32/dll
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
endif ()
|
||||
|
||||
elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # FreeBSD
|
||||
# libusb is integrated into FreeBSD
|
||||
elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # FreeBSD; libusb is integrated into the system
|
||||
FIND_PATH(
|
||||
LIBUSB_INCLUDE_DIR NAMES libusb.h
|
||||
HINTS /usr/include
|
||||
)
|
||||
|
||||
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 ()
|
||||
|
||||
else () # all other OS
|
||||
set(LIBUSB_NAME usb-1.0)
|
||||
find_library(
|
||||
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
HINTS /usr /usr/local /opt
|
||||
)
|
||||
endif()
|
||||
elseif (WIN32 OR (EXISTS "/etc/debian_version" AND ${CMAKE_BUILD_TYPE} MATCHES "Binary"))
|
||||
# Windows & Windows-Binary-Build on Debian/Ubuntu
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR)
|
||||
mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY)
|
||||
# for MinGW/MSYS/MSVC: 64-bit or 32-bit?
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(ARCH 64)
|
||||
else ()
|
||||
set(ARCH 32)
|
||||
endif ()
|
||||
|
||||
if (NOT LIBUSB_FOUND)
|
||||
if (WIN32 OR MINGW OR MSYS OR MSVC) # Windows
|
||||
if (NOT EXISTS "/etc/debian_version")
|
||||
FIND_PATH(
|
||||
LIBUSB_INCLUDE_DIR NAMES libusb.h
|
||||
HINTS /usr /usr/local /opt
|
||||
PATH_SUFFIXES libusb-1.0
|
||||
)
|
||||
|
||||
if (MINGW OR MSYS)
|
||||
set(LIBUSB_NAME usb-1.0)
|
||||
find_library(
|
||||
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MinGW${ARCH}/static
|
||||
)
|
||||
else (MSVC)
|
||||
set(LIBUSB_NAME libusb-1.0.lib)
|
||||
find_library(
|
||||
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MS${ARCH}/dll
|
||||
)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (NOT LIBUSB_FOUND OR EXISTS "/etc/debian_version")
|
||||
# Preparations for installing libusb library
|
||||
find_package(7Zip REQUIRED)
|
||||
set(LIBUSB_WIN_VERSION 1.0.23) # set libusb version to 1.0.23 (latest as of Apr 2020)
|
||||
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})
|
||||
set(LIBUSB_WIN_OUTPUT_FOLDER ${CMAKE_BINARY_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 (for whatever reason)
|
||||
message(STATUS "libusb archive already in build folder")
|
||||
else () # ... download the package (1.0.23 as of Apr 2020)
|
||||
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
|
||||
|
@ -127,11 +115,42 @@ if (NOT LIBUSB_FOUND)
|
|||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR)
|
||||
message(STATUS "installed libusb library")
|
||||
else () # all other OS
|
||||
message(FATAL_ERROR "libusb library not found on your system! Compilation terminated.")
|
||||
if (MINGW OR MSYS)
|
||||
find_library(
|
||||
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MinGW${ARCH}/static
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
|
||||
else (MSVC)
|
||||
find_library(
|
||||
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MS${ARCH}/dll
|
||||
NO_DEFAULT_PATH
|
||||
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)
|
||||
mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY)
|
||||
|
||||
else () # all other OS (unix-based)
|
||||
FIND_PATH(
|
||||
LIBUSB_INCLUDE_DIR NAMES libusb.h
|
||||
HINTS /usr /usr/local /opt
|
||||
PATH_SUFFIXES libusb-1.0
|
||||
)
|
||||
set(LIBUSB_NAME usb-1.0)
|
||||
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 "libusb library not found on your system! Install libusb 1.0.x from your package repository.")
|
||||
endif ()
|
||||
else (NOT LIBUSB_FOUND)
|
||||
message(STATUS "found libusb library")
|
||||
endif ()
|
||||
|
|
|
@ -5,9 +5,11 @@
|
|||
set(__detect_version 0)
|
||||
|
||||
find_package(Git)
|
||||
set(ERROR_FLAG "0")
|
||||
|
||||
if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
|
||||
# Working off a git repo, using git versioning
|
||||
|
||||
# Check if HEAD is pointing to a tag
|
||||
execute_process (
|
||||
COMMAND "${GIT_EXECUTABLE}" describe --always --tag
|
||||
|
@ -17,22 +19,22 @@ if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
|
|||
ERROR_VARIABLE GIT_DESCRIBE_ERROR
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
if (GIT_DESCRIBE_RESULT EQUAL 0)
|
||||
|
||||
# If the sources have been changed locally, add -dirty to the version.
|
||||
execute_process (
|
||||
COMMAND "${GIT_EXECUTABLE}" diff --quiet
|
||||
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
|
||||
RESULT_VARIABLE res
|
||||
)
|
||||
|
||||
if (res EQUAL 1)
|
||||
set (PROJECT_VERSION "${PROJECT_VERSION}-dirty")
|
||||
set(PROJECT_VERSION "${PROJECT_VERSION}-dirty")
|
||||
endif ()
|
||||
|
||||
# strip a leading v off of the version as proceeding code expectes just the version numbering.
|
||||
# Strip a leading v off of the version as proceeding code expects just the version numbering.
|
||||
string(REGEX REPLACE "^v" "" PROJECT_VERSION ${PROJECT_VERSION})
|
||||
|
||||
# Read version string
|
||||
string(REGEX REPLACE "^(0|[1-9][0-9]*)[.](0|[1-9][0-9]*)[.](0|[1-9][0-9]*)(-[.0-9A-Za-z-]+)?([+][.0-9A-Za-z-]+)?$"
|
||||
"\\1;\\2;\\3" PROJECT_VERSION_LIST ${PROJECT_VERSION})
|
||||
list(LENGTH PROJECT_VERSION_LIST len)
|
||||
|
@ -42,34 +44,46 @@ if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
|
|||
list(GET PROJECT_VERSION_LIST 2 PROJECT_VERSION_PATCH)
|
||||
set(__detect_version 1)
|
||||
set(__version_str "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
|
||||
if (EXISTS "${PROJECT_SOURCE_DIR}/.version")
|
||||
file(READ "${PROJECT_SOURCE_DIR}/.version" __version_file)
|
||||
if (NOT __version_str STREQUAL __version_file)
|
||||
message(STATUS "Rewrite ${PROJECT_SOURCE_DIR}/.version with ${__version_str}")
|
||||
endif ()
|
||||
else ()
|
||||
file(WRITE "${PROJECT_SOURCE_DIR}/.version" ${__version_str})
|
||||
endif ()
|
||||
else ()
|
||||
message(STATUS "Fail to extract version parts from \"${PROJECT_VERSION}\"")
|
||||
endif ()
|
||||
|
||||
else(GIT_DESCRIBE_RESULT EQUAL 0)
|
||||
message(WARNING "git describe failed.")
|
||||
message(WARNING "${GIT_DESCRIBE_ERROR}")
|
||||
# Compare git-Version with version read from .version file in source folder
|
||||
if (EXISTS "${PROJECT_SOURCE_DIR}/.version")
|
||||
|
||||
# Local .version file found, read version string...
|
||||
file(READ "${PROJECT_SOURCE_DIR}/.version" __version_file)
|
||||
|
||||
# ...the version does not match with git-version string
|
||||
if (NOT __version_str STREQUAL __version_file)
|
||||
message(STATUS "Rewrite ${PROJECT_SOURCE_DIR}/.version with ${__version_str}.")
|
||||
endif ()
|
||||
|
||||
else (EXISTS "${PROJECT_SOURCE_DIR}/.version")
|
||||
|
||||
# No local .version file found: Create a new one...
|
||||
file(WRITE "${PROJECT_SOURCE_DIR}/.version" ${__version_str})
|
||||
|
||||
endif ()
|
||||
|
||||
message(STATUS "stlink version: ${PROJECT_VERSION}")
|
||||
message(STATUS "Major ${PROJECT_VERSION_MAJOR} Minor ${PROJECT_VERSION_MINOR} Patch ${PROJECT_VERSION_PATCH}")
|
||||
|
||||
else (len EQUAL 3)
|
||||
message(STATUS "Failed to extract version parts from \"${PROJECT_VERSION}\"")
|
||||
set(ERROR_FLAG "1")
|
||||
endif (len EQUAL 3)
|
||||
|
||||
else (GIT_DESCRIBE_RESULT EQUAL 0)
|
||||
message(WARNING "git describe failed: ${GIT_DESCRIBE_ERROR}")
|
||||
set(ERROR_FLAG "1")
|
||||
endif(GIT_DESCRIBE_RESULT EQUAL 0)
|
||||
else ()
|
||||
message(STATUS "Git or repo not found.")
|
||||
endif ()
|
||||
|
||||
if (NOT __detect_version)
|
||||
message(STATUS "Try to detect version from \"${PROJECT_SOURCE_DIR}/.version\" file.")
|
||||
if (ERROR_FLAG EQUAL 1)
|
||||
message(STATUS "Git and/or repository not found.") # e.g. when building from source package
|
||||
message(STATUS "Try to detect version from \"${PROJECT_SOURCE_DIR}/.version\" file instead...")
|
||||
if (EXISTS ${PROJECT_SOURCE_DIR}/.version)
|
||||
# If git is not available (e.g. when building from source package)
|
||||
# we can extract the package version from .version file.
|
||||
file(STRINGS .version PROJECT_VERSION)
|
||||
|
||||
# TODO create function to extract semver from file or string and check if it is correct instead of copy-pasting
|
||||
# Read version string
|
||||
string(REGEX REPLACE "^(0|[1-9][0-9]*)[.](0|[1-9][0-9]*)[.](0|[1-9][0-9]*)(-[.0-9A-Za-z-]+)?([+][.0-9A-Za-z-]+)?$"
|
||||
"\\1;\\2;\\3" PROJECT_VERSION_LIST ${PROJECT_VERSION})
|
||||
list(LENGTH PROJECT_VERSION_LIST len)
|
||||
|
@ -81,11 +95,8 @@ if (NOT __detect_version)
|
|||
else ()
|
||||
message(STATUS "Fail to extract version parts from \"${PROJECT_VERSION}\"")
|
||||
endif ()
|
||||
else ()
|
||||
message(STATUS "File \"${PROJECT_SOURCE_DIR}/.version\" did not exists.")
|
||||
else (EXISTS ${PROJECT_SOURCE_DIR}/.version)
|
||||
message(STATUS "File \"${PROJECT_SOURCE_DIR}/.version\" does not exist.")
|
||||
message(FATAL_ERROR "Unable to determine project version")
|
||||
endif ()
|
||||
message(FATAL_ERROR "Unable to determine project version")
|
||||
endif ()
|
||||
|
||||
message(STATUS "stlink version: ${PROJECT_VERSION}")
|
||||
message(STATUS "Major ${PROJECT_VERSION_MAJOR} Minor ${PROJECT_VERSION_MINOR} Patch ${PROJECT_VERSION_PATCH}")
|
||||
|
|
Ładowanie…
Reference in New Issue