From 843c9025ae8b44b14d0908674c8874a51dc13a38 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Thu, 26 Jan 2023 21:35:06 +0100 Subject: build: check if libvterm version meets requirement (#22010) The vterm.h file only specifies major and minor version, but not patch, meaning that requiring a specific patch number isn't currently possible. --- cmake/FindLIBVTERM.cmake | 10 ---------- cmake/Findlibvterm.cmake | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 10 deletions(-) delete mode 100644 cmake/FindLIBVTERM.cmake create mode 100644 cmake/Findlibvterm.cmake (limited to 'cmake') diff --git a/cmake/FindLIBVTERM.cmake b/cmake/FindLIBVTERM.cmake deleted file mode 100644 index 469494ddfd..0000000000 --- a/cmake/FindLIBVTERM.cmake +++ /dev/null @@ -1,10 +0,0 @@ -# - Try to find libvterm -# Once done this will define -# LIBVTERM_FOUND - System has libvterm -# LIBVTERM_INCLUDE_DIRS - The libvterm include directories -# LIBVTERM_LIBRARIES - The libraries needed to use libvterm - -include(LibFindMacros) - -libfind_pkg_detect(LIBVTERM vterm FIND_PATH vterm.h FIND_LIBRARY vterm) -libfind_process(LIBVTERM REQUIRED) diff --git a/cmake/Findlibvterm.cmake b/cmake/Findlibvterm.cmake new file mode 100644 index 0000000000..e73775d973 --- /dev/null +++ b/cmake/Findlibvterm.cmake @@ -0,0 +1,20 @@ +find_path(LIBVTERM_INCLUDE_DIR vterm.h) +find_library(LIBVTERM_LIBRARY vterm) + +if(LIBVTERM_INCLUDE_DIR AND EXISTS "${LIBVTERM_INCLUDE_DIR}/vterm.h") + file(STRINGS ${LIBVTERM_INCLUDE_DIR}/vterm.h VTERM_VERSION_MAJOR REGEX "#define VTERM_VERSION_MAJOR") + string(REGEX MATCH "[0-9]+" VTERM_VERSION_MAJOR ${VTERM_VERSION_MAJOR}) + + file(STRINGS ${LIBVTERM_INCLUDE_DIR}/vterm.h VTERM_VERSION_MINOR REGEX "#define VTERM_VERSION_MINOR") + string(REGEX MATCH "[0-9]+" VTERM_VERSION_MINOR ${VTERM_VERSION_MINOR}) + + set(VTERM_VERSION ${VTERM_VERSION_MAJOR}.${VTERM_VERSION_MINOR}) +endif() + +find_package_handle_standard_args(libvterm + REQUIRED_VARS LIBVTERM_INCLUDE_DIR LIBVTERM_LIBRARY + VERSION_VAR VTERM_VERSION) + +add_library(libvterm INTERFACE) +target_include_directories(libvterm SYSTEM BEFORE INTERFACE INTERFACE ${LIBVTERM_INCLUDE_DIR}) +target_link_libraries(main_lib INTERFACE ${LIBVTERM_LIBRARY}) -- cgit From d85ed00a8cc2274eff4409e2b18ba34178ae567a Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Fri, 27 Jan 2023 11:53:32 +0100 Subject: build: find unibilium without relying on libfindmacros (#22015) This will remove the warning about the find module not providing a version. --- cmake/FindUNIBILIUM.cmake | 12 ------------ cmake/Findunibilium.cmake | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 12 deletions(-) delete mode 100644 cmake/FindUNIBILIUM.cmake create mode 100644 cmake/Findunibilium.cmake (limited to 'cmake') diff --git a/cmake/FindUNIBILIUM.cmake b/cmake/FindUNIBILIUM.cmake deleted file mode 100644 index 0bf27b45e2..0000000000 --- a/cmake/FindUNIBILIUM.cmake +++ /dev/null @@ -1,12 +0,0 @@ -# - Try to find unibilium -# Once done this will define -# UNIBILIUM_FOUND - System has unibilium -# UNIBILIUM_INCLUDE_DIRS - The unibilium include directories -# UNIBILIUM_LIBRARIES - The libraries needed to use unibilium - -include(LibFindMacros) - -libfind_pkg_detect(UNIBILIUM unibilium - FIND_PATH unibilium.h - FIND_LIBRARY unibilium) -libfind_process(UNIBILIUM) diff --git a/cmake/Findunibilium.cmake b/cmake/Findunibilium.cmake new file mode 100644 index 0000000000..fd8eb0cd7f --- /dev/null +++ b/cmake/Findunibilium.cmake @@ -0,0 +1,27 @@ +find_path(UNIBILIUM_INCLUDE_DIR unibilium.h) +find_library(UNIBILIUM_LIBRARY unibilium) + +find_package_handle_standard_args(unibilium + REQUIRED_VARS UNIBILIUM_INCLUDE_DIR UNIBILIUM_LIBRARY) + +add_library(unibilium INTERFACE) +target_include_directories(unibilium SYSTEM BEFORE INTERFACE ${UNIBILIUM_INCLUDE_DIR}) +target_link_libraries(unibilium INTERFACE ${UNIBILIUM_LIBRARY}) + +list(APPEND CMAKE_REQUIRED_INCLUDES "${UNIBILIUM_INCLUDE_DIR}") +list(APPEND CMAKE_REQUIRED_LIBRARIES "${UNIBILIUM_LIBRARY}") +check_c_source_compiles(" +#include + +int +main(void) +{ + unibi_str_from_var(unibi_var_from_str(\"\")); + return unibi_num_from_var(unibi_var_from_num(0)); +} +" UNIBI_HAS_VAR_FROM) +list(REMOVE_ITEM CMAKE_REQUIRED_INCLUDES "${UNIBILIUM_INCLUDE_DIR}") +list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "${UNIBILIUM_LIBRARY}") +if(UNIBI_HAS_VAR_FROM) + target_compile_definitions(main_lib INTERFACE NVIM_UNIBI_HAS_VAR_FROM) +endif() -- cgit From 38365fa2ef86057775cc17b21c02a38761adbe3c Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Fri, 27 Jan 2023 14:16:31 +0100 Subject: build: fix dependencies in find modules (#22017) Find modules should only link to libraries defined in the find module, and not the main project. This helps the find modules be more self-contained and easier to understand. --- cmake/Findlibvterm.cmake | 2 +- cmake/Findunibilium.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'cmake') diff --git a/cmake/Findlibvterm.cmake b/cmake/Findlibvterm.cmake index e73775d973..d8536ca894 100644 --- a/cmake/Findlibvterm.cmake +++ b/cmake/Findlibvterm.cmake @@ -17,4 +17,4 @@ find_package_handle_standard_args(libvterm add_library(libvterm INTERFACE) target_include_directories(libvterm SYSTEM BEFORE INTERFACE INTERFACE ${LIBVTERM_INCLUDE_DIR}) -target_link_libraries(main_lib INTERFACE ${LIBVTERM_LIBRARY}) +target_link_libraries(libvterm INTERFACE ${LIBVTERM_LIBRARY}) diff --git a/cmake/Findunibilium.cmake b/cmake/Findunibilium.cmake index fd8eb0cd7f..7bfbcba942 100644 --- a/cmake/Findunibilium.cmake +++ b/cmake/Findunibilium.cmake @@ -23,5 +23,5 @@ main(void) list(REMOVE_ITEM CMAKE_REQUIRED_INCLUDES "${UNIBILIUM_INCLUDE_DIR}") list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "${UNIBILIUM_LIBRARY}") if(UNIBI_HAS_VAR_FROM) - target_compile_definitions(main_lib INTERFACE NVIM_UNIBI_HAS_VAR_FROM) + target_compile_definitions(unibilium INTERFACE NVIM_UNIBI_HAS_VAR_FROM) endif() -- cgit From 13aa23b62af4df3e7f10687b76fe8c04efa2a598 Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 30 Jan 2023 20:36:49 +0100 Subject: refactor(tests): run unittests using main nvim binary in interpreter mode This allows us to get rid of the separate "nvim-test" target --- cmake/RunTests.cmake | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'cmake') diff --git a/cmake/RunTests.cmake b/cmake/RunTests.cmake index c3ac5f208e..d724f43a5f 100644 --- a/cmake/RunTests.cmake +++ b/cmake/RunTests.cmake @@ -71,8 +71,16 @@ if(NOT DEFINED ENV{TEST_TIMEOUT} OR "$ENV{TEST_TIMEOUT}" STREQUAL "") endif() set(ENV{SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_NAME}) # used by test/helpers.lua. + +# TODO: eventually always use NVIM_PRG as the runner +if("${TEST_TYPE}" STREQUAL "unit") + set(RUNNER_PRG ${NVIM_PRG} -ll ${WORKING_DIR}/test/busted_runner.lua) +else() + set(RUNNER_PRG ${BUSTED_PRG}) +endif() + execute_process( - COMMAND ${BUSTED_PRG} -v -o test.busted.outputHandlers.${BUSTED_OUTPUT_TYPE} + COMMAND ${RUNNER_PRG} -v -o test.busted.outputHandlers.${BUSTED_OUTPUT_TYPE} --lazy --helper=${TEST_DIR}/${TEST_TYPE}/preload.lua --lpath=${BUILD_DIR}/?.lua --lpath=${WORKING_DIR}/runtime/lua/?.lua -- cgit