comparison mupdf-source/thirdparty/curl/CMake/Macros.cmake @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 #File defines convenience macros for available feature testing
2
3 # This macro checks if the symbol exists in the library and if it
4 # does, it prepends library to the list. It is intended to be called
5 # multiple times with a sequence of possibly dependent libraries in
6 # order of least-to-most-dependent. Some libraries depend on others
7 # to link correctly.
8 macro(check_library_exists_concat LIBRARY SYMBOL VARIABLE)
9 check_library_exists("${LIBRARY};${CURL_LIBS}" ${SYMBOL} "${CMAKE_LIBRARY_PATH}"
10 ${VARIABLE})
11 if(${VARIABLE})
12 set(CURL_LIBS ${LIBRARY} ${CURL_LIBS})
13 endif()
14 endmacro()
15
16 # Check if header file exists and add it to the list.
17 # This macro is intended to be called multiple times with a sequence of
18 # possibly dependent header files. Some headers depend on others to be
19 # compiled correctly.
20 macro(check_include_file_concat FILE VARIABLE)
21 check_include_files("${CURL_INCLUDES};${FILE}" ${VARIABLE})
22 if(${VARIABLE})
23 set(CURL_INCLUDES ${CURL_INCLUDES} ${FILE})
24 set(CURL_TEST_DEFINES "${CURL_TEST_DEFINES} -D${VARIABLE}")
25 endif()
26 endmacro()
27
28 # For other curl specific tests, use this macro.
29 macro(curl_internal_test CURL_TEST)
30 if(NOT DEFINED "${CURL_TEST}")
31 set(MACRO_CHECK_FUNCTION_DEFINITIONS
32 "-D${CURL_TEST} ${CURL_TEST_DEFINES} ${CMAKE_REQUIRED_FLAGS}")
33 if(CMAKE_REQUIRED_LIBRARIES)
34 set(CURL_TEST_ADD_LIBRARIES
35 "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
36 endif()
37
38 message(STATUS "Performing Curl Test ${CURL_TEST}")
39 try_compile(${CURL_TEST}
40 ${CMAKE_BINARY_DIR}
41 ${CMAKE_CURRENT_SOURCE_DIR}/CMake/CurlTests.c
42 CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
43 "${CURL_TEST_ADD_LIBRARIES}"
44 OUTPUT_VARIABLE OUTPUT)
45 if(${CURL_TEST})
46 set(${CURL_TEST} 1 CACHE INTERNAL "Curl test ${FUNCTION}")
47 message(STATUS "Performing Curl Test ${CURL_TEST} - Success")
48 file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
49 "Performing Curl Test ${CURL_TEST} passed with the following output:\n"
50 "${OUTPUT}\n")
51 else()
52 message(STATUS "Performing Curl Test ${CURL_TEST} - Failed")
53 set(${CURL_TEST} "" CACHE INTERNAL "Curl test ${FUNCTION}")
54 file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
55 "Performing Curl Test ${CURL_TEST} failed with the following output:\n"
56 "${OUTPUT}\n")
57 endif()
58 endif()
59 endmacro()
60
61 macro(curl_nroff_check)
62 find_program(NROFF NAMES gnroff nroff)
63 if(NROFF)
64 # Need a way to write to stdin, this will do
65 file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt" "test")
66 # Tests for a valid nroff option to generate a manpage
67 foreach(_MANOPT "-man" "-mandoc")
68 execute_process(COMMAND "${NROFF}" ${_MANOPT}
69 OUTPUT_VARIABLE NROFF_MANOPT_OUTPUT
70 INPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt"
71 ERROR_QUIET)
72 # Save the option if it was valid
73 if(NROFF_MANOPT_OUTPUT)
74 message("Found *nroff option: -- ${_MANOPT}")
75 set(NROFF_MANOPT ${_MANOPT})
76 set(NROFF_USEFUL ON)
77 break()
78 endif()
79 endforeach()
80 # No need for the temporary file
81 file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt")
82 if(NOT NROFF_USEFUL)
83 message(WARNING "Found no *nroff option to get plaintext from man pages")
84 endif()
85 else()
86 message(WARNING "Found no *nroff program")
87 endif()
88 endmacro()