Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Link for WIN32 & APPLE with stlink-static #1069

Merged
merged 1 commit into from
Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,7 @@ execute_process(COMMAND bash -c "export LD_LIBRARY_PATH=${CMAKE_INSTALL_LIBDIR}"
###

# Set library name
if (NOT WIN32)
set(STLINK_LIB_SHARED ${PROJECT_NAME})
else (WIN32)
set(STLINK_LIB_SHARED ${PROJECT_NAME}-shared)
endif ()
set(STLINK_LIB_SHARED ${PROJECT_NAME}-shared)

add_library(${STLINK_LIB_SHARED} SHARED ${STLINK_HEADERS} ${STLINK_SOURCE})

Expand Down Expand Up @@ -195,6 +191,10 @@ install(TARGETS ${STLINK_LIB_SHARED} DESTINATION ${STLINK_LIBRARY_PATH})

# Set library name
set(STLINK_LIB_STATIC ${PROJECT_NAME}-static)
set(STLINK_LIB_STATIC_OUTPUT_NAME ${PROJECT_NAME})
if (MSVC)
set(STLINK_LIB_STATIC_OUTPUT_NAME ${PROJECT_NAME}-static)
endif()

add_library(${STLINK_LIB_STATIC} STATIC ${STLINK_HEADERS} ${STLINK_SOURCE})

Expand All @@ -206,7 +206,7 @@ message(STATUS "VERSION: ${STLINK_STATIC_VERSION}")
set_target_properties(${STLINK_LIB_STATIC} PROPERTIES
SOVERSION ${PROJECT_VERSION_MAJOR}
VERSION ${STLINK_STATIC_VERSION}
OUTPUT_NAME ${PROJECT_NAME}
OUTPUT_NAME ${STLINK_LIB_STATIC_OUTPUT_NAME}
)

# Link static library
Expand Down
12 changes: 9 additions & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@

set(TESTEXEC usb sg)

set(TEST_DEPENDENCY ${STLINK_LIB_SHARED})
if (WIN32 OR APPLE)
set(TEST_DEPENDENCY ${STLINK_LIB_STATIC})
endif()

foreach (test ${TESTEXEC})
add_executable(test-${test} ${test}.c)
add_dependencies(test-${test} ${STLINK_LIB_SHARED})
target_link_libraries(test-${test} ${STLINK_LIB_SHARED} ${SSP_LIB})
add_dependencies(test-${test} ${TEST_DEPENDENCY})
target_link_libraries(test-${test} ${TEST_DEPENDENCY} ${SSP_LIB})
add_test(test-${test} ${CMAKE_BINARY_DIR}/bin/test-${test})
endforeach ()

add_executable(test-flash flash.c "${CMAKE_SOURCE_DIR}/src/st-flash/flash_opts.c")
target_link_libraries(test-flash ${STLINK_LIB_SHARED} ${SSP_LIB})
add_dependencies(test-flash ${TEST_DEPENDENCY})
target_link_libraries(test-flash ${TEST_DEPENDENCY} ${SSP_LIB})
add_test(test-flash ${CMAKE_BINARY_DIR}/bin/test-flash)