From 7faf9b14e1c0fb682862e66c913e27eda8aa2d78 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Sun, 17 May 2020 19:12:52 +0200 Subject: [PATCH] Update for library linking - Simplified code - Added version info for static library --- CMakeLists.txt | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b5301fb0a..8ebe9cffb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -186,15 +186,13 @@ set_target_properties( VERSION ${STLINK_SHARED_VERSION} ) -# Link shared library with Apple macOS libraries -if (APPLE) +# Link shared library +if (APPLE) # ... with Apple macOS libraries find_library(ObjC objc) find_library(CoreFoundation CoreFoundation) find_library(IOKit IOKit) target_link_libraries(${STLINK_LIB_SHARED} ${CoreFoundation} ${IOKit} ${ObjC} ${SSP_LIB}) -endif () - -if (WIN32 OR MINGW OR MSYS) +elseif (WIN32) # ... with Windows libraries target_link_libraries(${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY} wsock32 ws2_32 ${SSP_LIB}) else () target_link_libraries(${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY} ${SSP_LIB}) @@ -215,20 +213,26 @@ add_library( ${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 ${PROJECT_NAME} ) -# Link static library with Apple macOS libraries -if (APPLE) +# Link static library +if (APPLE) # ... with Apple macOS libraries find_library(ObjC objc) find_library(CoreFoundation CoreFoundation) find_library(IOKit IOKit) target_link_libraries(${STLINK_LIB_STATIC} ${CoreFoundation} ${IOKit} ${ObjC} ${SSP_LIB}) -endif () - -if (WIN32 OR MINGW OR MSYS) +elseif (WIN32) # ... with Windows libraries target_link_libraries(${STLINK_LIB_STATIC} ${LIBUSB_LIBRARY} wsock32 ws2_32 ${SSP_LIB}) else () target_link_libraries(${STLINK_LIB_STATIC} ${LIBUSB_LIBRARY} ${SSP_LIB})