Skip to content

Commit

Permalink
cmake: introduce IS_LUAJIT
Browse files Browse the repository at this point in the history
  • Loading branch information
ligurio committed Nov 30, 2024
1 parent 5d51a38 commit ba5854f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ 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 (ENABLE_LUAJIT_RANDOM_RA AND NOT USE_LUAJIT)
endif (ENABLE_LUAJIT_RANDOM_RA AND NOT IS_LUAJIT)

if (USE_LUA AND NOT LUA_VERSION)
set(LUA_VERSION "master")
endif()

if (USE_LUAJIT AND NOT LUA_VERSION)
if (IS_LUAJIT AND NOT LUA_VERSION)
set(LUA_VERSION "v2.1")
endif()

Expand All @@ -50,6 +50,7 @@ if (USE_LUA)
elseif (USE_LUAJIT)
include(BuildLuaJIT)
build_luajit(${LUA_VERSION})
set(IS_LUAJIT TRUE)
elseif (LUA_INCLUDE_DIR AND LUA_LIBRARIES AND LUA_EXECUTABLE AND LUA_VERSION_STRING)
message(STATUS "Lua library passed outside:")
message(STATUS "LUA_INCLUDE_DIR: ${LUA_INCLUDE_DIR}")
Expand Down
12 changes: 6 additions & 6 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_TARGET})
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,9 +101,9 @@ function(create_test)
LABELS capi
)

if (USE_LUAJIT)
if (IS_LUAJIT)
target_compile_definitions(${test_name} PUBLIC LUAJIT)
endif (USE_LUAJIT)
endif (IS_LUAJIT)
endfunction()

# These Lua C functions are unsupported by LuaJIT.
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 ba5854f

Please sign in to comment.