2021-02-26 17:29:57 +01:00
|
|
|
cmake_minimum_required(VERSION 3.16)
|
2021-02-26 13:35:19 +01:00
|
|
|
|
|
|
|
set(LIBYARA_SOURCE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/yara/libyara")
|
|
|
|
|
|
|
|
set(LIBYARA_INCLUDES
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/ahocorasick.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/arena.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/atoms.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/bitmask.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/compiler.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/error.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/exec.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/exefiles.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/filemap.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/hash.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/integers.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/libyara.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/limits.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/mem.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/modules.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/object.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/parser.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/proc.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/re.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/rules.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/scan.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/scanner.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/sizedstr.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/stack.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/stopwatch.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/stream.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/strutils.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/threading.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/types.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/include/yara/utils.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/crypto.h
|
2023-03-13 10:24:56 +01:00
|
|
|
${LIBYARA_SOURCE_PATH}/tlshc/tlsh_impl.h
|
|
|
|
${LIBYARA_SOURCE_PATH}/tlshc/tlsh_util.h
|
2021-02-26 13:35:19 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
set(LIBYARA_SOURCE
|
|
|
|
${LIBYARA_SOURCE_PATH}/grammar.y
|
|
|
|
${LIBYARA_SOURCE_PATH}/ahocorasick.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/arena.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/atoms.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/base64.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/bitmask.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/compiler.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/endian.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/exec.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/exefiles.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/filemap.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/hash.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/hex_grammar.y
|
|
|
|
${LIBYARA_SOURCE_PATH}/hex_lexer.l
|
|
|
|
${LIBYARA_SOURCE_PATH}/lexer.l
|
|
|
|
${LIBYARA_SOURCE_PATH}/libyara.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/mem.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/modules.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/notebook.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/object.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/parser.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/proc.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/re.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/re_grammar.y
|
|
|
|
${LIBYARA_SOURCE_PATH}/re_lexer.l
|
|
|
|
${LIBYARA_SOURCE_PATH}/rules.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/scan.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/scanner.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/sizedstr.c
|
2023-03-13 10:24:56 +01:00
|
|
|
${LIBYARA_SOURCE_PATH}/simple_str.c
|
2021-02-26 13:35:19 +01:00
|
|
|
${LIBYARA_SOURCE_PATH}/stack.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/stopwatch.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/strutils.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/stream.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/threading.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/lexer.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/hex_lexer.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/grammar.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/re_lexer.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/hex_grammar.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/re_grammar.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/proc/none.c
|
2023-03-13 10:24:56 +01:00
|
|
|
${LIBYARA_SOURCE_PATH}/tlshc/tlsh.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/tlshc/tlsh_impl.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/tlshc/tlsh_util.c
|
2021-02-26 13:35:19 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
set(LIBYARA_MODULES
|
2022-03-15 23:45:33 +01:00
|
|
|
${LIBYARA_SOURCE_PATH}/modules/console/console.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/modules/dex/dex.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/modules/dotnet/dotnet.c
|
2021-02-26 13:35:19 +01:00
|
|
|
${LIBYARA_SOURCE_PATH}/modules/elf/elf.c
|
2022-03-15 23:45:33 +01:00
|
|
|
${LIBYARA_SOURCE_PATH}/modules/hash/hash.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/modules/macho/macho.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/modules/magic/magic.c
|
2021-02-26 13:35:19 +01:00
|
|
|
${LIBYARA_SOURCE_PATH}/modules/math/math.c
|
2022-03-15 23:45:33 +01:00
|
|
|
${LIBYARA_SOURCE_PATH}/modules/pe/pe.c
|
|
|
|
${LIBYARA_SOURCE_PATH}/modules/pe/pe_utils.c
|
2023-03-13 10:24:56 +01:00
|
|
|
${LIBYARA_SOURCE_PATH}/modules/string/string.c
|
2022-03-15 23:45:33 +01:00
|
|
|
${LIBYARA_SOURCE_PATH}/modules/tests/tests.c
|
2021-02-26 13:35:19 +01:00
|
|
|
${LIBYARA_SOURCE_PATH}/modules/time/time.c
|
2022-03-15 23:45:33 +01:00
|
|
|
)
|
2021-02-26 13:35:19 +01:00
|
|
|
|
2021-12-14 21:27:15 +01:00
|
|
|
find_package(mbedTLS 2.26.0 REQUIRED)
|
2021-02-26 13:35:19 +01:00
|
|
|
|
|
|
|
add_library(libyara STATIC ${LIBYARA_SOURCE} ${LIBYARA_INCLUDES} ${LIBYARA_MODULES})
|
2021-11-25 09:00:17 +01:00
|
|
|
set_property(TARGET libyara PROPERTY POSITION_INDEPENDENT_CODE ON)
|
2021-02-26 13:35:19 +01:00
|
|
|
|
2023-01-04 14:03:09 +01:00
|
|
|
# Add mbedtls crypto wrappers
|
2023-04-13 16:11:39 +02:00
|
|
|
target_compile_definitions(libyara PRIVATE
|
|
|
|
HAVE_MBEDTLS
|
|
|
|
USE_NO_PROC BUCKETS_256 CHECKSUM_3B
|
|
|
|
HASH_MODULE DOTNET_MODULE MAGIC_MODULE MACHO_MODULE DEX_MODULE
|
|
|
|
)
|
2023-01-04 14:03:09 +01:00
|
|
|
|
2023-07-15 10:02:19 +02:00
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
|
|
target_compile_options(libyara PRIVATE -Wno-shift-count-overflow -Wno-stringop-overflow)
|
2023-10-04 12:00:32 +02:00
|
|
|
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
|
|
target_compile_options(libyara PRIVATE -Wno-pointer-sign -Wno-tautological-constant-out-of-range-compare)
|
2023-07-15 10:02:19 +02:00
|
|
|
endif ()
|
2023-01-04 14:03:09 +01:00
|
|
|
|
2021-02-26 13:35:19 +01:00
|
|
|
target_include_directories(
|
|
|
|
libyara
|
2023-10-04 12:00:32 +02:00
|
|
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/yara> $<BUILD_INTERFACE:${LIBYARA_SOURCE_PATH}/include>
|
2021-02-26 17:29:57 +01:00
|
|
|
PRIVATE ${LIBYARA_SOURCE_PATH} ${MBEDTLS_INCLUDE_DIR}
|
2021-02-26 13:35:19 +01:00
|
|
|
)
|
|
|
|
|
2021-12-14 21:27:15 +01:00
|
|
|
target_link_directories(libyara PRIVATE ${MBEDTLS_LIBRARY_DIR})
|
|
|
|
|
2021-02-26 13:35:19 +01:00
|
|
|
if (UNIX)
|
2021-12-14 21:27:15 +01:00
|
|
|
target_link_libraries(libyara PRIVATE magic ${MBEDTLS_LIBRARIES} pthread)
|
2021-04-18 20:24:42 +02:00
|
|
|
else ()
|
2021-12-14 21:27:15 +01:00
|
|
|
target_link_libraries(libyara PRIVATE magic ${MBEDTLS_LIBRARIES})
|
2021-02-26 13:35:19 +01:00
|
|
|
endif ()
|
|
|
|
|
|
|
|
include(GNUInstallDirs)
|
2023-08-06 01:52:23 +02:00
|
|
|
|
2021-11-25 09:00:17 +01:00
|
|
|
set(CMAKE_STATIC_LIBRARY_PREFIX "")
|