Allow building as a static -fPIC library

This commit is contained in:
oakes 2014-11-30 21:22:46 -05:00
parent d5741e5124
commit dd9e5a3d7a
4 changed files with 18 additions and 1 deletions

View File

@ -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)

View File

@ -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

View File

@ -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})

View File

@ -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