Skip to content

Commit

Permalink
Update for library linking
Browse files Browse the repository at this point in the history
- Simplified code
- Added version info for static library
  • Loading branch information
Nightwalker-87 committed May 17, 2020
1 parent 06c66ed commit cde5a97
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,15 @@ 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)
if (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})
Expand All @@ -215,20 +215,28 @@ 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)
if (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})
Expand Down

0 comments on commit cde5a97

Please sign in to comment.