mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	third-party: Build libvterm in MinGW
Add build recipe for libvterm in MinGW, a CMakeLists.txt file is bundled in third-party/cmake/.
This commit is contained in:
		
							
								
								
									
										43
									
								
								third-party/cmake/BuildLibvterm.cmake
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										43
									
								
								third-party/cmake/BuildLibvterm.cmake
									
									
									
									
										vendored
									
									
								
							| @@ -1,6 +1,17 @@ | ||||
| if(WIN32) | ||||
|   message(STATUS "Building libvterm in Windows is not supported (skipping)") | ||||
|   return() | ||||
| include(CMakeParseArguments) | ||||
|  | ||||
| # BuildLibvterm(CONFIGURE_COMMAND ... BUILD_COMMAND ... INSTALL_COMMAND ...) | ||||
| # Failing to pass a command argument will result in no command being run | ||||
| function(BuildLibvterm) | ||||
|   cmake_parse_arguments(_libvterm | ||||
|     "" | ||||
|     "" | ||||
|     "CONFIGURE_COMMAND;BUILD_COMMAND;INSTALL_COMMAND" | ||||
|     ${ARGN}) | ||||
|  | ||||
|   if(NOT _libvterm_CONFIGURE_COMMAND AND NOT _libvterm_BUILD_COMMAND | ||||
|        AND NOT _libvterm_INSTALL_COMMAND) | ||||
|     message(FATAL_ERROR "Must pass at least one of CONFIGURE_COMMAND, BUILD_COMMAND, INSTALL_COMMAND") | ||||
|   endif() | ||||
|  | ||||
|   ExternalProject_Add(libvterm | ||||
| @@ -17,10 +28,32 @@ ExternalProject_Add(libvterm | ||||
|       -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake | ||||
|     CONFIGURE_COMMAND "" | ||||
|     BUILD_IN_SOURCE 1 | ||||
|   BUILD_COMMAND "" | ||||
|   INSTALL_COMMAND ${MAKE_PRG} CC=${DEPS_C_COMPILER} | ||||
|     CONFIGURE_COMMAND "${_libvterm_CONFIGURE_COMMAND}" | ||||
|     BUILD_COMMAND "${_libvterm_BUILD_COMMAND}" | ||||
|     INSTALL_COMMAND "${_libvterm_INSTALL_COMMAND}") | ||||
| endfunction() | ||||
|  | ||||
| if(WIN32) | ||||
|   # MinGW | ||||
|   set(LIBVTERM_CONFIGURE_COMMAND ${CMAKE_COMMAND} -E copy | ||||
| 	  ${CMAKE_CURRENT_SOURCE_DIR}/cmake/LibvtermCMakeLists.txt | ||||
| 	  ${DEPS_BUILD_DIR}/src/libvterm/CMakeLists.txt | ||||
| 	COMMAND ${CMAKE_COMMAND} ${DEPS_BUILD_DIR}/src/libvterm | ||||
|       -DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR} | ||||
|       -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} | ||||
|       "-DCMAKE_C_FLAGS:STRING=${CMAKE_C_COMPILER_ARG1} -fPIC" | ||||
|       -DCMAKE_GENERATOR=${CMAKE_GENERATOR}) | ||||
|   set(LIBVTERM_BUILD_COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE}) | ||||
|   set(LIBVTERM_INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config ${CMAKE_BUILD_TYPE}) | ||||
| else() | ||||
|   set(LIBVTERM_INSTALL_COMMAND ${MAKE_PRG} CC=${DEPS_C_COMPILER} | ||||
|                                 PREFIX=${DEPS_INSTALL_DIR} | ||||
|                                 CFLAGS=-fPIC | ||||
|                                 install) | ||||
| endif() | ||||
|  | ||||
| BuildLibvterm(CONFIGURE_COMMAND ${LIBVTERM_CONFIGURE_COMMAND} | ||||
|   BUILD_COMMAND ${LIBVTERM_BUILD_COMMAND} | ||||
|   INSTALL_COMMAND ${LIBVTERM_INSTALL_COMMAND}) | ||||
|  | ||||
| list(APPEND THIRD_PARTY_DEPS libvterm) | ||||
|   | ||||
							
								
								
									
										72
									
								
								third-party/cmake/LibvtermCMakeLists.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								third-party/cmake/LibvtermCMakeLists.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,72 @@ | ||||
