@@ -240,6 +240,17 @@ if(WIN32)
240240 add_definitions (-DLUA_BUILD_AS_DLL -DLUA_LIB)
241241endif ()
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+
243254foreach (TARGET_NAME ${ACTIVE_TARGETS} )
244255 if (WIN32 OR CYGWIN )
245256 if (LUA)
@@ -262,39 +273,6 @@ foreach(TARGET_NAME ${ACTIVE_TARGETS})
262273 endif ()
263274endforeach ()
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-
298276if (NOT LUA)
299277 if (BUILD_MODULE)
300278 if (WIN32 )
0 commit comments