Skip to content

Commit

Permalink
Fix linkage of custom PCSC libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
qpernil committed Apr 22, 2024
1 parent 9258cba commit b37b863
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
18 changes: 8 additions & 10 deletions cmake/pcscd.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -92,27 +92,25 @@ macro (find_pcscd)
endif(PCSC_FOUND)
endif()

if(${PCSC_LIB} NOT STREQUAL "")
if(NOT ${PCSC_LIB} STREQUAL "")
message("Checking for PCSC with custom lib")
find_file(PCSC_WINSCARD_H_FOUND PCSC/winscard.h)
if(${PCSC_DIR} NOT STREQUAL "")
if(NOT ${PCSC_DIR} STREQUAL "")
set(PCSC_CUSTOM_LIBS "-Wl,-L${PCSC_DIR} -Wl,-l${PCSC_LIB} -Wl,-rpath,${PCSC_DIR}")
else(${PCSC_DIR} NOT STREQUAL "")
else(NOT ${PCSC_DIR} STREQUAL "")
set(PCSC_CUSTOM_LIBS "-Wl,-l${PCSC_LIB}")
endif(${PCSC_DIR} NOT STREQUAL "")
endif(NOT ${PCSC_DIR} STREQUAL "")
set(CMAKE_C_FLAGS ${PCSC_CFLAGS} ${CMAKE_C_FLAGS})
set(PCSC_LIBRARIES ${PCSC_LIBRARIES} ${PCSC_CUSTOM_LIBS})
unset(PCSC_MACOSX_LIBS)
unset(PCSC_WIN_LIBS)
unset(PCSC_LIBS)
endif(${PCSC_LIB} NOT STREQUAL "")
set(PCSC_LIBRARIES ${PCSC_CUSTOM_LIBS} ${PCSC_LIBRARIES} )
message("PCSC_CUSTOM_LIBS: ${PCSC_CUSTOM_LIBS}")
endif(NOT ${PCSC_LIB} STREQUAL "")

string(REPLACE ";" " " PCSC_CFLAGS "${PCSC_CFLAGS}")

if(${BACKEND} STREQUAL ${BACKEND_ARG_PCSC} OR
${BACKEND} STREQUAL ${BACKEND_ARG_WIN} OR
${BACKEND} STREQUAL ${BACKEND_ARG_MAC} OR
${PCSC_LIB} NOT STREQUAL "")
NOT ${PCSC_LIB} STREQUAL "")
set(BACKEND_PCSC ON)
else()
message (FATAL_ERROR "cannot find PCSC library")
Expand Down
4 changes: 2 additions & 2 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ endif()
# static library
if(BUILD_STATIC_LIB)
add_library(ykpiv STATIC ${SOURCE})
target_link_libraries(ykpiv ${LIBCRYPTO_LIBRARIES} ${PCSC_LIBRARIES} ${PCSC_WIN_LIBS} ${PCSC_MACOSX_LIBS} ${PCSC_CUSTOM_LIBS} ${ZLIB_LIBS})
target_link_libraries(ykpiv ${LIBCRYPTO_LIBRARIES} ${PCSC_LIBRARIES} ${ZLIB_LIBS})
set_target_properties (ykpiv PROPERTIES COMPILE_FLAGS "-DSTATIC ")
if(WIN32)
set_target_properties(ykpiv PROPERTIES OUTPUT_NAME ykpiv_static)
Expand All @@ -72,7 +72,7 @@ endif(BUILD_STATIC_LIB)

# dynamic library
add_library(ykpiv_shared SHARED ${SOURCE})
target_link_libraries(ykpiv_shared ${LIBCRYPTO_LIBRARIES} ${PCSC_LIBRARIES} ${PCSC_WIN_LIBS} ${PCSC_MACOSX_LIBS} ${PCSC_CUSTOM_LIBS} ${ZLIB_LIBS})
target_link_libraries(ykpiv_shared ${LIBCRYPTO_LIBRARIES} ${PCSC_LIBRARIES} ${ZLIB_LIBS})
set_target_properties(ykpiv_shared PROPERTIES SOVERSION ${SO_VERSION} VERSION ${VERSION})
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set_target_properties(ykpiv_shared PROPERTIES INSTALL_RPATH "${YKPIV_INSTALL_LIB_DIR}")
Expand Down

0 comments on commit b37b863

Please sign in to comment.