Skip to content

Commit

Permalink
cmake: introduce IS_LUAJIT
Browse files Browse the repository at this point in the history
Required for setting a Lua library outside.
  • Loading branch information
ligurio committed Dec 9, 2024
1 parent 040f5bb commit 92085b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ set(CMAKE_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_INCLUDE_PATH}
include(SetBuildParallelLevel)
include(SetHardwareArch)

if (ENABLE_LUAJIT_RANDOM_RA AND NOT USE_LUAJIT)
if (ENABLE_LUAJIT_RANDOM_RA AND NOT IS_LUAJIT)
message(FATAL_ERROR "Option ENABLE_LUAJIT_RANDOM_RA is LuaJIT-specific.")
endif()

Expand All @@ -50,6 +50,7 @@ if (USE_LUA)
elseif (USE_LUAJIT)
include(BuildLuaJIT)
build_luajit(${LUA_VERSION})
set(IS_LUAJIT TRUE)
else ()
message(FATAL_ERROR "No Lua is specified.")
endif ()
Expand Down
10 changes: 5 additions & 5 deletions tests/capi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ function(create_test)
add_dependencies(${test_name} ${LUA_LIBRARIES})
string(REPLACE "_test" "" test_prefix ${test_name})
set(LIBFUZZER_OPTS "${LIBFUZZER_OPTS} -artifact_prefix=${test_name}_")
if (USE_LUAJIT AND (${test_name} STREQUAL "lua_dump_test"))
if (IS_LUAJIT AND (${test_name} STREQUAL "lua_dump_test"))
set(LIBFUZZER_OPTS "${LIBFUZZER_OPTS} -only_ascii=1")
endif ()
if (USE_LUAJIT AND (${test_name} STREQUAL "lua_load_test"))
if (IS_LUAJIT AND (${test_name} STREQUAL "lua_load_test"))
set(LIBFUZZER_OPTS "${LIBFUZZER_OPTS} -only_ascii=1")
endif ()
set(dict_path ${PROJECT_SOURCE_DIR}/corpus/${test_name}.dict)
Expand All @@ -101,7 +101,7 @@ function(create_test)
LABELS capi
)

if (USE_LUAJIT)
if (IS_LUAJIT)
target_compile_definitions(${test_name} PUBLIC LUAJIT)
endif()
endfunction()
Expand All @@ -121,7 +121,7 @@ list(APPEND LUAJIT_BLACKLIST_TESTS "luaL_loadstring_test")
file(GLOB tests LIST_DIRECTORIES false ${CMAKE_CURRENT_SOURCE_DIR} *.c *.cc)
foreach(filename ${tests})
get_filename_component(test_name ${filename} NAME_WE)
if (USE_LUAJIT AND (${test_name} IN_LIST LUAJIT_BLACKLIST_TESTS))
if (IS_LUAJIT AND (${test_name} IN_LIST LUAJIT_BLACKLIST_TESTS))
continue()
endif ()
if ((${test_name} IN_LIST BLACKLIST_TESTS))
Expand All @@ -134,6 +134,6 @@ endforeach()

include(ProtobufMutator)
add_subdirectory(luaL_loadbuffer_proto)
if(USE_LUAJIT)
if(IS_LUAJIT)
add_subdirectory(ffi_cdef_proto)
endif ()

0 comments on commit 92085b3

Please sign in to comment.