cmake: fix pkgconfig and cmake interaction

Issue #454
This commit is contained in:
John McNamara 2025-02-12 19:44:01 +00:00
parent a18ee6498d
commit fc5497b6ee

View File

@ -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()
@ -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}")
@ -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.