diff options
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/FindLibintl.cmake | 6 | ||||
-rw-r--r-- | cmake/FindLibtermkey.cmake | 9 | ||||
-rw-r--r-- | cmake/FindLibuv.cmake | 16 | ||||
-rw-r--r-- | cmake/FindTreesitter.cmake | 20 | ||||
-rw-r--r-- | cmake/Format.cmake | 65 | ||||
-rw-r--r-- | cmake/InstallHelpers.cmake | 13 | ||||
-rw-r--r-- | cmake/RunTests.cmake | 9 | ||||
-rw-r--r-- | cmake/Util.cmake | 25 |
8 files changed, 35 insertions, 128 deletions
diff --git a/cmake/FindLibintl.cmake b/cmake/FindLibintl.cmake index 630a3545fc..faee0537ff 100644 --- a/cmake/FindLibintl.cmake +++ b/cmake/FindLibintl.cmake @@ -78,3 +78,9 @@ endif() find_package_handle_standard_args(Libintl DEFAULT_MSG ${REQUIRED_VARIABLES}) mark_as_advanced(LIBINTL_LIBRARY LIBINTL_INCLUDE_DIR) + +add_library(libintl INTERFACE) +target_include_directories(libintl SYSTEM BEFORE INTERFACE ${LIBINTL_INCLUDE_DIR}) +if (LIBINTL_LIBRARY) + target_link_libraries(libintl INTERFACE ${LIBINTL_LIBRARY}) +endif() diff --git a/cmake/FindLibtermkey.cmake b/cmake/FindLibtermkey.cmake deleted file mode 100644 index 8039ae7994..0000000000 --- a/cmake/FindLibtermkey.cmake +++ /dev/null @@ -1,9 +0,0 @@ -find_path2(LIBTERMKEY_INCLUDE_DIR termkey.h) -find_library2(LIBTERMKEY_LIBRARY NAMES termkey) -find_package_handle_standard_args(Libtermkey DEFAULT_MSG - LIBTERMKEY_LIBRARY LIBTERMKEY_INCLUDE_DIR) -mark_as_advanced(LIBTERMKEY_INCLUDE_DIR LIBTERMKEY_LIBRARY) - -add_library(libtermkey INTERFACE) -target_include_directories(libtermkey SYSTEM BEFORE INTERFACE ${LIBTERMKEY_INCLUDE_DIR}) -target_link_libraries(libtermkey INTERFACE ${LIBTERMKEY_LIBRARY}) diff --git a/cmake/FindLibuv.cmake b/cmake/FindLibuv.cmake index 19315388dd..dcd9b9559d 100644 --- a/cmake/FindLibuv.cmake +++ b/cmake/FindLibuv.cmake @@ -1,5 +1,5 @@ find_path2(LIBUV_INCLUDE_DIR uv.h) -find_library2(LIBUV_LIBRARY NAMES uv_a uv) +find_library2(LIBUV_LIBRARY NAMES uv_a uv libuv) set(LIBUV_LIBRARIES ${LIBUV_LIBRARY}) @@ -41,10 +41,12 @@ endif() if(WIN32) # check_library_exists() does not work for Win32 API calls in X86 due to name # mangling calling conventions - list(APPEND LIBUV_LIBRARIES iphlpapi) - list(APPEND LIBUV_LIBRARIES psapi) - list(APPEND LIBUV_LIBRARIES userenv) - list(APPEND LIBUV_LIBRARIES ws2_32) + list(APPEND LIBUV_LIBRARIES + iphlpapi + psapi + userenv + ws2_32 + dbghelp) endif() find_package(Threads) @@ -59,3 +61,7 @@ find_package_handle_standard_args(Libuv DEFAULT_MSG LIBUV_LIBRARY LIBUV_INCLUDE_DIR) mark_as_advanced(LIBUV_INCLUDE_DIR LIBUV_LIBRARY) + +add_library(libuv INTERFACE) +target_include_directories(libuv SYSTEM BEFORE INTERFACE ${LIBUV_INCLUDE_DIR}) +target_link_libraries(libuv INTERFACE ${LIBUV_LIBRARIES}) diff --git a/cmake/FindTreesitter.cmake b/cmake/FindTreesitter.cmake index 8dac13337b..0d0897be70 100644 --- a/cmake/FindTreesitter.cmake +++ b/cmake/FindTreesitter.cmake @@ -7,23 +7,3 @@ mark_as_advanced(TREESITTER_LIBRARY TREESITTER_INCLUDE_DIR) add_library(treesitter INTERFACE) target_include_directories(treesitter SYSTEM BEFORE INTERFACE ${TREESITTER_INCLUDE_DIR}) target_link_libraries(treesitter INTERFACE ${TREESITTER_LIBRARY}) - -# TODO(lewis6991): remove when min TS version is 0.20.9 -list(APPEND CMAKE_REQUIRED_INCLUDES "${TREESITTER_INCLUDE_DIR}") -list(APPEND CMAKE_REQUIRED_LIBRARIES "${TREESITTER_LIBRARY}") -check_c_source_compiles(" -#include <tree_sitter/api.h> -int -main(void) -{ - TSQueryCursor *cursor = ts_query_cursor_new(); - ts_query_cursor_set_max_start_depth(cursor, 32); - return 0; -} -" TS_HAS_SET_MAX_START_DEPTH) -list(REMOVE_ITEM CMAKE_REQUIRED_INCLUDES "${TREESITTER_INCLUDE_DIR}") -list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "${TREESITTER_LIBRARY}") - -if(TS_HAS_SET_MAX_START_DEPTH) - target_compile_definitions(treesitter INTERFACE NVIM_TS_HAS_SET_MAX_START_DEPTH) -endif() diff --git a/cmake/Format.cmake b/cmake/Format.cmake deleted file mode 100644 index 7097e5766f..0000000000 --- a/cmake/Format.cmake +++ /dev/null @@ -1,65 +0,0 @@ -# Returns a list of all files that has been changed in current branch compared -# to master branch. This includes unstaged, staged and committed files. -function(get_changed_files outvar) - execute_process( - COMMAND git branch --show-current - OUTPUT_VARIABLE current_branch - OUTPUT_STRIP_TRAILING_WHITESPACE) - - execute_process( - COMMAND git merge-base master HEAD - OUTPUT_VARIABLE ancestor_commit - OUTPUT_STRIP_TRAILING_WHITESPACE) - - # Changed files that have been committed - execute_process( - COMMAND git diff --diff-filter=d --name-only ${ancestor_commit}...${current_branch} - OUTPUT_VARIABLE committed_files - OUTPUT_STRIP_TRAILING_WHITESPACE) - separate_arguments(committed_files NATIVE_COMMAND ${committed_files}) - - # Unstaged files - execute_process( - COMMAND git diff --diff-filter=d --name-only - OUTPUT_VARIABLE unstaged_files - OUTPUT_STRIP_TRAILING_WHITESPACE) - separate_arguments(unstaged_files NATIVE_COMMAND ${unstaged_files}) - - # Staged files - execute_process( - COMMAND git diff --diff-filter=d --cached --name-only - OUTPUT_VARIABLE staged_files - OUTPUT_STRIP_TRAILING_WHITESPACE) - separate_arguments(staged_files NATIVE_COMMAND ${staged_files}) - - set(files ${committed_files} ${unstaged_files} ${staged_files}) - list(REMOVE_DUPLICATES files) - - set(${outvar} "${files}" PARENT_SCOPE) -endfunction() - -get_changed_files(changed_files) - -if(LANG STREQUAL c) - list(FILTER changed_files INCLUDE REGEX "\\.[ch]$") - list(FILTER changed_files INCLUDE REGEX "^src/nvim/") - - if(changed_files) - if(FORMAT_PRG) - execute_process(COMMAND ${FORMAT_PRG} -c "src/uncrustify.cfg" --replace --no-backup ${changed_files}) - else() - message(STATUS "Uncrustify not found. Skip formatting C files.") - endif() - endif() -elseif(LANG STREQUAL lua) - list(FILTER changed_files INCLUDE REGEX "\\.lua$") - list(FILTER changed_files INCLUDE REGEX "^runtime/") - - if(changed_files) - if(FORMAT_PRG) - execute_process(COMMAND ${FORMAT_PRG} ${changed_files}) - else() - message(STATUS "Stylua not found. Skip formatting lua files.") - endif() - endif() -endif() diff --git a/cmake/InstallHelpers.cmake b/cmake/InstallHelpers.cmake index 63bf2bb73b..0a07bf9859 100644 --- a/cmake/InstallHelpers.cmake +++ b/cmake/InstallHelpers.cmake @@ -151,16 +151,3 @@ function(install_helper) ${RENAME}) endif() endfunction() - -# Without CONFIGURE_DEPENDS globbing reuses cached file tree on rebuild. -# For example it will ignore new files. -# CONFIGURE_DEPENDS was introduced in 3.12 - -function(glob_wrapper outvar) - if(${CMAKE_VERSION} VERSION_LESS 3.12) - file(GLOB ${outvar} ${ARGN}) - else() - file(GLOB ${outvar} CONFIGURE_DEPENDS ${ARGN}) - endif() - set(${outvar} ${${outvar}} PARENT_SCOPE) -endfunction() diff --git a/cmake/RunTests.cmake b/cmake/RunTests.cmake index 8d5b0d2402..6f93f73bc0 100644 --- a/cmake/RunTests.cmake +++ b/cmake/RunTests.cmake @@ -32,12 +32,7 @@ if(IS_ABSOLUTE ${TEST_PATH}) file(RELATIVE_PATH TEST_PATH "${WORKING_DIR}" "${TEST_PATH}") endif() -if(BUSTED_OUTPUT_TYPE STREQUAL junit) - set(EXTRA_ARGS OUTPUT_FILE ${BUILD_DIR}/${TEST_TYPE}test-junit.xml) -endif() - -set(BUSTED_ARGS $ENV{BUSTED_ARGS}) -separate_arguments(BUSTED_ARGS) +separate_arguments(BUSTED_ARGS NATIVE_COMMAND $ENV{BUSTED_ARGS}) if(DEFINED ENV{TEST_TAG} AND NOT "$ENV{TEST_TAG}" STREQUAL "") list(APPEND BUSTED_ARGS --tags $ENV{TEST_TAG}) @@ -72,7 +67,7 @@ endif() execute_process( # Note: because of "-ll" (low-level interpreter mode), some modules like # _editor.lua are not loaded. - COMMAND ${NVIM_PRG} -ll ${WORKING_DIR}/test/lua_runner.lua ${DEPS_INSTALL_DIR} busted -v -o test.busted.outputHandlers.${BUSTED_OUTPUT_TYPE} + COMMAND ${NVIM_PRG} -ll ${WORKING_DIR}/test/lua_runner.lua ${DEPS_INSTALL_DIR} busted -v -o test.busted.outputHandlers.nvim --lazy --helper=${TEST_DIR}/${TEST_TYPE}/preload.lua --lpath=${BUILD_DIR}/?.lua --lpath=${WORKING_DIR}/runtime/lua/?.lua diff --git a/cmake/Util.cmake b/cmake/Util.cmake index 01d34d6752..80f81fd0b4 100644 --- a/cmake/Util.cmake +++ b/cmake/Util.cmake @@ -75,6 +75,7 @@ function(add_glob_target) list(APPEND ARG_FILES ${globfiles}) endforeach() + list(APPEND ARG_EXCLUDE runtime/lua/vim/_meta) # only generated files, always ignore foreach(exclude_pattern ${ARG_EXCLUDE}) list(FILTER ARG_FILES EXCLUDE REGEX ${exclude_pattern}) endforeach() @@ -88,7 +89,7 @@ function(add_glob_target) endif() if(ARG_TOUCH_STRATEGY STREQUAL SINGLE) - set(touch_file ${TOUCHES_DIR}/ran-${ARG_TARGET}) + set(touch_file ${TOUCHES_DIR}/${ARG_TARGET}) add_custom_command( OUTPUT ${touch_file} COMMAND ${CMAKE_COMMAND} -E touch ${touch_file} @@ -102,7 +103,7 @@ function(add_glob_target) foreach(f ${ARG_FILES}) string(REGEX REPLACE "^${PROJECT_SOURCE_DIR}/" "" tf ${f}) string(REGEX REPLACE "[/.]" "-" tf ${tf}) - set(touch_file ${touch_dir}/ran-${tf}) + set(touch_file ${touch_dir}/${tf}) add_custom_command( OUTPUT ${touch_file} COMMAND ${CMAKE_COMMAND} -E touch ${touch_file} @@ -132,7 +133,7 @@ function(add_glob_target) file(MAKE_DIRECTORY ${td}) string(REGEX REPLACE "^${PROJECT_SOURCE_DIR}/" "" tf ${touch_dir}) string(REGEX REPLACE "[/.]" "-" tf ${tf}) - set(touch_file ${td}/ran-${tf}) + set(touch_file ${td}/${tf}) add_custom_command( OUTPUT ${touch_file} @@ -147,8 +148,8 @@ function(add_glob_target) add_custom_target(${ARG_TARGET} DEPENDS ${touch_list}) endfunction() -# Set default build type to Debug. Also limit the list of allowable build types -# to the ones defined in variable allowableBuildTypes. +# Set default build type to BUILD_TYPE. Also limit the list of allowable build +# types to the ones defined in variable allowableBuildTypes. # # The correct way to specify build type (for example Release) for # single-configuration generators (Make and Ninja) is to run @@ -164,21 +165,27 @@ endfunction() # # Passing CMAKE_BUILD_TYPE for multi-config generators will not only not be # used, but also generate a warning for the user. -function(set_default_buildtype) +function(set_default_buildtype BUILD_TYPE) set(allowableBuildTypes Debug Release MinSizeRel RelWithDebInfo) + if(NOT BUILD_TYPE IN_LIST allowableBuildTypes) + message(FATAL_ERROR "Invalid build type: ${BUILD_TYPE}") + endif() get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(isMultiConfig) + # Multi-config generators use the first element in CMAKE_CONFIGURATION_TYPES as the default build type + list(INSERT allowableBuildTypes 0 ${BUILD_TYPE}) + list(REMOVE_DUPLICATES allowableBuildTypes) set(CMAKE_CONFIGURATION_TYPES ${allowableBuildTypes} PARENT_SCOPE) if(CMAKE_BUILD_TYPE) message(WARNING "CMAKE_BUILD_TYPE specified which is ignored on \ - multi-configuration generators. Defaulting to Debug build type.") + multi-configuration generators. Defaulting to ${BUILD_TYPE} build type.") endif() else() set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${allowableBuildTypes}") if(NOT CMAKE_BUILD_TYPE) - message(STATUS "CMAKE_BUILD_TYPE not specified, default is 'Debug'") - set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build" FORCE) + message(STATUS "CMAKE_BUILD_TYPE not specified, default is '${BUILD_TYPE}'") + set(CMAKE_BUILD_TYPE ${BUILD_TYPE} CACHE STRING "Choose the type of build" FORCE) elseif(NOT CMAKE_BUILD_TYPE IN_LIST allowableBuildTypes) message(FATAL_ERROR "Invalid build type: ${CMAKE_BUILD_TYPE}") else() |