Skip to content

Commit b798331

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 b798331

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

cmake/BuildLuzer.cmake

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

0 commit comments

Comments
 (0)