mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
Merge pull request #18607 from dundargoc/build/mingw
restore mingw in cmake
This commit is contained in:
commit
4fab52908b
@ -108,7 +108,14 @@ endif()
|
|||||||
|
|
||||||
option(ENABLE_LIBINTL "enable libintl" ON)
|
option(ENABLE_LIBINTL "enable libintl" ON)
|
||||||
option(ENABLE_LIBICONV "enable libiconv" ON)
|
option(ENABLE_LIBICONV "enable libiconv" ON)
|
||||||
option(ENABLE_LTO "enable link time optimization" ON)
|
if (MINGW)
|
||||||
|
# Disable LTO by default as it may not compile
|
||||||
|
# See https://github.com/Alexpux/MINGW-packages/issues/3516
|
||||||
|
# and https://github.com/neovim/neovim/pull/8654#issuecomment-402316672
|
||||||
|
option(ENABLE_LTO "enable link time optimization" OFF)
|
||||||
|
else()
|
||||||
|
option(ENABLE_LTO "enable link time optimization" ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
message(STATUS "CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}")
|
message(STATUS "CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}")
|
||||||
|
|
||||||
@ -315,6 +322,10 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(MINGW)
|
||||||
|
# Use POSIX compatible stdio in Mingw
|
||||||
|
add_definitions(-D__USE_MINGW_ANSI_STDIO)
|
||||||
|
endif()
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
# Windows Vista is the minimum supported version
|
# Windows Vista is the minimum supported version
|
||||||
add_definitions(-D_WIN32_WINNT=0x0600)
|
add_definitions(-D_WIN32_WINNT=0x0600)
|
||||||
|
@ -17,6 +17,8 @@ find_path(LUAJIT_INCLUDE_DIR luajit.h
|
|||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
list(APPEND LUAJIT_NAMES lua51)
|
list(APPEND LUAJIT_NAMES lua51)
|
||||||
|
elseif(MINGW)
|
||||||
|
list(APPEND LUAJIT_NAMES libluajit libluajit-5.1)
|
||||||
else()
|
else()
|
||||||
list(APPEND LUAJIT_NAMES luajit-5.1)
|
list(APPEND LUAJIT_NAMES luajit-5.1)
|
||||||
endif()
|
endif()
|
||||||
|
9
third-party/CMakeLists.txt
vendored
9
third-party/CMakeLists.txt
vendored
@ -93,6 +93,15 @@ if(CMAKE_GENERATOR MATCHES "Makefiles")
|
|||||||
set(MAKE_PRG "$(MAKE)")
|
set(MAKE_PRG "$(MAKE)")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(MINGW AND CMAKE_GENERATOR MATCHES "Ninja")
|
||||||
|
find_program(MAKE_PRG NAMES mingw32-make)
|
||||||
|
if(NOT MAKE_PRG)
|
||||||
|
message(FATAL_ERROR "GNU Make for mingw32 is required to build the dependencies.")
|
||||||
|
else()
|
||||||
|
message(STATUS "Found GNU Make for mingw32: ${MAKE_PRG}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if(CMAKE_C_COMPILER_ARG1)
|
if(CMAKE_C_COMPILER_ARG1)
|
||||||
set(DEPS_C_COMPILER "${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}")
|
set(DEPS_C_COMPILER "${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}")
|
||||||
else()
|
else()
|
||||||
|
13
third-party/cmake/BuildLibuv.cmake
vendored
13
third-party/cmake/BuildLibuv.cmake
vendored
@ -45,11 +45,24 @@ if(UNIX)
|
|||||||
CONFIGURE_COMMAND ${UNIX_CFGCMD} MAKE=${MAKE_PRG}
|
CONFIGURE_COMMAND ${UNIX_CFGCMD} MAKE=${MAKE_PRG}
|
||||||
INSTALL_COMMAND ${MAKE_PRG} V=1 install)
|
INSTALL_COMMAND ${MAKE_PRG} V=1 install)
|
||||||
|
|
||||||
|
elseif(MINGW AND CMAKE_CROSSCOMPILING)
|
||||||
|
# Build libuv for the host
|
||||||
|
BuildLibuv(TARGET libuv_host
|
||||||
|
CONFIGURE_COMMAND sh ${DEPS_BUILD_DIR}/src/libuv_host/autogen.sh && ${DEPS_BUILD_DIR}/src/libuv_host/configure --with-pic --disable-shared --prefix=${HOSTDEPS_INSTALL_DIR} CC=${HOST_C_COMPILER}
|
||||||
|
INSTALL_COMMAND ${MAKE_PRG} V=1 install)
|
||||||
|
|
||||||
|
# Build libuv for the target
|
||||||
|
BuildLibuv(
|
||||||
|
CONFIGURE_COMMAND ${UNIX_CFGCMD} --host=${CROSS_TARGET}
|
||||||
|
INSTALL_COMMAND ${MAKE_PRG} V=1 install)
|
||||||
|
|
||||||
elseif(WIN32)
|
elseif(WIN32)
|
||||||
|
|
||||||
set(UV_OUTPUT_DIR ${DEPS_BUILD_DIR}/src/libuv/${CMAKE_BUILD_TYPE})
|
set(UV_OUTPUT_DIR ${DEPS_BUILD_DIR}/src/libuv/${CMAKE_BUILD_TYPE})
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
set(BUILD_SHARED ON)
|
set(BUILD_SHARED ON)
|
||||||
|
elseif(MINGW)
|
||||||
|
set(BUILD_SHARED OFF)
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "Trying to build libuv in an unsupported system ${CMAKE_SYSTEM_NAME}/${CMAKE_C_COMPILER_ID}")
|
message(FATAL_ERROR "Trying to build libuv in an unsupported system ${CMAKE_SYSTEM_NAME}/${CMAKE_C_COMPILER_ID}")
|
||||||
endif()
|
endif()
|
||||||
|
2
third-party/cmake/BuildLua.cmake
vendored
2
third-party/cmake/BuildLua.cmake
vendored
@ -39,6 +39,8 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
|||||||
set(LUA_TARGET freebsd)
|
set(LUA_TARGET freebsd)
|
||||||
elseif(CMAKE_SYSTEM_NAME MATCHES "BSD")
|
elseif(CMAKE_SYSTEM_NAME MATCHES "BSD")
|
||||||
set(CMAKE_LUA_TARGET bsd)
|
set(CMAKE_LUA_TARGET bsd)
|
||||||
|
elseif(CMAKE_SYSTEM_NAME MATCHES "^MINGW")
|
||||||
|
set(CMAKE_LUA_TARGET mingw)
|
||||||
else()
|
else()
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
set(LUA_TARGET posix)
|
set(LUA_TARGET posix)
|
||||||
|
51
third-party/cmake/BuildLuajit.cmake
vendored
51
third-party/cmake/BuildLuajit.cmake
vendored
@ -76,6 +76,57 @@ if(UNIX)
|
|||||||
CC=${DEPS_C_COMPILER} PREFIX=${DEPS_INSTALL_DIR}
|
CC=${DEPS_C_COMPILER} PREFIX=${DEPS_INSTALL_DIR}
|
||||||
${DEPLOYMENT_TARGET})
|
${DEPLOYMENT_TARGET})
|
||||||
|
|
||||||
|
elseif(MINGW AND CMAKE_CROSSCOMPILING)
|
||||||
|
|
||||||
|
# Build luajit for the host
|
||||||
|
BuildLuaJit(TARGET luajit_host
|
||||||
|
CONFIGURE_COMMAND ""
|
||||||
|
BUILD_COMMAND ""
|
||||||
|
INSTALL_COMMAND ${INSTALLCMD_UNIX}
|
||||||
|
CC=${HOST_C_COMPILER} PREFIX=${HOSTDEPS_INSTALL_DIR})
|
||||||
|
|
||||||
|
# Build luajit for the target
|
||||||
|
BuildLuaJit(
|
||||||
|
# Similar to Unix + cross - fPIC
|
||||||
|
INSTALL_COMMAND
|
||||||
|
${MAKE_PRG} PREFIX=${DEPS_INSTALL_DIR}
|
||||||
|
BUILDMODE=static install
|
||||||
|
TARGET_SYS=${CMAKE_SYSTEM_NAME}
|
||||||
|
CROSS=${CROSS_TARGET}-
|
||||||
|
HOST_CC=${HOST_C_COMPILER} HOST_CFLAGS=${HOST_C_FLAGS}
|
||||||
|
HOST_LDFLAGS=${HOST_EXE_LINKER_FLAGS}
|
||||||
|
FILE_T=luajit.exe
|
||||||
|
Q=
|
||||||
|
INSTALL_TSYMNAME=luajit.exe)
|
||||||
|
|
||||||
|
elseif(MINGW)
|
||||||
|
|
||||||
|
if(CMAKE_GENERATOR MATCHES "Ninja")
|
||||||
|
set(LUAJIT_MAKE_PRG ${MAKE_PRG})
|
||||||
|
else()
|
||||||
|
set(LUAJIT_MAKE_PRG ${CMAKE_MAKE_PROGRAM})
|
||||||
|
endif()
|
||||||
|
BuildLuaJit(BUILD_COMMAND ${LUAJIT_MAKE_PRG} CC=${DEPS_C_COMPILER}
|
||||||
|
PREFIX=${DEPS_INSTALL_DIR}
|
||||||
|
CFLAGS+=-DLUA_USE_APICHECK
|
||||||
|
CFLAGS+=-funwind-tables
|
||||||
|
CCDEBUG+=-g
|
||||||
|
BUILDMODE=static
|
||||||
|
# Build a DLL too
|
||||||
|
COMMAND ${LUAJIT_MAKE_PRG} CC=${DEPS_C_COMPILER} BUILDMODE=dynamic
|
||||||
|
|
||||||
|
INSTALL_COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_INSTALL_DIR}/bin
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy ${DEPS_BUILD_DIR}/src/luajit/src/luajit.exe ${DEPS_INSTALL_DIR}/bin
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy ${DEPS_BUILD_DIR}/src/luajit/src/lua51.dll ${DEPS_INSTALL_DIR}/bin
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_INSTALL_DIR}/lib
|
||||||
|
# Luarocks searches for lua51.dll in lib
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy ${DEPS_BUILD_DIR}/src/luajit/src/lua51.dll ${DEPS_INSTALL_DIR}/lib
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy ${DEPS_BUILD_DIR}/src/luajit/src/libluajit.a ${DEPS_INSTALL_DIR}/lib
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_INSTALL_DIR}/include/luajit-2.1
|
||||||
|
COMMAND ${CMAKE_COMMAND} -DFROM_GLOB=${DEPS_BUILD_DIR}/src/luajit/src/*.h -DTO=${DEPS_INSTALL_DIR}/include/luajit-2.1 -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/CopyFilesGlob.cmake
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_INSTALL_DIR}/bin/lua/jit
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${DEPS_BUILD_DIR}/src/luajit/src/jit ${DEPS_INSTALL_DIR}/bin/lua/jit
|
||||||
|
)
|
||||||
elseif(MSVC)
|
elseif(MSVC)
|
||||||
|
|
||||||
BuildLuaJit(
|
BuildLuaJit(
|
||||||
|
14
third-party/cmake/BuildLuarocks.cmake
vendored
14
third-party/cmake/BuildLuarocks.cmake
vendored
@ -56,7 +56,7 @@ endif()
|
|||||||
# Defaults to 5.1 for bundled LuaJIT/Lua.
|
# Defaults to 5.1 for bundled LuaJIT/Lua.
|
||||||
set(LUA_VERSION "5.1")
|
set(LUA_VERSION "5.1")
|
||||||
|
|
||||||
if(UNIX)
|
if(UNIX OR (MINGW AND CMAKE_CROSSCOMPILING))
|
||||||
|
|
||||||
if(USE_BUNDLED_LUAJIT)
|
if(USE_BUNDLED_LUAJIT)
|
||||||
list(APPEND LUAROCKS_OPTS
|
list(APPEND LUAROCKS_OPTS
|
||||||
@ -94,9 +94,13 @@ if(UNIX)
|
|||||||
CONFIGURE_COMMAND ${DEPS_BUILD_DIR}/src/luarocks/configure
|
CONFIGURE_COMMAND ${DEPS_BUILD_DIR}/src/luarocks/configure
|
||||||
--prefix=${HOSTDEPS_INSTALL_DIR} --force-config ${LUAROCKS_OPTS}
|
--prefix=${HOSTDEPS_INSTALL_DIR} --force-config ${LUAROCKS_OPTS}
|
||||||
INSTALL_COMMAND ${MAKE_PRG} -j1 bootstrap)
|
INSTALL_COMMAND ${MAKE_PRG} -j1 bootstrap)
|
||||||
elseif(MSVC)
|
elseif(MSVC OR MINGW)
|
||||||
|
|
||||||
|
if(MINGW)
|
||||||
|
set(COMPILER_FLAG /MW)
|
||||||
|
elseif(MSVC)
|
||||||
set(COMPILER_FLAG /MSVC)
|
set(COMPILER_FLAG /MSVC)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Ignore USE_BUNDLED_LUAJIT - always ON for native Win32
|
# Ignore USE_BUNDLED_LUAJIT - always ON for native Win32
|
||||||
BuildLuarocks(INSTALL_COMMAND install.bat /FORCECONFIG /NOREG /NOADMIN /Q /F
|
BuildLuarocks(INSTALL_COMMAND install.bat /FORCECONFIG /NOREG /NOADMIN /Q /F
|
||||||
@ -119,6 +123,9 @@ list(APPEND THIRD_PARTY_DEPS luarocks)
|
|||||||
|
|
||||||
if(USE_BUNDLED_LUAJIT)
|
if(USE_BUNDLED_LUAJIT)
|
||||||
add_dependencies(luarocks luajit)
|
add_dependencies(luarocks luajit)
|
||||||
|
if(MINGW AND CMAKE_CROSSCOMPILING)
|
||||||
|
add_dependencies(luarocks luajit_host)
|
||||||
|
endif()
|
||||||
elseif(USE_BUNDLED_LUA)
|
elseif(USE_BUNDLED_LUA)
|
||||||
add_dependencies(luarocks lua)
|
add_dependencies(luarocks lua)
|
||||||
endif()
|
endif()
|
||||||
@ -189,6 +196,9 @@ if(USE_BUNDLED_BUSTED)
|
|||||||
set(LUV_DEPS luacheck)
|
set(LUV_DEPS luacheck)
|
||||||
if(USE_BUNDLED_LUV)
|
if(USE_BUNDLED_LUV)
|
||||||
list(APPEND LUV_DEPS luv-static lua-compat-5.3)
|
list(APPEND LUV_DEPS luv-static lua-compat-5.3)
|
||||||
|
if(MINGW AND CMAKE_CROSSCOMPILING)
|
||||||
|
list(APPEND LUV_DEPS libuv_host)
|
||||||
|
endif()
|
||||||
set(LUV_ARGS "CFLAGS=-O0 -g3 -fPIC")
|
set(LUV_ARGS "CFLAGS=-O0 -g3 -fPIC")
|
||||||
if(USE_BUNDLED_LIBUV)
|
if(USE_BUNDLED_LIBUV)
|
||||||
list(APPEND LUV_ARGS LIBUV_DIR=${HOSTDEPS_INSTALL_DIR})
|
list(APPEND LUV_ARGS LIBUV_DIR=${HOSTDEPS_INSTALL_DIR})
|
||||||
|
11
third-party/cmake/BuildLuv.cmake
vendored
11
third-party/cmake/BuildLuv.cmake
vendored
@ -91,7 +91,16 @@ if(USE_BUNDLED_LIBUV)
|
|||||||
-DCMAKE_PREFIX_PATH=${DEPS_INSTALL_DIR})
|
-DCMAKE_PREFIX_PATH=${DEPS_INSTALL_DIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
if(MINGW AND CMAKE_CROSSCOMPILING)
|
||||||
|
get_filename_component(TOOLCHAIN ${CMAKE_TOOLCHAIN_FILE} REALPATH)
|
||||||
|
set(LUV_CONFIGURE_COMMAND
|
||||||
|
${LUV_CONFIGURE_COMMAND_COMMON}
|
||||||
|
# Pass toolchain
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN}
|
||||||
|
"-DCMAKE_C_FLAGS:STRING=${LUV_INCLUDE_FLAGS} -D_WIN32_WINNT=0x0600"
|
||||||
|
# Hack to avoid -rdynamic in Mingw
|
||||||
|
-DCMAKE_SHARED_LIBRARY_LINK_C_FLAGS="")
|
||||||
|
elseif(MSVC)
|
||||||
set(LUV_CONFIGURE_COMMAND
|
set(LUV_CONFIGURE_COMMAND
|
||||||
${LUV_CONFIGURE_COMMAND_COMMON}
|
${LUV_CONFIGURE_COMMAND_COMMON}
|
||||||
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
||||||
|
13
third-party/cmake/BuildMsgpack.cmake
vendored
13
third-party/cmake/BuildMsgpack.cmake
vendored
@ -42,7 +42,18 @@ set(MSGPACK_CONFIGURE_COMMAND ${CMAKE_COMMAND} ${DEPS_BUILD_DIR}/src/msgpack
|
|||||||
set(MSGPACK_BUILD_COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE})
|
set(MSGPACK_BUILD_COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE})
|
||||||
set(MSGPACK_INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config ${CMAKE_BUILD_TYPE})
|
set(MSGPACK_INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config ${CMAKE_BUILD_TYPE})
|
||||||
|
|
||||||
if(MSVC)
|
if(MINGW AND CMAKE_CROSSCOMPILING)
|
||||||
|
get_filename_component(TOOLCHAIN ${CMAKE_TOOLCHAIN_FILE} REALPATH)
|
||||||
|
set(MSGPACK_CONFIGURE_COMMAND ${CMAKE_COMMAND} ${DEPS_BUILD_DIR}/src/msgpack
|
||||||
|
-DMSGPACK_BUILD_TESTS=OFF
|
||||||
|
-DMSGPACK_BUILD_EXAMPLES=OFF
|
||||||
|
-DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
|
||||||
|
# Pass toolchain
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN}
|
||||||
|
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||||
|
# Hack to avoid -rdynamic in Mingw
|
||||||
|
-DCMAKE_SHARED_LIBRARY_LINK_C_FLAGS="")
|
||||||
|
elseif(MSVC)
|
||||||
# Same as Unix without fPIC
|
# Same as Unix without fPIC
|
||||||
set(MSGPACK_CONFIGURE_COMMAND ${CMAKE_COMMAND} ${DEPS_BUILD_DIR}/src/msgpack
|
set(MSGPACK_CONFIGURE_COMMAND ${CMAKE_COMMAND} ${DEPS_BUILD_DIR}/src/msgpack
|
||||||
-DMSGPACK_BUILD_TESTS=OFF
|
-DMSGPACK_BUILD_TESTS=OFF
|
||||||
|
Loading…
Reference in New Issue
Block a user