• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#***************************************************************************
2#                                  _   _ ____  _
3#  Project                     ___| | | |  _ \| |
4#                             / __| | | | |_) | |
5#                            | (__| |_| |  _ <| |___
6#                             \___|\___/|_| \_\_____|
7#
8# Copyright (C) 1998 - 2021, 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.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###########################################################################
22set(EXE_NAME curl)
23
24if(USE_MANUAL)
25  # Use the C locale to ensure that only ASCII characters appear in the
26  # embedded text. NROFF and MANOPT are set in the parent CMakeLists.txt
27  add_custom_command(
28    OUTPUT tool_hugehelp.c
29    COMMAND ${CMAKE_COMMAND} -E echo "#include \"tool_setup.h\"" > tool_hugehelp.c
30    COMMAND ${CMAKE_COMMAND} -E echo "#ifndef HAVE_LIBZ" >> tool_hugehelp.c
31    COMMAND env LC_ALL=C "${NROFF}" ${NROFF_MANOPT}
32            "${CURL_BINARY_DIR}/docs/curl.1" |
33            "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl" >> tool_hugehelp.c
34    COMMAND ${CMAKE_COMMAND} -E echo "#else" >> tool_hugehelp.c
35    COMMAND env LC_ALL=C "${NROFF}" ${NROFF_MANOPT}
36            "${CURL_BINARY_DIR}/docs/curl.1" |
37            "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl" -c >> tool_hugehelp.c
38    COMMAND ${CMAKE_COMMAND} -E echo "#endif /* HAVE_LIBZ */" >> tool_hugehelp.c
39    DEPENDS
40      generate-curl.1
41      "${CURL_BINARY_DIR}/docs/curl.1"
42      "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl"
43      "${CMAKE_CURRENT_SOURCE_DIR}/tool_hugehelp.h"
44    VERBATIM)
45else()
46  add_custom_command(
47    OUTPUT tool_hugehelp.c
48    COMMAND ${CMAKE_COMMAND} -E echo "/* built-in manual is disabled, blank function */" > tool_hugehelp.c
49    COMMAND ${CMAKE_COMMAND} -E echo "#include \"tool_hugehelp.h\"" >> tool_hugehelp.c
50    COMMAND ${CMAKE_COMMAND} -E echo "void hugehelp(void) {}" >> tool_hugehelp.c
51    DEPENDS
52      "${CMAKE_CURRENT_SOURCE_DIR}/tool_hugehelp.h"
53    VERBATIM)
54
55endif()
56
57transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
58include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake)
59
60if(MSVC)
61  list(APPEND CURL_FILES curl.rc)
62endif()
63
64# CURL_FILES comes from Makefile.inc
65add_executable(
66  ${EXE_NAME}
67  ${CURL_FILES}
68  )
69
70add_executable(
71  ${PROJECT_NAME}::${EXE_NAME}
72  ALIAS ${EXE_NAME}
73  )
74
75if(CURL_HAS_LTO)
76  set_target_properties(${EXE_NAME} PROPERTIES
77    INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE
78    INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO TRUE)
79endif()
80
81if(ENABLE_UNICODE AND MINGW)
82  target_link_libraries(${EXE_NAME} -municode)
83  # GCC doesn't know about wmain
84  set_source_files_properties(tool_main.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes -Wno-missing-declarations")
85endif()
86
87source_group("curlX source files" FILES ${CURLX_CFILES})
88source_group("curl source files" FILES ${CURL_CFILES})
89source_group("curl header files" FILES ${CURL_HFILES})
90
91include_directories(
92  ${CURL_SOURCE_DIR}/lib        # To be able to reach "curl_setup_once.h"
93  ${CURL_BINARY_DIR}/lib        # To be able to reach "curl_config.h"
94  ${CURL_BINARY_DIR}/include    # To be able to reach "curl/curl.h"
95  # This is needed as tool_hugehelp.c is generated in the binary dir
96  ${CURL_SOURCE_DIR}/src        # To be able to reach "tool_hugehelp.h"
97  )
98
99#Build curl executable
100target_link_libraries(${EXE_NAME} libcurl ${CURL_LIBS})
101
102################################################################################
103
104#SET_TARGET_PROPERTIES(${EXE_NAME} ARCHIVE_OUTPUT_DIRECTORY "blah blah blah")
105#SET_TARGET_PROPERTIES(${EXE_NAME} RUNTIME_OUTPUT_DIRECTORY "blah blah blah")
106#SET_TARGET_PROPERTIES(${EXE_NAME} LIBRARY_OUTPUT_DIRECTORY "blah blah blah")
107
108#INCLUDE(ModuleInstall OPTIONAL)
109
110install(TARGETS ${EXE_NAME} EXPORT ${TARGETS_EXPORT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
111export(TARGETS ${EXE_NAME}
112       APPEND FILE ${PROJECT_BINARY_DIR}/curl-target.cmake
113       NAMESPACE ${PROJECT_NAME}::
114)
115