diff options
author | oakes <zsoakes@gmail.com> | 2014-11-30 21:22:46 -0500 |
---|---|---|
committer | oakes <zsoakes@gmail.com> | 2014-12-12 14:48:39 -0500 |
commit | dd9e5a3d7a829cd057cc9ea0865cd3fc9d9d2054 (patch) | |
tree | da50db84a7dadd13375bf72155998cbac352aa8b | |
parent | d5741e512402b13f9b0f75e081bf1027e1c577f0 (diff) | |
download | rneovim-dd9e5a3d7a829cd057cc9ea0865cd3fc9d9d2054.tar.gz rneovim-dd9e5a3d7a829cd057cc9ea0865cd3fc9d9d2054.tar.bz2 rneovim-dd9e5a3d7a829cd057cc9ea0865cd3fc9d9d2054.zip |
Allow building as a static -fPIC library
-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 |
4 files changed, 18 insertions, 1 deletions
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 |