Skip to content

Commit 1b29585

Browse files
authored
Merge pull request #752 from squeek502/test-exclude-from-all
Clean up test step and exclude it from the "all" target
2 parents b17d6e6 + 61e0f36 commit 1b29585

File tree

2 files changed

+13
-37
lines changed

2 files changed

+13
-37
lines changed

CMakeLists.txt

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,17 @@ if(WIN32)
240240
add_definitions(-DLUA_BUILD_AS_DLL -DLUA_LIB)
241241
endif()
242242

243+
add_executable(test EXCLUDE_FROM_ALL src/test.c src/luv.c)
244+
# Need to link Lua/LuaJIT libraries on non-Windows for the test executable
245+
if ((LUAJIT_LIBRARIES OR LUA_LIBRARIES) AND NOT (WIN32 OR CYGWIN))
246+
if(USE_LUAJIT)
247+
target_link_libraries(test ${LUAJIT_LIBRARIES})
248+
else()
249+
target_link_libraries(test ${LUA_LIBRARIES})
250+
endif()
251+
endif()
252+
list(APPEND ACTIVE_TARGETS "test")
253+
243254
foreach(TARGET_NAME ${ACTIVE_TARGETS})
244255
if(WIN32 OR CYGWIN)
245256
if (LUA)
@@ -262,39 +273,6 @@ foreach(TARGET_NAME ${ACTIVE_TARGETS})
262273
endif()
263274
endforeach()
264275

265-
if(LUAJIT_LIBRARIES OR LUA_LIBRARIES)
266-
add_executable(test src/test.c src/luv.c)
267-
if(WIN32 OR CYGWIN)
268-
if (LUA)
269-
target_link_libraries(test ${LIBUV_LIBRARIES} ${LUA_LIBRARIES})
270-
else (LUA)
271-
if (USE_LUAJIT)
272-
target_link_libraries(test ${LIBUV_LIBRARIES} ${LUAJIT_LIBRARIES})
273-
else (USE_LUAJIT)
274-
if (LUA_BUILD_TYPE STREQUAL System)
275-
target_link_libraries(test ${LIBUV_LIBRARIES} ${LUA_LIBRARIES})
276-
else (LUA_BUILD_TYPE STREQUAL System)
277-
target_link_libraries(test ${LIBUV_LIBRARIES} lualib)
278-
endif (LUA_BUILD_TYPE STREQUAL System)
279-
endif (USE_LUAJIT)
280-
endif (LUA)
281-
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
282-
if (USE_LUAJIT)
283-
target_link_libraries(test ${LIBUV_LIBRARIES} ${LUAJIT_LIBRARIES} rt)
284-
else ()
285-
target_link_libraries(test ${LIBUV_LIBRARIES} ${LUA_LIBRARIES} rt)
286-
endif ()
287-
else()
288-
if (USE_LUAJIT)
289-
target_link_libraries(test ${LIBUV_LIBRARIES} ${LUAJIT_LIBRARIES})
290-
else ()
291-
target_link_libraries(test ${LIBUV_LIBRARIES} ${LUA_LIBRARIES})
292-
endif ()
293-
endif()
294-
else()
295-
message(STATUS "Lua/LuaJIT libraries not found, test not built.")
296-
endif()
297-
298276
if (NOT LUA)
299277
if (BUILD_MODULE)
300278
if (WIN32)

Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,8 @@ clean:
7070

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

7876
reset:
7977
git submodule update --init --recursive && \

0 commit comments

Comments
 (0)