blob: e6004ceaef4e1d566e78997bafc3206d6cb1e7ce [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001set(EXE_NAME curl)
2
3if(USE_MANUAL)
4 # Use the C locale to ensure that only ASCII characters appear in the
5 # embedded text. NROFF and MANOPT are set in the parent CMakeLists.txt
6 add_custom_command(
7 OUTPUT tool_hugehelp.c
8 COMMAND ${CMAKE_COMMAND} -E echo "#include \"tool_setup.h\"" > tool_hugehelp.c
9 COMMAND ${CMAKE_COMMAND} -E echo "#ifndef HAVE_LIBZ" >> tool_hugehelp.c
10 COMMAND env LC_ALL=C "${NROFF}" ${NROFF_MANOPT}
11 "${CURL_BINARY_DIR}/docs/curl.1" |
12 "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl"
13 "${CURL_SOURCE_DIR}/docs/MANUAL" >> tool_hugehelp.c
14 COMMAND ${CMAKE_COMMAND} -E echo "#else" >> tool_hugehelp.c
15 COMMAND env LC_ALL=C "${NROFF}" ${NROFF_MANOPT}
16 "${CURL_BINARY_DIR}/docs/curl.1" |
17 "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl" -c
18 "${CURL_SOURCE_DIR}/docs/MANUAL" >> tool_hugehelp.c
19 COMMAND ${CMAKE_COMMAND} -E echo "#endif /* HAVE_LIBZ */" >> tool_hugehelp.c
20 DEPENDS
21 "${CURL_SOURCE_DIR}/docs/MANUAL"
22 generate-curl.1
23 "${CURL_BINARY_DIR}/docs/curl.1"
24 "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl"
25 "${CMAKE_CURRENT_SOURCE_DIR}/tool_hugehelp.h"
26 VERBATIM)
27else()
28 add_custom_command(
29 OUTPUT tool_hugehelp.c
30 COMMAND ${CMAKE_COMMAND} -E echo "/* built-in manual is disabled, blank function */" > tool_hugehelp.c
31 COMMAND ${CMAKE_COMMAND} -E echo "#include \"tool_hugehelp.h\"" >> tool_hugehelp.c
32 COMMAND ${CMAKE_COMMAND} -E echo "void hugehelp(void) {}" >> tool_hugehelp.c
33 DEPENDS
34 "${CMAKE_CURRENT_SOURCE_DIR}/tool_hugehelp.h"
35 VERBATIM)
36
37endif()
38
39transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
40include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake)
41
42if(MSVC)
43 list(APPEND CURL_SOURCE curl.rc)
44endif()
45
46# CURL_FILES comes from Makefile.inc
47add_executable(
48 ${EXE_NAME}
49 ${CURL_FILES}
50 )
51
52source_group("curlX source files" FILES ${CURLX_CFILES})
53source_group("curl source files" FILES ${CURL_CFILES})
54source_group("curl header files" FILES ${CURL_HFILES})
55
56include_directories(
57 ${CURL_SOURCE_DIR}/lib # To be able to reach "curl_setup_once.h"
58 ${CURL_BINARY_DIR}/lib # To be able to reach "curl_config.h"
59 ${CURL_BINARY_DIR}/include # To be able to reach "curl/curlbuild.h"
60 # This is needed as tool_hugehelp.c is generated in the binary dir
61 ${CURL_SOURCE_DIR}/src # To be able to reach "tool_hugehelp.h"
62 )
63
64#Build curl executable
65target_link_libraries( ${EXE_NAME} libcurl ${CURL_LIBS})
66
67################################################################################
68
69#SET_TARGET_PROPERTIES(${EXE_NAME} ARCHIVE_OUTPUT_DIRECTORY "blah blah blah")
70#SET_TARGET_PROPERTIES(${EXE_NAME} RUNTIME_OUTPUT_DIRECTORY "blah blah blah")
71#SET_TARGET_PROPERTIES(${EXE_NAME} LIBRARY_OUTPUT_DIRECTORY "blah blah blah")
72
73# Add the postfix to the executable since it is not added automatically as for modules and shared libraries
74set_target_properties(${EXE_NAME} PROPERTIES
75 DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
76
77#INCLUDE(ModuleInstall OPTIONAL)
78
79install(TARGETS ${EXE_NAME} DESTINATION bin)