From 63dd3a30fcb0cb6421dc59567c5a0eaccbe5f437 Mon Sep 17 00:00:00 2001 From: Stijn Herfst Date: Fri, 2 Aug 2019 22:31:48 +0200 Subject: [PATCH] [casclib] Added CMake targets (#7522) * Added CMake targets * Windows build failure fix * [casclib] Improve CMake find_package() integration * [casclib] Remove unused lines --- ports/casclib/CMakeLists.txt | 59 ++++++++++++++++++++--------------- ports/casclib/CONTROL | 4 +-- ports/casclib/Config.cmake.in | 7 +++++ ports/casclib/portfile.cmake | 16 ++++++++-- 4 files changed, 56 insertions(+), 30 deletions(-) create mode 100644 ports/casclib/Config.cmake.in diff --git a/ports/casclib/CMakeLists.txt b/ports/casclib/CMakeLists.txt index 4165814f56..ad05df424c 100644 --- a/ports/casclib/CMakeLists.txt +++ b/ports/casclib/CMakeLists.txt @@ -1,22 +1,13 @@ cmake_minimum_required(VERSION 3.9) -project(CascLib) -set(HEADER_FILES - src/CascCommon.h - src/CascLib.h - src/CascLib.def - src/CascPort.h - src/common/Array.h - src/common/Common.h - src/common/Csv.h - src/common/FileStream.h - src/common/FileTree.h - src/common/ListFile.h - src/common/Map.h - src/jenkins/lookup.h -) +project(casclib) +set(PROJECT_VERSION_MAJOR 1) +set(PROJECT_VERSION_MINOR 50) + +option(INSTALL_HEADERS "Install header files" ON) set(SRC_FILES + src/CascLib.def src/CascCommon.cpp src/CascDecompress.cpp src/CascDecrypt.cpp @@ -57,18 +48,36 @@ set(ZLIB_FILES src/zlib/zutil.c ) +add_library(casclib ${SRC_FILES} ${ZLIB_FILES} ${MD5_FILES}) +target_include_directories(casclib + PUBLIC + $ + $) if(WIN32) - add_definitions(-DUNICODE -D_UNICODE) + target_compile_definitions(casclib PRIVATE UNICODE _UNICODE) endif() -add_library(CascLib ${SRC_FILES} ${HEADER_FILES} ${TOMCRYPT_FILES} ${ZLIB_FILES} ${MD5_FILES}) +install(TARGETS casclib + EXPORT casclibTargets + RUNTIME DESTINATION bin + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib +) -set_target_properties(CascLib PROPERTIES PUBLIC_HEADER "src/CascLib.h;src/CascPort.h") +include(CMakePackageConfigHelpers) -install(TARGETS CascLib - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - FRAMEWORK DESTINATION /Library/Frameworks - PUBLIC_HEADER DESTINATION include - INCLUDES DESTINATION include) \ No newline at end of file +set(VERSION_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/temp/casclibConfigVersion.cmake") +set(PROJECT_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/temp/casclibConfig.cmake") +set(INSTALL_DIR "share/casclib") + +write_basic_package_version_file("${VERSION_CONFIG}" VERSION 1.50 COMPATIBILITY SameMajorVersion) +configure_package_config_file("Config.cmake.in" + "${PROJECT_CONFIG}" + INSTALL_DESTINATION "${INSTALL_DIR}") + +install(FILES "${PROJECT_CONFIG}" "${VERSION_CONFIG}" DESTINATION "${INSTALL_DIR}") +install(EXPORT casclibTargets DESTINATION "${INSTALL_DIR}") + +if(INSTALL_HEADERS) + install(FILES "src/CascLib.h" "src/CascPort.h" DESTINATION include/casclib) +endif() diff --git a/ports/casclib/CONTROL b/ports/casclib/CONTROL index a9a10ac9bf..4622f5200c 100644 --- a/ports/casclib/CONTROL +++ b/ports/casclib/CONTROL @@ -1,4 +1,4 @@ Source: casclib -Version: 1.50 +Version: 1.50-1 Build-Depends: zlib -Description: An open-source implementation of library for reading CASC storage from Blizzard games since 2014 \ No newline at end of file +Description: An open-source implementation of library for reading CASC storage from Blizzard games since 2014 diff --git a/ports/casclib/Config.cmake.in b/ports/casclib/Config.cmake.in new file mode 100644 index 0000000000..96f5154279 --- /dev/null +++ b/ports/casclib/Config.cmake.in @@ -0,0 +1,7 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) +find_dependency(ZLIB REQUIRED) + +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +check_required_components("@PROJECT_NAME@") diff --git a/ports/casclib/portfile.cmake b/ports/casclib/portfile.cmake index bf17bc5451..9604ac618e 100644 --- a/ports/casclib/portfile.cmake +++ b/ports/casclib/portfile.cmake @@ -10,14 +10,24 @@ vcpkg_from_github( ctype_for_mac.patch ) -file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}) +file(COPY + ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_LIST_DIR}/Config.cmake.in + DESTINATION + ${SOURCE_PATH} +) vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} PREFER_NINJA + OPTIONS_DEBUG + -DINSTALL_HEADERS=OFF ) vcpkg_install_cmake() -file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/casclib RENAME copyright) -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) \ No newline at end of file +vcpkg_fixup_cmake_targets() + +file(INSTALL ${SOURCE_PATH}/LICENSE + DESTINATION ${CURRENT_PACKAGES_DIR}/share/casclib + RENAME copyright)