| cmake_minimum_required(VERSION 2.8.11) | ||||
| project(libvterm LANGUAGES C) | ||||
|  | ||||
| include(GNUInstallDirs) | ||||
| find_package(Perl REQUIRED) | ||||
|  | ||||
| if(MSVC) | ||||
|   add_definitions(/W3 -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) | ||||
| else() | ||||
|   add_definitions(-Wall -std=c99) | ||||
| endif() | ||||
|  | ||||
| # Generate includes from tables | ||||
| file(GLOB TBL_FILES ${CMAKE_SOURCE_DIR}/src/encoding/*.tbl) | ||||
| set(TBL_FILES_HEADERS) | ||||
| foreach(file ${TBL_FILES}) | ||||
|   get_filename_component(basename ${file} NAME_WE) | ||||
|   set(tname encoding/${basename}.inc) | ||||
|   add_custom_command(OUTPUT | ||||
|     COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/encoding/ | ||||
|     COMMAND ${PERL_EXECUTABLE} -CSD ${CMAKE_SOURCE_DIR}/tbl2inc_c.pl ${file} > ${CMAKE_BINARY_DIR}/${tname} | ||||
|     COMMENT "Generating ${tname}" | ||||
|     OUTPUT ${CMAKE_BINARY_DIR}/${tname} | ||||
|     ) | ||||
|   list(APPEND TBL_FILES_HEADERS ${tname}) | ||||
| endforeach() | ||||
|  | ||||
| include_directories(${CMAKE_SOURCE_DIR}/include) | ||||
| include_directories(${CMAKE_BINARY_DIR}) | ||||
|  | ||||
| file(GLOB VTERM_SOURCES ${CMAKE_SOURCE_DIR}/src/*.c) | ||||
| add_library(vterm ${VTERM_SOURCES} ${TBL_FILES_HEADERS}) | ||||
| install(TARGETS vterm ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) | ||||
|  | ||||
| add_library(vterm-shared SHARED ${VTERM_SOURCES} ${TBL_FILES_HEADERS}) | ||||
| set_target_properties(vterm-shared PROPERTIES | ||||
|   OUTPUT_NAME vterm | ||||
|   SOVERSION 0) | ||||
| install(TARGETS vterm-shared | ||||
|   LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||||
|   RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||||
|  | ||||
| install(FILES include/vterm.h include/vterm_keycodes.h | ||||
|   DESTINATION include) | ||||
|  | ||||
| if(NOT WIN32) | ||||
|   file(GLOB BIN_SOURCES ${CMAKE_SOURCE_DIR}/bin/*.c) | ||||
|   foreach(EXE_C ${BIN_SOURCES}) | ||||
|     get_filename_component(target_name ${EXE_C} NAME_WE) | ||||
|     add_executable(${target_name} ${EXE_C}) | ||||
|     target_link_libraries(${target_name} vterm) | ||||
|     install(TARGETS ${target_name} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||||
|   endforeach() | ||||
| endif() | ||||
|  | ||||
| # Tests | ||||
| add_executable(harness EXCLUDE_FROM_ALL t/harness.c) | ||||
| target_link_libraries(harness vterm) | ||||
| set_target_properties(harness PROPERTIES | ||||
|   # run-test.pl expects to find the harness in t/.libs/ | ||||
|   RUNTIME_OUTPUT_DIRECTORY t/.libs) | ||||
|  | ||||
| file(GLOB TESTFILES ${CMAKE_SOURCE_DIR}/t/*.test) | ||||
| add_custom_target(check) | ||||
| foreach(testfile ${TESTFILES}) | ||||
|   get_filename_component(target_name ${testfile} NAME_WE) | ||||
|   add_custom_target(${target_name} | ||||
|     COMMAND ${PERL_EXECUTABLE} ${CMAKE_SOURCE_DIR}/t/run-test.pl ${testfile} | ||||
|     COMMENT "**${target_name} **" | ||||
|     DEPENDS harness) | ||||
|   add_dependencies(check ${target_name}) | ||||
| endforeach() | ||||
		Reference in New Issue
	
	Block a user
	 Rui Abreu Ferreira
					Rui Abreu Ferreira