CMakeLists.txt 4.2 KB

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