kopia lustrzana https://github.com/stlink-org/stlink
Prepare for win64 static executable builds
rodzic
e05ad17253
commit
4868a62fbf
|
@ -66,12 +66,16 @@ include_directories(include)
|
|||
include_directories(${PROJECT_BINARY_DIR}/include)
|
||||
include_directories(src/mingw)
|
||||
|
||||
###
|
||||
# Shared library
|
||||
add_library(${PROJECT_NAME} SHARED
|
||||
###
|
||||
set(STLINK_LIB_SHARED ${PROJECT_NAME}-shared)
|
||||
|
||||
add_library(${STLINK_LIB_SHARED} SHARED
|
||||
${STLINK_HEADERS} # header files for ide projects generated by cmake
|
||||
${STLINK_SOURCE}
|
||||
)
|
||||
target_link_libraries(${PROJECT_NAME} ${LIBUSB_LIBRARY})
|
||||
target_link_libraries(${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY})
|
||||
|
||||
if (WIN32 OR MSYS OR MINGW)
|
||||
set(STLINK_SHARED_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})
|
||||
|
@ -79,25 +83,27 @@ else()
|
|||
set(STLINK_SHARED_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
|
||||
endif()
|
||||
|
||||
set_target_properties(${PROJECT_NAME}
|
||||
set_target_properties(${STLINK_LIB_SHARED}
|
||||
PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR}
|
||||
VERSION ${STLINK_SHARED_VERSION}
|
||||
)
|
||||
|
||||
# Link shared library with apple OS libraries
|
||||
if (APPLE)
|
||||
find_library(ObjC objc)
|
||||
find_library(CoreFoundation CoreFoundation)
|
||||
find_library(IOKit IOKit)
|
||||
target_link_libraries(${PROJECT_NAME} ${CoreFoundation} ${IOKit} ${ObjC})
|
||||
target_link_libraries(${STLINK_LIB_SHARED} ${CoreFoundation} ${IOKit} ${ObjC})
|
||||
endif ()
|
||||
|
||||
if(WIN32 OR MSYS OR MINGW)
|
||||
target_link_libraries(${PROJECT_NAME} ${LIBUSB_LIBRARY} wsock32 ws2_32)
|
||||
# Link
|
||||
if (WIN32 OR MSYS OR MINGW)
|
||||
target_link_libraries(${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY} wsock32 ws2_32)
|
||||
else()
|
||||
target_link_libraries(${PROJECT_NAME} ${LIBUSB_LIBRARY})
|
||||
target_link_libraries(${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY})
|
||||
endif()
|
||||
|
||||
install(TARGETS ${PROJECT_NAME}
|
||||
install(TARGETS ${STLINK_LIB_SHARED}
|
||||
DESTINATION lib/${CMAKE_LIBRARY_PATH}
|
||||
)
|
||||
|
||||
|
@ -110,7 +116,17 @@ add_library(${STLINK_LIB_STATIC} STATIC
|
|||
${STLINK_HEADERS} # header files for ide projects generated by cmake
|
||||
${STLINK_SOURCE}
|
||||
)
|
||||
|
||||
target_link_libraries(${STLINK_LIB_STATIC} ${LIBUSB_LIBRARY})
|
||||
|
||||
# Link shared library with apple OS libraries
|
||||
if (APPLE)
|
||||
find_library(ObjC objc)
|
||||
find_library(CoreFoundation CoreFoundation)
|
||||
find_library(IOKit IOKit)
|
||||
target_link_libraries(${STLINK_LIB_STATIC} ${CoreFoundation} ${IOKit} ${ObjC})
|
||||
endif ()
|
||||
|
||||
set_target_properties(${STLINK_LIB_STATIC} PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
|
||||
|
||||
install(TARGETS ${STLINK_LIB_STATIC}
|
||||
|
@ -121,10 +137,18 @@ install(TARGETS ${STLINK_LIB_STATIC}
|
|||
# Tools
|
||||
###
|
||||
add_executable(st-flash src/tools/flash.c src/tools/flash_opts.c)
|
||||
target_link_libraries(st-flash ${PROJECT_NAME})
|
||||
if (WIN32 OR APPLE)
|
||||
target_link_libraries(st-flash ${STLINK_LIB_STATIC})
|
||||
else()
|
||||
target_link_libraries(st-flash ${STLINK_LIB_SHARED})
|
||||
endif()
|
||||
|
||||
add_executable(st-info src/tools/info.c)
|
||||
target_link_libraries(st-info ${PROJECT_NAME})
|
||||
if (WIN32 OR APPLE)
|
||||
target_link_libraries(st-info ${STLINK_LIB_STATIC})
|
||||
else()
|
||||
target_link_libraries(st-info ${STLINK_LIB_SHARED})
|
||||
endif()
|
||||
|
||||
install(TARGETS st-flash st-info
|
||||
RUNTIME DESTINATION bin
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
set (CPACK_PACKAGE_NAME ${PROJECT_NAME})
|
||||
set (CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
|
||||
set (CPACK_SET_DESTDIR "ON")
|
||||
set (CPACK_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/cpack/staging")
|
||||
if (APPLE)
|
||||
set(CPACK_GENERATOR "ZIP")
|
||||
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/dist/osx")
|
||||
set (CPACK_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/cpack/staging")
|
||||
set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_BINARY_DIR}/dist/osx")
|
||||
elseif (WIN32)
|
||||
set(CPACK_GENERATOR "ZIP")
|
||||
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/dist/windows")
|
||||
set (CPACK_INSTALL_PREFIX "")
|
||||
set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_BINARY_DIR}/dist/windows")
|
||||
endif()
|
||||
endif()
|
|
@ -1,23 +0,0 @@
|
|||
Building with MinGW under Windows
|
||||
=================================
|
||||
|
||||
## Prequistes
|
||||
|
||||
* 7Zip
|
||||
* CMake 2.8 or higher
|
||||
* MinGW64 GCC toolchain (5.3.0)
|
||||
|
||||
## Installation
|
||||
|
||||
1. Install 7Zip from http://www.7-zip.org
|
||||
2. Install CMake from https://cmake.org/download
|
||||
3. Install MinGW64 from https://sourceforge.net/projects/mingw-w64 (mingw-w64-install.exe)
|
||||
4. Git clone or download stlink sourcefiles zip
|
||||
5. Create build folder in source
|
||||
|
||||
# Building
|
||||
|
||||
Check and execute `<source-dir>\scripts\mingw64-build.bat`
|
||||
|
||||
NOTE: when installing different toolchains make sure you edit the path in the `mingw64-build.bat`
|
||||
the build script uses currently `C:\Program Files\mingw-w64\x86_64-5.3.0-win32-sjlj-rt_v4-rev0\mingw64\bin`
|
|
@ -117,3 +117,25 @@ during installation you can use the following cmake options:
|
|||
$ cmake -DSTLINK_UDEV_RULES_DIR="/usr/lib/udev/rules.d" \
|
||||
-DSTLINK_MODPROBED_DIR="/usr/lib/modprobe.d" ..
|
||||
```
|
||||
|
||||
## Windows (MinGW64)
|
||||
|
||||
### Prequistes
|
||||
|
||||
* 7Zip
|
||||
* CMake 2.8 or higher
|
||||
* MinGW64 GCC toolchain (5.3.0)
|
||||
|
||||
### Installation
|
||||
|
||||
1. Install 7Zip from <http://www.7-zip.org>
|
||||
2. Install CMake from <https://cmake.org/download>
|
||||
3. Install MinGW64 from <https://sourceforge.net/projects/mingw-w64> (mingw-w64-install.exe)
|
||||
4. Git clone or download stlink sourcefiles zip
|
||||
|
||||
### Building
|
||||
|
||||
Check and execute (in the script folder) `<source-dir>\scripts\mingw64-build.bat`
|
||||
|
||||
NOTE: when installing different toolchains make sure you edit the path in the `mingw64-build.bat`
|
||||
the build script uses currently `C:\Program Files\mingw-w64\x86_64-5.3.0-win32-sjlj-rt_v4-rev0\mingw64\bin`
|
||||
|
|
|
@ -30,7 +30,7 @@ foreach(manpage ${MANPAGES})
|
|||
message(AUTHOR_WARNING "Manpage ${manpage} not generated")
|
||||
endif()
|
||||
|
||||
if (f)
|
||||
if (f AND NOT WIN32)
|
||||
install(FILES ${f} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1)
|
||||
unset(f)
|
||||
endif()
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
@echo off
|
||||
set PATH=C:\Program Files (x86)\CMake\bin;C:\Program Files\CMake\bin;C:\Program Files\mingw-w64\x86_64-5.3.0-win32-sjlj-rt_v4-rev0\mingw64\bin;%PATH%
|
||||
cmake -G "MinGW Makefiles" ..
|
||||
mingw32-make
|
||||
mingw32-make
|
||||
mingw32-make install DESTDIR=_install
|
||||
mingw32-make package
|
||||
|
|
|
@ -4,7 +4,12 @@ add_executable(st-util gdb-remote.c
|
|||
gdb-server.h
|
||||
semihosting.c
|
||||
semihosting.h)
|
||||
target_link_libraries(st-util ${PROJECT_NAME})
|
||||
if (WIN32 OR APPLE)
|
||||
target_link_libraries(st-util ${STLINK_LIB_STATIC})
|
||||
else()
|
||||
target_link_libraries(st-util ${STLINK_LIB_SHARED})
|
||||
endif()
|
||||
|
||||
install(TARGETS st-util
|
||||
RUNTIME DESTINATION bin
|
||||
)
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
PRG := st-util
|
||||
OBJS = gdb-remote.o gdb-server.o
|
||||
|
||||
CFLAGS+=-g -Wall -Werror -std=gnu99 -I../src
|
||||
LDFLAGS=-L.. -lstlink
|
||||
|
||||
# libusb location
|
||||
LDFLAGS+=`pkg-config --libs libusb-1.0`
|
||||
CFLAGS+=`pkg-config --cflags libusb-1.0`
|
||||
|
||||
all: $(PRG)
|
||||
|
||||
$(PRG): $(OBJS) ../libstlink.a
|
||||
$(CC) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJS)
|
||||
rm -rf $(PRG)
|
||||
|
||||
.PHONY: clean all
|
|
@ -5,11 +5,11 @@ set(TESTS
|
|||
|
||||
foreach(test ${TESTS})
|
||||
add_executable(${test} ${test}.c)
|
||||
add_dependencies(${test} ${PROJECT_NAME})
|
||||
target_link_libraries(${test} ${PROJECT_NAME})
|
||||
add_dependencies(${test} ${STLINK_LIB_STATIC})
|
||||
target_link_libraries(${test} ${STLINK_LIB_STATIC})
|
||||
add_test(${test} ${CMAKE_CURRENT_BINARY_DIR}/${test})
|
||||
endforeach()
|
||||
|
||||
add_executable(flash flash.c "${CMAKE_SOURCE_DIR}/src/tools/flash_opts.c")
|
||||
target_link_libraries(flash ${PROJECT_NAME})
|
||||
target_link_libraries(flash ${STLINK_LIB_STATIC})
|
||||
add_test(flash ${CMAKE_CURRENT_BINARY_DIR}/flash)
|
||||
|
|
Ładowanie…
Reference in New Issue