• 带有ZLIB_LIBRARY_DEBUG的FindZLIB.cmake文件


    CMake自带的FindZLIB.cmake只有ZLIB_LIBRARY,而没有ZLIB_LIBRARY_DEBUG

    将下面的代码保存成FindZLIB.cmake,替换掉D:Program Files (x86)CMakesharecmake-3.3ModulesFindZLIB.cmake

    # - Find zlib
    # Find the native ZLIB includes and library.
    # Once done this will define
    #
    #  ZLIB_INCLUDE_DIRS   - where to find zlib.h, etc.
    #  ZLIB_LIBRARIES      - List of libraries when using zlib.
    #  ZLIB_FOUND          - True if zlib found.
    #
    #  ZLIB_VERSION_STRING - The version of zlib found (x.y.z)
    #  ZLIB_VERSION_MAJOR  - The major version of zlib
    #  ZLIB_VERSION_MINOR  - The minor version of zlib
    #  ZLIB_VERSION_PATCH  - The patch version of zlib
    #  ZLIB_VERSION_TWEAK  - The tweak version of zlib
    #
    # The following variable are provided for backward compatibility
    #
    #  ZLIB_MAJOR_VERSION  - The major version of zlib
    #  ZLIB_MINOR_VERSION  - The minor version of zlib
    #  ZLIB_PATCH_VERSION  - The patch version of zlib
    #
    # An includer may set ZLIB_ROOT to a zlib installation root to tell
    # this module where to look.
    
    #=============================================================================
    # Copyright 2001-2011 Kitware, Inc.
    #
    # Distributed under the OSI-approved BSD License (the "License");
    # see accompanying file Copyright.txt for details.
    #
    # This software is distributed WITHOUT ANY WARRANTY; without even the
    # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    # See the License for more information.
    #=============================================================================
    # (To distribute this file outside of CMake, substitute the full
    #  License text for the above reference.)
    
    set(_ZLIB_SEARCHES)
    
    # Search ZLIB_ROOT first if it is set.
    if(ZLIB_ROOT)
      set(_ZLIB_SEARCH_ROOT PATHS ${ZLIB_ROOT} NO_DEFAULT_PATH)
      list(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_ROOT)
    endif()
    
    # Normal search.
    set(_ZLIB_SEARCH_NORMAL
      PATHS "[HKEY_LOCAL_MACHINE\SOFTWARE\GnuWin32\Zlib;InstallPath]"
            "$ENV{PROGRAMFILES}/zlib"
      )
    list(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_NORMAL)
    
    set(ZLIB_NAMES z zlib zdll zlib1)
    set(ZLIB_NAMES_DEBUG zlibd zlibd1)
    
    # Try each search configuration.
    foreach(search ${_ZLIB_SEARCHES})
      find_path(ZLIB_INCLUDE_DIR NAMES zlib.h        ${${search}} PATH_SUFFIXES include)
      find_library(ZLIB_LIBRARY  NAMES ${ZLIB_NAMES} ${${search}} PATH_SUFFIXES lib)
      find_library(ZLIB_LIBRARY_DEBUG  NAMES ${ZLIB_NAMES_DEBUG} ${${search}} PATH_SUFFIXES lib)
    endforeach()
    
    mark_as_advanced(ZLIB_INCLUDE_DIR ZLIB_LIBRARY ZLIB_LIBRARY_DEBUG)
    
    # parse version from #define ZLIB_VERSION in zlib.h
    if(ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h")
        file(STRINGS "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_H REGEX "^#define ZLIB_VERSION "[^"]*"$")
    
        string(REGEX REPLACE "^.*ZLIB_VERSION "([0-9]+).*$" "\1" ZLIB_VERSION_MAJOR "${ZLIB_H}")
        string(REGEX REPLACE "^.*ZLIB_VERSION "[0-9]+\.([0-9]+).*$" "\1" ZLIB_VERSION_MINOR  "${ZLIB_H}")
        string(REGEX REPLACE "^.*ZLIB_VERSION "[0-9]+\.[0-9]+\.([0-9]+).*$" "\1" ZLIB_VERSION_PATCH "${ZLIB_H}")
        set(ZLIB_VERSION_STRING "${ZLIB_VERSION_MAJOR}.${ZLIB_VERSION_MINOR}.${ZLIB_VERSION_PATCH}")
    
        # only append a TWEAK version if it exists:
        set(ZLIB_VERSION_TWEAK "")
        if( "${ZLIB_H}" MATCHES "^.*ZLIB_VERSION "[0-9]+\.[0-9]+\.[0-9]+\.([0-9]+).*$")
            set(ZLIB_VERSION_TWEAK "${CMAKE_MATCH_1}")
            set(ZLIB_VERSION_STRING "${ZLIB_VERSION_STRING}.${ZLIB_VERSION_TWEAK}")
        endif()
    
        set(ZLIB_MAJOR_VERSION "${ZLIB_VERSION_MAJOR}")
        set(ZLIB_MINOR_VERSION "${ZLIB_VERSION_MINOR}")
        set(ZLIB_PATCH_VERSION "${ZLIB_VERSION_PATCH}")
    endif()
    
    # handle the QUIETLY and REQUIRED arguments and set ZLIB_FOUND to TRUE if
    # all listed variables are TRUE
    include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
    FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB REQUIRED_VARS ZLIB_LIBRARY ZLIB_INCLUDE_DIR
                                           VERSION_VAR ZLIB_VERSION_STRING)
    
    if(ZLIB_FOUND)
        set(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR})
        if(ZLIB_LIBRARY_DEBUG)
            set(ZLIB_LIBRARIES debug ${ZLIB_LIBRARY_DEBUG} optimized ${ZLIB_LIBRARY})
        else()
            set(ZLIB_LIBRARIES ${ZLIB_LIBRARY})
        endif()
    endif()
  • 相关阅读:
    java注解实例-反射生成sql
    应用服务器集群的伸缩性设计
    高可用的服务
    应用服务器集群Session管理
    应用服务器性能优化 (存储性能优化)
    应用服务器性能优化 (代码优化)
    应用服务器性能优化 (使用集群)
    应用服务器性能优化 (异步操作)
    应用服务器性能优化 (分布式缓存)
    Web前端性能优化(CDN加速及反向代理)
  • 原文地址:https://www.cnblogs.com/coolbear/p/7587616.html
Copyright © 2020-2023  润新知