diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2014-12-13 13:29:14 -0500 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2014-12-13 13:29:14 -0500 |
commit | 0ba6cb2f5cfe49ee1ee66c6246a77947af74ae5e (patch) | |
tree | a089061fe1212960b868408b9699e5b02f792880 | |
parent | 677a3f42c0f0821ddeed34728c8708fa4d0742cc (diff) | |
parent | 975f4ec3505b8bc2321ab2cb554aff40f2db614b (diff) | |
download | rneovim-0ba6cb2f5cfe49ee1ee66c6246a77947af74ae5e.tar.gz rneovim-0ba6cb2f5cfe49ee1ee66c6246a77947af74ae5e.tar.bz2 rneovim-0ba6cb2f5cfe49ee1ee66c6246a77947af74ae5e.zip |
Merge pull request #1586 from oakes/master
libnvim: Allow building as a static library
-rw-r--r-- | .ci/gcc-32.sh | 3 | ||||
-rw-r--r-- | .ci/gcc.sh | 3 | ||||
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | src/nvim/CMakeLists.txt | 8 | ||||
-rw-r--r-- | src/nvim/main.c | 4 |
6 files changed, 24 insertions, 1 deletions
diff --git a/.ci/gcc-32.sh b/.ci/gcc-32.sh index e0448894ab..9d879b7009 100644 --- a/.ci/gcc-32.sh +++ b/.ci/gcc-32.sh @@ -26,6 +26,9 @@ CMAKE_EXTRA_FLAGS="-DTRAVIS_CI_BUILD=ON \ $MAKE_CMD CMAKE_EXTRA_FLAGS="$CMAKE_EXTRA_FLAGS" nvim build/bin/nvim --version +# Build library. +$MAKE_CMD CMAKE_EXTRA_FLAGS="$CMAKE_EXTRA_FLAGS" libnvim + # Run unittests. $MAKE_CMD unittest diff --git a/.ci/gcc.sh b/.ci/gcc.sh index ad9cbd33b0..188cf5e5e8 100644 --- a/.ci/gcc.sh +++ b/.ci/gcc.sh @@ -23,6 +23,9 @@ CMAKE_EXTRA_FLAGS="-DTRAVIS_CI_BUILD=ON \ $MAKE_CMD CMAKE_EXTRA_FLAGS="$CMAKE_EXTRA_FLAGS" nvim build/bin/nvim --version +# Build library. +$MAKE_CMD CMAKE_EXTRA_FLAGS="$CMAKE_EXTRA_FLAGS" libnvim + # Run unittests. make unittest diff --git a/CMakeLists.txt b/CMakeLists.txt index d2b5217658..20d653a082 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -185,6 +185,8 @@ set(CMAKE_THREAD_PREFER_PTHREAD ON) find_package(Threads REQUIRED) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) # Find Lua interpreter include(LuaHelpers) @@ -51,6 +51,9 @@ all: nvim nvim: build/.ran-cmake deps +$(BUILD_CMD) -C build +libnvim: build/.ran-cmake deps + +$(BUILD_CMD) -C build libnvim + cmake: touch CMakeLists.txt $(MAKE) build/.ran-cmake @@ -95,4 +98,4 @@ distclean: clean install: | nvim +$(BUILD_CMD) -C build install -.PHONY: test functionaltest unittest clean distclean nvim cmake deps install +.PHONY: test functionaltest unittest clean distclean nvim libnvim cmake deps install diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 8c05c6a2b2..8c0979026a 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -208,6 +208,14 @@ if(SANITIZE) set_property(TARGET nvim APPEND_STRING PROPERTY LINK_FLAGS "-fsanitize=address -fsanitize=undefined ") endif() +add_library(libnvim STATIC EXCLUDE_FROM_ALL ${NEOVIM_GENERATED_SOURCES} + ${NEOVIM_SOURCES} ${NEOVIM_HEADERS}) +target_link_libraries(libnvim ${NVIM_LINK_LIBRARIES}) +set_target_properties(libnvim PROPERTIES + POSITION_INDEPENDENT_CODE ON + OUTPUT_NAME nvim) +set_property(TARGET libnvim APPEND_STRING PROPERTY COMPILE_FLAGS " -DMAKE_LIB ") + add_library(nvim-test MODULE EXCLUDE_FROM_ALL ${NEOVIM_GENERATED_SOURCES} ${NEOVIM_SOURCES} ${NEOVIM_HEADERS}) target_link_libraries(nvim-test ${NVIM_LINK_LIBRARIES}) diff --git a/src/nvim/main.c b/src/nvim/main.c index c806431872..8c6df6a212 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -194,7 +194,11 @@ void early_init(void) } #ifndef NO_VIM_MAIN /* skip this for unittests */ +#ifdef MAKE_LIB +int nvim_main(int argc, char **argv) +#else int main(int argc, char **argv) +#endif { char_u *fname = NULL; /* file name from command line */ mparm_T params; /* various parameters passed between |