BuildLibvterm.cmake 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. include(CMakeParseArguments)
  2. # BuildLibvterm(CONFIGURE_COMMAND ... BUILD_COMMAND ... INSTALL_COMMAND ...)
  3. # Failing to pass a command argument will result in no command being run
  4. function(BuildLibvterm)
  5. cmake_parse_arguments(_libvterm
  6. ""
  7. ""
  8. "PATCH_COMMAND;CONFIGURE_COMMAND;BUILD_COMMAND;INSTALL_COMMAND"
  9. ${ARGN})
  10. if(NOT _libvterm_CONFIGURE_COMMAND AND NOT _libvterm_BUILD_COMMAND
  11. AND NOT _libvterm_INSTALL_COMMAND)
  12. message(FATAL_ERROR "Must pass at least one of CONFIGURE_COMMAND, BUILD_COMMAND, INSTALL_COMMAND")
  13. endif()
  14. ExternalProject_Add(libvterm
  15. PREFIX ${DEPS_BUILD_DIR}
  16. URL ${LIBVTERM_URL}
  17. DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/libvterm
  18. DOWNLOAD_COMMAND ${CMAKE_COMMAND}
  19. -DPREFIX=${DEPS_BUILD_DIR}
  20. -DDOWNLOAD_DIR=${DEPS_DOWNLOAD_DIR}/libvterm
  21. -DURL=${LIBVTERM_URL}
  22. -DEXPECTED_SHA256=${LIBVTERM_SHA256}
  23. -DTARGET=libvterm
  24. -DUSE_EXISTING_SRC_DIR=${USE_EXISTING_SRC_DIR}
  25. -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake
  26. PATCH_COMMAND "${_libvterm_PATCH_COMMAND}"
  27. BUILD_IN_SOURCE 1
  28. CONFIGURE_COMMAND "${_libvterm_CONFIGURE_COMMAND}"
  29. BUILD_COMMAND "${_libvterm_BUILD_COMMAND}"
  30. INSTALL_COMMAND "${_libvterm_INSTALL_COMMAND}")
  31. endfunction()
  32. if(WIN32)
  33. if(MSVC)
  34. set(LIBVTERM_PATCH_COMMAND
  35. ${GIT_EXECUTABLE} -C ${DEPS_BUILD_DIR}/src/libvterm init
  36. COMMAND ${GIT_EXECUTABLE} -C ${DEPS_BUILD_DIR}/src/libvterm apply --ignore-whitespace
  37. ${CMAKE_CURRENT_SOURCE_DIR}/patches/libvterm-Remove-VLAs-for-MSVC.patch)
  38. endif()
  39. set(LIBVTERM_CONFIGURE_COMMAND ${CMAKE_COMMAND} -E copy
  40. ${CMAKE_CURRENT_SOURCE_DIR}/cmake/LibvtermCMakeLists.txt
  41. ${DEPS_BUILD_DIR}/src/libvterm/CMakeLists.txt
  42. COMMAND ${CMAKE_COMMAND} -E copy
  43. ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Libvterm-tbl2inc_c.cmake
  44. ${DEPS_BUILD_DIR}/src/libvterm/tbl2inc_c.cmake
  45. COMMAND ${CMAKE_COMMAND} ${DEPS_BUILD_DIR}/src/libvterm
  46. -DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
  47. -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
  48. "-DCMAKE_C_FLAGS:STRING=${CMAKE_C_COMPILER_ARG1} -fPIC"
  49. -DCMAKE_GENERATOR=${CMAKE_GENERATOR})
  50. set(LIBVTERM_BUILD_COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE})
  51. set(LIBVTERM_INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config ${CMAKE_BUILD_TYPE})
  52. else()
  53. set(LIBVTERM_INSTALL_COMMAND ${MAKE_PRG} CC=${DEPS_C_COMPILER}
  54. PREFIX=${DEPS_INSTALL_DIR}
  55. CFLAGS=-fPIC
  56. LDFLAGS+=-static
  57. ${DEFAULT_MAKE_CFLAGS}
  58. install)
  59. endif()
  60. BuildLibvterm(PATCH_COMMAND ${LIBVTERM_PATCH_COMMAND}
  61. CONFIGURE_COMMAND ${LIBVTERM_CONFIGURE_COMMAND}
  62. BUILD_COMMAND ${LIBVTERM_BUILD_COMMAND}
  63. INSTALL_COMMAND ${LIBVTERM_INSTALL_COMMAND})
  64. list(APPEND THIRD_PARTY_DEPS libvterm)