Skip to content

Commit 762b7f9

Browse files
committed
cmake: initial version of luzer module
The patch add a CMake module that builds a luzer [1], a coverage-guided, native Lua fuzzing engine. Needed for the following commit. 1. https://github.com/ligurio/luzer
1 parent ed4b725 commit 762b7f9

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

cmake/BuildLuzer.cmake

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
set(LUZER_DIR ${PROJECT_BINARY_DIR}/luzer)
2+
set(LUZER_BUILD_DIR ${LUZER_DIR}/build)
3+
set(LUZER_LIBRARY_PATH ${LUZER_BUILD_DIR}/luzer)
4+
list(APPEND LUZER_LIBRARIES
5+
${LUZER_LIBRARY_PATH}/luzer/luzer.so
6+
${LUZER_LIBRARY_PATH}/luzer/libcustom_mutator.so
7+
)
8+
9+
include(ExternalProject)
10+
11+
get_target_property(LUA_LIBRARIES_LOCATION ${LUA_LIBRARIES} LOCATION)
12+
13+
ExternalProject_Add(bundled-luzer
14+
GIT_REPOSITORY https://github.com/ligurio/luzer
15+
GIT_TAG e552a2073a477e173d8c46f7cfa72077e9c00ad6
16+
GIT_PROGRESS TRUE
17+
GIT_SHALLOW FALSE
18+
SOURCE_DIR ${LUZER_DIR}/source
19+
BINARY_DIR ${LUZER_BUILD_DIR}
20+
TMP_DIR ${LUZER_DIR}/tmp
21+
STAMP_DIR ${LUZER_DIR}/stamp
22+
CONFIGURE_COMMAND
23+
${CMAKE_COMMAND} -B <BINARY_DIR> -S <SOURCE_DIR>
24+
-G ${CMAKE_GENERATOR} ${BENCHMARK_CMAKE_FLAGS}
25+
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
26+
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
27+
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
28+
29+
-DLUA_INCLUDE_DIR=${LUA_INCLUDE_DIR}
30+
-DLUA_LIBRARIES=${LUA_LIBRARIES_LOCATION}
31+
BUILD_COMMAND cd <BINARY_DIR> && ${CMAKE_MAKE_PROGRAM}
32+
INSTALL_COMMAND ""
33+
CMAKE_GENERATOR ${CMAKE_GENERATOR}
34+
BUILD_BYPRODUCTS ${LUZER_LIBRARIES}
35+
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
36+
)
37+
38+
add_library(luzer-library STATIC IMPORTED GLOBAL)
39+
set_target_properties(luzer-library PROPERTIES
40+
IMPORTED_LOCATION "${LUZER_LIBRARIES}")
41+
add_dependencies(luzer-library bundled-luzer)
42+
add_dependencies(bundled-luzer bundled-liblua)
43+
44+
set(LUZER_LUA_PATH ${LUZER_DIR}/source/?/init.lua)
45+
set(LUZER_LUA_PATH ${LUZER_LUA_PATH} PARENT_SCOPE)
46+
47+
set(LUZER_LUA_CPATH ${LUZER_LIBRARY_PATH}/?${CMAKE_SHARED_LIBRARY_SUFFIX})
48+
set(LUZER_LUA_CPATH ${LUZER_LUA_CPATH} PARENT_SCOPE)
49+
50+
set(LUZER_LIBRARY luzer-library PARENT_SCOPE)
51+
52+
unset(LUZER_DIR)
53+
unset(LUZER_BUILD_DIR)

0 commit comments

Comments
 (0)