mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
Merge #8579 win: cmake: Improvements for building with IDEs
This commit is contained in:
commit
6294a807d3
@ -15,12 +15,41 @@ list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
|
||||
# We don't support building in-tree.
|
||||
include(PreventInTreeBuilds)
|
||||
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
# Prefer our bundled versions of dependencies.
|
||||
if(DEFINED ENV{DEPS_BUILD_DIR})
|
||||
set(DEPS_PREFIX "$ENV{DEPS_BUILD_DIR}/usr" CACHE PATH "Path prefix for finding dependencies")
|
||||
else()
|
||||
set(DEPS_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/.deps/usr" CACHE PATH "Path prefix for finding dependencies")
|
||||
# When running from within CLion or Visual Studio,
|
||||
# build bundled dependencies automatically.
|
||||
if(NOT EXISTS ${DEPS_PREFIX}
|
||||
AND (DEFINED ENV{CLION_IDE}
|
||||
OR DEFINED ENV{VisualStudioEdition}))
|
||||
message(STATUS "Building dependencies...")
|
||||
set(DEPS_BUILD_DIR ${PROJECT_BINARY_DIR}/.deps)
|
||||
file(MAKE_DIRECTORY ${DEPS_BUILD_DIR})
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -G ${CMAKE_GENERATOR}
|
||||
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
|
||||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
||||
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
|
||||
-DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG}
|
||||
-DCMAKE_C_FLAGS_MINSIZEREL=${CMAKE_C_FLAGS_MINSIZEREL}
|
||||
-DCMAKE_C_FLAGS_RELWITHDEBINFO=${CMAKE_C_FLAGS_RELWITHDEBINFO}
|
||||
-DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE}
|
||||
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
|
||||
${PROJECT_SOURCE_DIR}/third-party
|
||||
WORKING_DIRECTORY ${DEPS_BUILD_DIR})
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} --build ${DEPS_BUILD_DIR}
|
||||
--config ${CMAKE_BUILD_TYPE})
|
||||
set(DEPS_PREFIX ${DEPS_BUILD_DIR}/usr)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_CROSSCOMPILING AND NOT UNIX)
|
||||
list(INSERT CMAKE_FIND_ROOT_PATH 0 ${DEPS_PREFIX})
|
||||
list(INSERT CMAKE_PREFIX_PATH 0 ${DEPS_PREFIX}/../host/bin)
|
||||
@ -543,6 +572,7 @@ if(BUSTED_PRG)
|
||||
# Useful for automated build systems, if they want to manually run the tests.
|
||||
add_custom_target(unittest-prereqs
|
||||
DEPENDS ${UNITTEST_PREREQS})
|
||||
set_target_properties(unittest-prereqs PROPERTIES FOLDER test)
|
||||
|
||||
add_custom_target(functionaltest-prereqs
|
||||
DEPENDS ${FUNCTIONALTEST_PREREQS})
|
||||
@ -565,6 +595,7 @@ if(BUSTED_PRG)
|
||||
-P ${PROJECT_SOURCE_DIR}/cmake/RunTests.cmake
|
||||
DEPENDS ${UNITTEST_PREREQS}
|
||||
${TEST_TARGET_ARGS})
|
||||
set_target_properties(unittest PROPERTIES FOLDER test)
|
||||
else()
|
||||
message(WARNING "disabling unit tests: no Luajit FFI in ${LUA_PRG}")
|
||||
endif()
|
||||
@ -595,6 +626,8 @@ if(BUSTED_PRG)
|
||||
-P ${PROJECT_SOURCE_DIR}/cmake/RunTests.cmake
|
||||
DEPENDS ${FUNCTIONALTEST_PREREQS}
|
||||
${TEST_TARGET_ARGS})
|
||||
set_target_properties(functionaltest functionaltest-prereqs
|
||||
PROPERTIES FOLDER test)
|
||||
|
||||
add_custom_target(benchmark
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
@ -610,6 +643,7 @@ if(BUSTED_PRG)
|
||||
-P ${PROJECT_SOURCE_DIR}/cmake/RunTests.cmake
|
||||
DEPENDS ${BENCHMARK_PREREQS}
|
||||
${TEST_TARGET_ARGS})
|
||||
set_target_properties(benchmark benchmark-prereqs PROPERTIES FOLDER test)
|
||||
endif()
|
||||
|
||||
if(BUSTED_LUA_PRG)
|
||||
@ -627,6 +661,7 @@ if(BUSTED_LUA_PRG)
|
||||
-P ${PROJECT_SOURCE_DIR}/cmake/RunTests.cmake
|
||||
DEPENDS ${FUNCTIONALTEST_PREREQS}
|
||||
${TEST_TARGET_ARGS})
|
||||
set_target_properties(functionaltest-lua PROPERTIES FOLDER test)
|
||||
endif()
|
||||
|
||||
if(LUACHECK_PRG)
|
||||
|
18
makedeps.bat
18
makedeps.bat
@ -1,18 +0,0 @@
|
||||
echo off
|
||||
|
||||
if not defined VS150COMNTOOLS (
|
||||
echo error: missing VS150COMNTOOLS environment variable.
|
||||
echo Run this script from the 'Developer Command Prompt'.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo on
|
||||
|
||||
set CMAKE=%VS150COMNTOOLS%\..\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe
|
||||
|
||||
mkdir .deps
|
||||
cd .deps
|
||||
"%CMAKE%" -G "Visual Studio 15 2017" "-DCMAKE_BUILD_TYPE=RelWithDebInfo" ..\third-party\
|
||||
"%CMAKE%" --build . --config RelWithDebInfo -- "/verbosity:normal"
|
||||
cd ..
|
||||
|
@ -424,39 +424,52 @@ if(WIN32)
|
||||
-P ${PROJECT_SOURCE_DIR}/cmake/WindowsDllCopy.cmake)
|
||||
add_dependencies(nvim_runtime_deps nvim_dll_deps)
|
||||
|
||||
# A CMake script is used for copying the files to avoid the
|
||||
# "command line is too long" error that occurs when Ninja tries running
|
||||
# a command that exceeds the length limit (8191 characters) on Windows.
|
||||
# See https://developercommunity.visualstudio.com/content/problem/212207/file-open-cmake-the-command-line-is-too-long.html
|
||||
set(EXTERNAL_BLOBS_SCRIPT
|
||||
"file(MAKE_DIRECTORY \"${PROJECT_BINARY_DIR}/windows_runtime_deps/platforms\")")
|
||||
foreach(DEP_FILE IN ITEMS
|
||||
ca-bundle.crt
|
||||
cat.exe
|
||||
curl.exe
|
||||
diff.exe
|
||||
tee.exe
|
||||
tidy.exe
|
||||
win32yank.exe
|
||||
winpty-agent.exe
|
||||
xxd.exe
|
||||
|
||||
D3Dcompiler_47.dll
|
||||
libEGL.dll
|
||||
libgcc_s_dw2-1.dll
|
||||
libGLESV2.dll
|
||||
libstdc++-6.dll
|
||||
libwinpthread-1.dll
|
||||
nvim-qt.exe
|
||||
Qt5Core.dll
|
||||
Qt5Gui.dll
|
||||
Qt5Network.dll
|
||||
Qt5Svg.dll
|
||||
Qt5Widgets.dll
|
||||
winpty.dll
|
||||
|
||||
platforms/qwindows.dll
|
||||
)
|
||||
set(EXTERNAL_BLOBS_SCRIPT "${EXTERNAL_BLOBS_SCRIPT}\n"
|
||||
"file(COPY \"${DEPS_PREFIX}/bin/${DEP_FILE}\"
|
||||
DESTINATION \"${PROJECT_BINARY_DIR}/windows_runtime_deps/\")")
|
||||
endforeach()
|
||||
file(WRITE ${PROJECT_BINARY_DIR}/external_blobs.cmake ${EXTERNAL_BLOBS_SCRIPT})
|
||||
add_custom_target(external_blobs
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/windows_runtime_deps/platforms
|
||||
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/ca-bundle.crt" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/cat.exe" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/curl.exe" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/diff.exe" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/tee.exe" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/tidy.exe" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/win32yank.exe" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/winpty-agent.exe" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/xxd.exe" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
||||
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/D3Dcompiler_47.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/libEGL.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/libgcc_s_dw2-1.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/libGLESV2.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/libstdc++-6.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/libwinpthread-1.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/nvim-qt.exe" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/Qt5Core.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/Qt5Gui.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/Qt5Network.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/Qt5Svg.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/Qt5Widgets.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/winpty.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
||||
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/platforms/qwindows.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/platforms/
|
||||
)
|
||||
COMMAND ${CMAKE_COMMAND} -P ${PROJECT_BINARY_DIR}/external_blobs.cmake)
|
||||
set_target_properties(external_blobs PROPERTIES FOLDER deps)
|
||||
add_dependencies(nvim_runtime_deps external_blobs)
|
||||
else()
|
||||
add_custom_target(nvim_runtime_deps) # Stub target to avoid CMP0046.
|
||||
endif()
|
||||
set_target_properties(nvim_runtime_deps PROPERTIES FOLDER deps)
|
||||
|
||||
add_library(
|
||||
libnvim
|
||||
@ -568,6 +581,7 @@ foreach(hfile ${NVIM_HEADERS})
|
||||
TARGET ${texe}
|
||||
APPEND PROPERTY INCLUDE_DIRECTORIES ${LUA_PREFERRED_INCLUDE_DIRS}
|
||||
)
|
||||
set_target_properties(${texe} PROPERTIES FOLDER test)
|
||||
|
||||
list(FIND NO_SINGLE_CHECK_HEADERS "${relative_path}" hfile_exclude_idx)
|
||||
if(${hfile_exclude_idx} EQUAL -1)
|
||||
|
@ -55,6 +55,7 @@ if(HAVE_WORKING_LIBINTL AND GETTEXT_FOUND AND XGETTEXT_PRG AND ICONV_PRG)
|
||||
DEPENDS ${NVIM_SOURCES})
|
||||
|
||||
add_custom_target(potfile DEPENDS ${NVIM_POT})
|
||||
set_target_properties(potfile PROPERTIES FOLDER po)
|
||||
|
||||
set(LANGUAGE_MO_FILES)
|
||||
set(UPDATE_PO_TARGETS)
|
||||
@ -91,6 +92,7 @@ if(HAVE_WORKING_LIBINTL AND GETTEXT_FOUND AND XGETTEXT_PRG AND ICONV_PRG)
|
||||
COMMENT "Checking ${name}.po"
|
||||
VERBATIM
|
||||
DEPENDS ${poFile})
|
||||
set_target_properties(check-po-${name} PROPERTIES FOLDER po/check)
|
||||
endmacro()
|
||||
|
||||
macro(BuildPoIconvGenericWithCharset
|
||||
@ -182,7 +184,9 @@ if(HAVE_WORKING_LIBINTL AND GETTEXT_FOUND AND XGETTEXT_PRG AND ICONV_PRG)
|
||||
|
||||
BuildMo(${LANGUAGE})
|
||||
endforeach()
|
||||
set_target_properties(${UPDATE_PO_TARGETS} PROPERTIES FOLDER po/update)
|
||||
|
||||
add_custom_target(translations ALL DEPENDS ${LANGUAGE_MO_FILES})
|
||||
add_custom_target(update-po DEPENDS ${UPDATE_PO_TARGETS})
|
||||
set_target_properties(translations update-po PROPERTIES FOLDER po)
|
||||
endif()
|
||||
|
@ -22,3 +22,4 @@ foreach(hfile ${PRE_HEADERS})
|
||||
endforeach()
|
||||
|
||||
add_custom_target(unittest-headers DEPENDS ${POST_HEADERS})
|
||||
set_target_properties(unittest-headers PROPERTIES FOLDER test)
|
||||
|
Loading…
Reference in New Issue
Block a user