Skip to content

Commit

Permalink
cmake: fix pkgconfig and cmake interaction
Browse files Browse the repository at this point in the history
Issue #454
  • Loading branch information
jmcnamara committed Feb 13, 2025
1 parent caf4158 commit 30777ca
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -228,18 +228,19 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
if(PKG_CONFIG_FOUND)
pkg_check_modules(ZLIB zlib)
list(APPEND LXW_PRIVATE_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS})
else(NOT ZLIB_FOUND)
else()
find_package(ZLIB "1.0" REQUIRED)
list(APPEND LXW_PRIVATE_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS})
message("zlib version: " ${ZLIB_VERSION})
endif()


# MINIZIP
if(USE_SYSTEM_MINIZIP)
if(PKG_CONFIG_FOUND)
pkg_check_modules(MINIZIP minizip)
list(APPEND LXW_PRIVATE_INCLUDE_DIRS ${MINIZIP_INCLUDE_DIRS}/..)
else(NOT MINIZIP_FOUND)
else()
find_package(MINIZIP "1.0" REQUIRED)
list(APPEND LXW_PRIVATE_INCLUDE_DIRS ${MINIZIP_INCLUDE_DIRS})
endif()
Expand Down Expand Up @@ -288,7 +289,7 @@ if(USE_OPENSSL_MD5)
if(PKG_CONFIG_FOUND)
pkg_check_modules(LIBCRYPTO libcrypto)
include_directories(${LIBCRYPTO_INCLUDE_DIRS})
else(NOT LIBCRYPTO_FOUND)
else()
find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})
message(STATUS "OpenSSL version: ${OPENSSL_VERSION}")
Expand All @@ -308,21 +309,24 @@ target_sources(${PROJECT_NAME}
PRIVATE ${LXW_SOURCES}
PUBLIC ${LXW_HEADERS}
)
if(ZLIB_LDFLAGS)
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${ZLIB_LDFLAGS})
if(ZLIB_LINK_LIBRARIES)
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${ZLIB_LINK_LIBRARIES})
else()
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${ZLIB_LIBRARIES})
endif()
if(MINIZIP_LDFLAGS)
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${MINIZIP_LDFLAGS})

if(MINIZIP_LINK_LIBRARIES)
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${MINIZIP_LINK_LIBRARIES})
else()
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${MINIZIP_LIBRARIES})
endif()
if(LIBCRYPTO_LDFLAGS)
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${LIBCRYPTO_LDFLAGS})

if(LIBCRYPTO_LINK_LIBRARIES)
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${LIBCRYPTO_LINK_LIBRARIES})
else()
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${LIB_CRYPTO} ${OPENSSL_CRYPTO_LIBRARY})
endif()

target_compile_definitions(${PROJECT_NAME} PRIVATE ${LXW_PRIVATE_COMPILE_DEFINITIONS})

# /utf-8 needs VS2015 Update 2 or above.
Expand Down

0 comments on commit 30777ca

Please sign in to comment.