Annotation of embedaddon/curl/CMake/Macros.cmake, revision 1.1

1.1     ! misho       1: #***************************************************************************
        !             2: #                                  _   _ ____  _
        !             3: #  Project                     ___| | | |  _ \| |
        !             4: #                             / __| | | | |_) | |
        !             5: #                            | (__| |_| |  _ <| |___
        !             6: #                             \___|\___/|_| \_\_____|
        !             7: #
        !             8: # Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
        !             9: #
        !            10: # This software is licensed as described in the file COPYING, which
        !            11: # you should have received as part of this distribution. The terms
        !            12: # are also available at https://curl.haxx.se/docs/copyright.html.
        !            13: #
        !            14: # You may opt to use, copy, modify, merge, publish, distribute and/or sell
        !            15: # copies of the Software, and permit persons to whom the Software is
        !            16: # furnished to do so, under the terms of the COPYING file.
        !            17: #
        !            18: # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
        !            19: # KIND, either express or implied.
        !            20: #
        !            21: ###########################################################################
        !            22: #File defines convenience macros for available feature testing
        !            23: 
        !            24: # This macro checks if the symbol exists in the library and if it
        !            25: # does, it prepends library to the list.  It is intended to be called
        !            26: # multiple times with a sequence of possibly dependent libraries in
        !            27: # order of least-to-most-dependent.  Some libraries depend on others
        !            28: # to link correctly.
        !            29: macro(check_library_exists_concat LIBRARY SYMBOL VARIABLE)
        !            30:   check_library_exists("${LIBRARY};${CURL_LIBS}" ${SYMBOL} "${CMAKE_LIBRARY_PATH}"
        !            31:     ${VARIABLE})
        !            32:   if(${VARIABLE})
        !            33:     set(CURL_LIBS ${LIBRARY} ${CURL_LIBS})
        !            34:   endif()
        !            35: endmacro()
        !            36: 
        !            37: # Check if header file exists and add it to the list.
        !            38: # This macro is intended to be called multiple times with a sequence of
        !            39: # possibly dependent header files.  Some headers depend on others to be
        !            40: # compiled correctly.
        !            41: macro(check_include_file_concat FILE VARIABLE)
        !            42:   check_include_files("${CURL_INCLUDES};${FILE}" ${VARIABLE})
        !            43:   if(${VARIABLE})
        !            44:     set(CURL_INCLUDES ${CURL_INCLUDES} ${FILE})
        !            45:     set(CURL_TEST_DEFINES "${CURL_TEST_DEFINES} -D${VARIABLE}")
        !            46:   endif()
        !            47: endmacro()
        !            48: 
        !            49: # For other curl specific tests, use this macro.
        !            50: macro(curl_internal_test CURL_TEST)
        !            51:   if(NOT DEFINED "${CURL_TEST}")
        !            52:     set(MACRO_CHECK_FUNCTION_DEFINITIONS
        !            53:       "-D${CURL_TEST} ${CURL_TEST_DEFINES} ${CMAKE_REQUIRED_FLAGS}")
        !            54:     if(CMAKE_REQUIRED_LIBRARIES)
        !            55:       set(CURL_TEST_ADD_LIBRARIES
        !            56:         "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
        !            57:     endif()
        !            58: 
        !            59:     message(STATUS "Performing Curl Test ${CURL_TEST}")
        !            60:     try_compile(${CURL_TEST}
        !            61:       ${CMAKE_BINARY_DIR}
        !            62:       ${CMAKE_CURRENT_SOURCE_DIR}/CMake/CurlTests.c
        !            63:       CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
        !            64:       "${CURL_TEST_ADD_LIBRARIES}"
        !            65:       OUTPUT_VARIABLE OUTPUT)
        !            66:     if(${CURL_TEST})
        !            67:       set(${CURL_TEST} 1 CACHE INTERNAL "Curl test ${FUNCTION}")
        !            68:       message(STATUS "Performing Curl Test ${CURL_TEST} - Success")
        !            69:       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
        !            70:         "Performing Curl Test ${CURL_TEST} passed with the following output:\n"
        !            71:         "${OUTPUT}\n")
        !            72:     else()
        !            73:       message(STATUS "Performing Curl Test ${CURL_TEST} - Failed")
        !            74:       set(${CURL_TEST} "" CACHE INTERNAL "Curl test ${FUNCTION}")
        !            75:       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
        !            76:         "Performing Curl Test ${CURL_TEST} failed with the following output:\n"
        !            77:         "${OUTPUT}\n")
        !            78:     endif()
        !            79:   endif()
        !            80: endmacro()
        !            81: 
        !            82: macro(curl_nroff_check)
        !            83:   find_program(NROFF NAMES gnroff nroff)
        !            84:   if(NROFF)
        !            85:     # Need a way to write to stdin, this will do
        !            86:     file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt" "test")
        !            87:     # Tests for a valid nroff option to generate a manpage
        !            88:     foreach(_MANOPT "-man" "-mandoc")
        !            89:       execute_process(COMMAND "${NROFF}" ${_MANOPT}
        !            90:         OUTPUT_VARIABLE NROFF_MANOPT_OUTPUT
        !            91:         INPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt"
        !            92:         ERROR_QUIET)
        !            93:       # Save the option if it was valid
        !            94:       if(NROFF_MANOPT_OUTPUT)
        !            95:         message("Found *nroff option: -- ${_MANOPT}")
        !            96:         set(NROFF_MANOPT ${_MANOPT})
        !            97:         set(NROFF_USEFUL ON)
        !            98:         break()
        !            99:       endif()
        !           100:     endforeach()
        !           101:     # No need for the temporary file
        !           102:     file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt")
        !           103:     if(NOT NROFF_USEFUL)
        !           104:       message(WARNING "Found no *nroff option to get plaintext from man pages")
        !           105:     endif()
        !           106:   else()
        !           107:     message(WARNING "Found no *nroff program")
        !           108:   endif()
        !           109: endmacro()

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>