Skip to content

Commit

Permalink
Merge pull request #752 from squeek502/test-exclude-from-all
Browse files Browse the repository at this point in the history
Clean up test step and exclude it from the "all" target
  • Loading branch information
squeek502 authored Jan 24, 2025
2 parents b17d6e6 + 61e0f36 commit 1b29585
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 37 deletions.
44 changes: 11 additions & 33 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,17 @@ if(WIN32)
add_definitions(-DLUA_BUILD_AS_DLL -DLUA_LIB)
endif()

add_executable(test EXCLUDE_FROM_ALL src/test.c src/luv.c)
# Need to link Lua/LuaJIT libraries on non-Windows for the test executable
if ((LUAJIT_LIBRARIES OR LUA_LIBRARIES) AND NOT (WIN32 OR CYGWIN))
if(USE_LUAJIT)
target_link_libraries(test ${LUAJIT_LIBRARIES})
else()
target_link_libraries(test ${LUA_LIBRARIES})
endif()
endif()
list(APPEND ACTIVE_TARGETS "test")

foreach(TARGET_NAME ${ACTIVE_TARGETS})
if(WIN32 OR CYGWIN)
if (LUA)
Expand All @@ -262,39 +273,6 @@ foreach(TARGET_NAME ${ACTIVE_TARGETS})
endif()
endforeach()

if(LUAJIT_LIBRARIES OR LUA_LIBRARIES)
add_executable(test src/test.c src/luv.c)
if(WIN32 OR CYGWIN)
if (LUA)
target_link_libraries(test ${LIBUV_LIBRARIES} ${LUA_LIBRARIES})
else (LUA)
if (USE_LUAJIT)
target_link_libraries(test ${LIBUV_LIBRARIES} ${LUAJIT_LIBRARIES})
else (USE_LUAJIT)
if (LUA_BUILD_TYPE STREQUAL System)
target_link_libraries(test ${LIBUV_LIBRARIES} ${LUA_LIBRARIES})
else (LUA_BUILD_TYPE STREQUAL System)
target_link_libraries(test ${LIBUV_LIBRARIES} lualib)
endif (LUA_BUILD_TYPE STREQUAL System)
endif (USE_LUAJIT)
endif (LUA)
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
if (USE_LUAJIT)
target_link_libraries(test ${LIBUV_LIBRARIES} ${LUAJIT_LIBRARIES} rt)
else ()
target_link_libraries(test ${LIBUV_LIBRARIES} ${LUA_LIBRARIES} rt)
endif ()
else()
if (USE_LUAJIT)
target_link_libraries(test ${LIBUV_LIBRARIES} ${LUAJIT_LIBRARIES})
else ()
target_link_libraries(test ${LIBUV_LIBRARIES} ${LUA_LIBRARIES})
endif ()
endif()
else()
message(STATUS "Lua/LuaJIT libraries not found, test not built.")
endif()

if (NOT LUA)
if (BUILD_MODULE)
if (WIN32)
Expand Down
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,8 @@ clean:

test: luv
${LUABIN} tests/run.lua
@if [ -f $(BUILD_DIR)/test ]; then \
echo "$(BUILD_DIR)/test exists."; \
$(BUILD_DIR)/test tests/manual-test-external-loop.lua; \
fi
$(MAKE) -C $(BUILD_DIR) test
$(BUILD_DIR)/test tests/manual-test-external-loop.lua

reset:
git submodule update --init --recursive && \
Expand Down

0 comments on commit 1b29585

Please sign in to comment.