aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt60
1 files changed, 40 insertions, 20 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 521ce54..06edb6a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,27 +1,8 @@
cmake_minimum_required(VERSION 3.0.2)
+include(ExternalProject)
project(emacs-libvterm C)
-# Look for the header file.
-find_path(LIBVTERM_INCLUDE_DIR NAMES
- vterm.h
- )
-
-if(NOT LIBVTERM_INCLUDE_DIR)
- message(FATAL_ERROR "vterm.h not found")
-endif()
-
-find_library(LIBVTERM_LIBRARY NAMES
- vterm
- libvterm
- )
-
-if(NOT LIBVTERM_LIBRARY)
- message(FATAL_ERROR "libvterm not found")
-endif()
-
-include_directories(${LIBVTERM_INCLUDE_DIR})
-
add_library(vterm-module MODULE vterm-module.c utf8.c elisp.c)
set_target_properties(vterm-module PROPERTIES
C_STANDARD 99
@@ -30,6 +11,45 @@ set_target_properties(vterm-module PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}
)
+# Look for the header file.
+option(USE_SYSTEM_LIBVTERM "Use system libvterm instead of the vendored version." OFF)
+
+if(USE_SYSTEM_LIBVTERM)
+ find_path(LIBVTERM_INCLUDE_DIR NAMES
+ vterm.h
+ )
+
+ if(NOT LIBVTERM_INCLUDE_DIR)
+ message(FATAL_ERROR "vterm.h not found")
+ endif()
+
+ find_library(LIBVTERM_LIBRARY NAMES
+ vterm
+ libvterm
+ )
+
+ if(NOT LIBVTERM_LIBRARY)
+ message(FATAL_ERROR "libvterm not found")
+ endif()
+else()
+ ExternalProject_add(libvterm
+ GIT_REPOSITORY https://github.com/neovim/libvterm.git
+ GIT_TAG a6293a0e033e7e86c74889b4527787993656883a
+ CONFIGURE_COMMAND ""
+ BUILD_COMMAND make "CFLAGS='-fPIC'"
+ BUILD_IN_SOURCE ON
+ INSTALL_COMMAND "")
+
+ ExternalProject_Get_property(libvterm SOURCE_DIR)
+
+ set(LIBVTERM_INCLUDE_DIR ${SOURCE_DIR}/include)
+ set(LIBVTERM_LIBRARY ${SOURCE_DIR}/.libs/libvterm.a)
+
+ add_dependencies(vterm-module libvterm)
+endif()
+
+include_directories(${LIBVTERM_INCLUDE_DIR})
+
# Link with libvterm
target_link_libraries(vterm-module ${LIBVTERM_LIBRARY})