CMakeLists.txt 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. set(EXE_NAME curl)
  2. if(USE_MANUAL)
  3. # Use the C locale to ensure that only ASCII characters appear in the
  4. # embedded text. NROFF and MANOPT are set in the parent CMakeLists.txt
  5. add_custom_command(
  6. OUTPUT tool_hugehelp.c
  7. COMMAND ${CMAKE_COMMAND} -E echo "#include \"tool_setup.h\"" > tool_hugehelp.c
  8. COMMAND ${CMAKE_COMMAND} -E echo "#ifndef HAVE_LIBZ" >> tool_hugehelp.c
  9. COMMAND env LC_ALL=C "${NROFF}" ${NROFF_MANOPT}
  10. "${CURL_BINARY_DIR}/docs/curl.1" |
  11. "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl" >> tool_hugehelp.c
  12. COMMAND ${CMAKE_COMMAND} -E echo "#else" >> tool_hugehelp.c
  13. COMMAND env LC_ALL=C "${NROFF}" ${NROFF_MANOPT}
  14. "${CURL_BINARY_DIR}/docs/curl.1" |
  15. "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl" -c >> tool_hugehelp.c
  16. COMMAND ${CMAKE_COMMAND} -E echo "#endif /* HAVE_LIBZ */" >> tool_hugehelp.c
  17. DEPENDS
  18. generate-curl.1
  19. "${CURL_BINARY_DIR}/docs/curl.1"
  20. "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl"
  21. "${CMAKE_CURRENT_SOURCE_DIR}/tool_hugehelp.h"
  22. VERBATIM)
  23. else()
  24. add_custom_command(
  25. OUTPUT tool_hugehelp.c
  26. COMMAND ${CMAKE_COMMAND} -E echo "/* built-in manual is disabled, blank function */" > tool_hugehelp.c
  27. COMMAND ${CMAKE_COMMAND} -E echo "#include \"tool_hugehelp.h\"" >> tool_hugehelp.c
  28. COMMAND ${CMAKE_COMMAND} -E echo "void hugehelp(void) {}" >> tool_hugehelp.c
  29. DEPENDS
  30. "${CMAKE_CURRENT_SOURCE_DIR}/tool_hugehelp.h"
  31. VERBATIM)
  32. endif()
  33. transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
  34. include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake)
  35. if(MSVC)
  36. list(APPEND CURL_FILES curl.rc)
  37. endif()
  38. # CURL_FILES comes from Makefile.inc
  39. add_executable(
  40. ${EXE_NAME}
  41. ${CURL_FILES}
  42. )
  43. source_group("curlX source files" FILES ${CURLX_CFILES})
  44. source_group("curl source files" FILES ${CURL_CFILES})
  45. source_group("curl header files" FILES ${CURL_HFILES})
  46. include_directories(
  47. ${CURL_SOURCE_DIR}/lib # To be able to reach "curl_setup_once.h"
  48. ${CURL_BINARY_DIR}/lib # To be able to reach "curl_config.h"
  49. ${CURL_BINARY_DIR}/include # To be able to reach "curl/curl.h"
  50. # This is needed as tool_hugehelp.c is generated in the binary dir
  51. ${CURL_SOURCE_DIR}/src # To be able to reach "tool_hugehelp.h"
  52. )
  53. #Build curl executable
  54. target_link_libraries(${EXE_NAME} libcurl ${CURL_LIBS})
  55. ################################################################################
  56. #SET_TARGET_PROPERTIES(${EXE_NAME} ARCHIVE_OUTPUT_DIRECTORY "blah blah blah")
  57. #SET_TARGET_PROPERTIES(${EXE_NAME} RUNTIME_OUTPUT_DIRECTORY "blah blah blah")
  58. #SET_TARGET_PROPERTIES(${EXE_NAME} LIBRARY_OUTPUT_DIRECTORY "blah blah blah")
  59. #INCLUDE(ModuleInstall OPTIONAL)
  60. install(TARGETS ${EXE_NAME} EXPORT ${TARGETS_EXPORT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
  61. export(TARGETS ${EXE_NAME}
  62. APPEND FILE ${PROJECT_BINARY_DIR}/curl-target.cmake
  63. NAMESPACE CURL::
  64. )