link zlib in a better way

This commit is contained in:
Thomas Fussell 2017-03-11 10:37:28 -05:00
parent e2f8720bb2
commit b4d84f29f1
2 changed files with 7 additions and 3 deletions

View File

@ -132,7 +132,7 @@ add_dependencies(xlnt xlnt.third-party)
target_link_libraries(xlnt PRIVATE libstudxml)
target_include_directories(xlnt PUBLIC ${XLNT_INCLUDE_DIR})
target_include_directories(xlnt PRIVATE ${XLNT_SOURCE_DIR})
target_link_libraries(xlnt PUBLIC ${ZLIB_LIBRARY_RELEASE})
target_link_libraries(xlnt PRIVATE ${ZLIB_LIBRARY_RELEASE})
target_include_directories(xlnt PRIVATE ${ZLIB_INCLUDE_DIR})
target_link_libraries(xlnt PRIVATE ${CRYPTOPP_LIBRARY_RELEASE})
target_include_directories(xlnt PRIVATE ${CRYPTOPP_INCLUDE_DIR})

View File

@ -8,6 +8,10 @@ if(NOT COMBINED_PROJECT)
add_subdirectory(${LIBRARY_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/source)
endif()
# Tests uses the private interface of xlnt (source/detail) so it needs to explicitly link zlib
# as zlib is not part of xlnt's default link interface
find_package(ZLIB REQUIRED)
file(GLOB CELL_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/cell/tests/test_*.hpp)
file(GLOB CHARTS_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/charts/tests/test_*.hpp)
file(GLOB CHARTSHEET_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/chartsheet/tests/test_*.hpp)
@ -39,11 +43,11 @@ endif()
add_executable(xlnt.test ${TEST_HELPERS} ${TESTS} ${RUNNER})
target_link_libraries(xlnt.test
PRIVATE xlnt)
target_link_libraries(xlnt.test PRIVATE ${ZLIB_LIBRARY_RELEASE})
target_include_directories(xlnt.test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../source
PRIVATE ${CXXTEST_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../third-party/libstudxml)
PRIVATE ${CXXTEST_INCLUDE_DIR})
set(XLNT_TEST_DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data)
target_compile_definitions(xlnt.test PRIVATE XLNT_TEST_DATA_DIR=${XLNT_TEST_DATA_DIR})