Fix zlib install

This commit is contained in:
Luke Street 2021-06-22 16:32:55 -04:00
parent 4bd9dfac61
commit 2aa9a573a0
3 changed files with 12 additions and 6 deletions

View File

@ -226,7 +226,7 @@ target_include_directories(athena-core PUBLIC
target_link_libraries(athena-core PUBLIC target_link_libraries(athena-core PUBLIC
athena-libyaml athena-libyaml
fmt fmt
${ZLIB_LIBRARIES} $<BUILD_INTERFACE:${ZLIB_LIBRARIES}>
) )
add_library(athena-sakura EXCLUDE_FROM_ALL add_library(athena-sakura EXCLUDE_FROM_ALL
@ -332,8 +332,11 @@ endforeach()
# Define installs # Define installs
install(DIRECTORY include/athena DESTINATION ${INSTALL_INCLUDE_DIR} COMPONENT athena) install(DIRECTORY include/athena DESTINATION ${INSTALL_INCLUDE_DIR} COMPONENT athena)
install(DIRECTORY extern/fmt/include/fmt DESTINATION ${INSTALL_INCLUDE_DIR} COMPONENT athena) install(DIRECTORY extern/fmt/include/fmt DESTINATION ${INSTALL_INCLUDE_DIR} COMPONENT athena)
install(TARGETS athena-core fmt if (ATHENA_ZLIB)
DESTINATION ${INSTALL_LIB_DIR} EXPORT AthenaTargets COMPONENT athena) set(ZLIB_INSTALL ${ZLIB_LIBRARIES})
endif ()
install(TARGETS athena-core fmt ${ZLIB_INSTALL}
DESTINATION ${INSTALL_LIB_DIR} EXPORT AthenaTargets COMPONENT athena)
if(WIN32 AND NOT CYGWIN) if(WIN32 AND NOT CYGWIN)
install(FILES Athena.ico DESTINATION ${INSTALL_LIB_DIR} COMPONENT athena) install(FILES Athena.ico DESTINATION ${INSTALL_LIB_DIR} COMPONENT athena)
elseif(UNIX) elseif(UNIX)
@ -348,7 +351,7 @@ endif()
################## ##################
# Add all targets to the build-tree export set # Add all targets to the build-tree export set
export(TARGETS athena-core athena-libyaml fmt FILE "${CMAKE_CURRENT_BINARY_DIR}/AthenaTargets.cmake") export(TARGETS athena-core athena-libyaml fmt ${ZLIB_LIBRARIES} FILE "${CMAKE_CURRENT_BINARY_DIR}/AthenaTargets.cmake")
# Export the package for use from the build-tree # Export the package for use from the build-tree
# (this registers the build-tree with a global CMake-registry) # (this registers the build-tree with a global CMake-registry)

View File

@ -7,7 +7,6 @@ add_subdirectory(yaml)
if(NOT TARGET fmt) if(NOT TARGET fmt)
add_subdirectory(fmt) add_subdirectory(fmt)
target_compile_definitions(fmt PUBLIC target_compile_definitions(fmt PUBLIC
FMT_STRING_ALIAS=1
FMT_ARM_ABI_COMPATIBILITY=1 FMT_ARM_ABI_COMPATIBILITY=1
FMT_EXCEPTIONS=0) FMT_EXCEPTIONS=0)
target_compile_definitions(fmt INTERFACE target_compile_definitions(fmt INTERFACE

View File

@ -4,8 +4,11 @@ if (APPLE)
endif () endif ()
find_package(ZLIB ${ZLIB_REQUIRED}) find_package(ZLIB ${ZLIB_REQUIRED})
if (ZLIB_FOUND) if (ZLIB_FOUND)
add_library(z ALIAS ZLIB::ZLIB) # alias hack to allow use from global context add_library(z INTERFACE)
target_link_libraries(z INTERFACE ${ZLIB_LIBRARIES})
target_include_directories(z INTERFACE ${ZLIB_INCLUDE_DIRS})
set(ZLIB_LIBRARIES z CACHE STRING "zlib libraries" FORCE) set(ZLIB_LIBRARIES z CACHE STRING "zlib libraries" FORCE)
set(ATHENA_ZLIB NO CACHE BOOL "Using built-in zlib" FORCE)
else () else ()
message(STATUS "Using Athena's built-in zlib") message(STATUS "Using Athena's built-in zlib")
add_library(z add_library(z
@ -39,4 +42,5 @@ else ()
endif () endif ()
target_include_directories(z INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(z INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
set(ZLIB_LIBRARIES z CACHE STRING "zlib libraries" FORCE) set(ZLIB_LIBRARIES z CACHE STRING "zlib libraries" FORCE)
set(ATHENA_ZLIB YES CACHE BOOL "Using built-in zlib" FORCE)
endif () endif ()