File size: 4,801 Bytes
910a777 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
#*************************************************************************** # _ _ ____ _ # Project ___| | | | _ \| | # / __| | | | |_) | | # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # # Copyright (C) Daniel Stenberg, <[email protected]>, et al. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at https://curl.se/docs/copyright.html. # # You may opt to use, copy, modify, merge, publish, distribute and/or sell # copies of the Software, and permit persons to whom the Software is # furnished to do so, under the terms of the COPYING file. # # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY # KIND, either express or implied. # # SPDX-License-Identifier: curl # ########################################################################### set(EXE_NAME curl) add_definitions("-DBUILDING_CURL") if(ENABLE_CURL_MANUAL AND HAVE_MANUAL_TOOLS) add_definitions("-DUSE_MANUAL") add_custom_command( OUTPUT "tool_hugehelp.c" COMMAND ${CMAKE_COMMAND} -E echo "#include \"tool_setup.h\"" > "tool_hugehelp.c" COMMAND ${CMAKE_COMMAND} -E echo "#ifndef HAVE_LIBZ" >> "tool_hugehelp.c" COMMAND "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl" < "${CURL_ASCIIPAGE}" >> "tool_hugehelp.c" COMMAND ${CMAKE_COMMAND} -E echo "#else" >> "tool_hugehelp.c" COMMAND "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl" -c < "${CURL_ASCIIPAGE}" >> "tool_hugehelp.c" COMMAND ${CMAKE_COMMAND} -E echo "#endif /* HAVE_LIBZ */" >> "tool_hugehelp.c" DEPENDS generate-curl.1 "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl" "${CMAKE_CURRENT_SOURCE_DIR}/tool_hugehelp.h" "${CURL_ASCIIPAGE}" VERBATIM) else() add_custom_command( OUTPUT "tool_hugehelp.c" COMMAND ${CMAKE_COMMAND} -E echo "#include \"tool_hugehelp.h\"" > "tool_hugehelp.c" DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/tool_hugehelp.h" VERBATIM) endif() # Get 'CURL_CFILES', 'CURLX_CFILES', 'CURL_HFILES', 'CURLTOOL_LIBCURL_CFILES' variables transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake") include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake") if(CURL_CA_EMBED_SET) if(PERL_FOUND) add_definitions("-DCURL_CA_EMBED") add_custom_command( OUTPUT "tool_ca_embed.c" COMMAND "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/mk-file-embed.pl" --var curl_ca_embed < "${CURL_CA_EMBED}" > "tool_ca_embed.c" DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/mk-file-embed.pl" "${CURL_CA_EMBED}" VERBATIM) list(APPEND CURL_CFILES "tool_ca_embed.c") else() message(WARNING "Perl not found. Will not embed the CA bundle.") endif() endif() if(WIN32) list(APPEND CURL_CFILES "curl.rc") endif() if(BUILD_STATIC_CURL) set(CURLX_CFILES ${CURLTOOL_LIBCURL_CFILES}) endif() if(ENABLE_CURLDEBUG) # We must compile this source separately to avoid memdebug.h redefinitions # applying to them. set_source_files_properties("../lib/curl_multibyte.c" PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON) endif() add_executable( ${EXE_NAME} ${CURL_CFILES} ${CURLX_CFILES} ${CURL_HFILES} ) add_executable( ${PROJECT_NAME}::${EXE_NAME} ALIAS ${EXE_NAME} ) add_library( curltool # special libcurltool library just for unittests STATIC EXCLUDE_FROM_ALL ${CURL_CFILES} ${CURLTOOL_LIBCURL_CFILES} ${CURL_HFILES} ) target_compile_definitions(curltool PUBLIC "UNITTESTS" "CURL_STATICLIB") target_link_libraries(curltool PRIVATE ${CURL_LIBS}) if(CURL_HAS_LTO) set_target_properties(${EXE_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO TRUE) endif() if(ENABLE_UNICODE AND MINGW) target_link_libraries(${EXE_NAME} "-municode") endif() source_group("curlX source files" FILES ${CURLX_CFILES}) source_group("curl source files" FILES ${CURL_CFILES}) source_group("curl header files" FILES ${CURL_HFILES}) include_directories( "${PROJECT_BINARY_DIR}/lib" # for "curl_config.h" "${PROJECT_SOURCE_DIR}/lib" # for "curl_setup.h" # This is needed as tool_hugehelp.c is generated in the binary dir "${PROJECT_SOURCE_DIR}/src" # for "tool_hugehelp.h" ) # Build curl executable target_link_libraries(${EXE_NAME} ${LIB_SELECTED_FOR_EXE} ${CURL_LIBS}) ################################################################################ install(TARGETS ${EXE_NAME} EXPORT ${TARGETS_EXPORT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) export(TARGETS ${EXE_NAME} FILE "${PROJECT_BINARY_DIR}/curl-target.cmake" NAMESPACE ${PROJECT_NAME}:: ) |