mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-23 20:07:49 +08:00
c5f77be5c5
* [yara] Remove Windows-only assumptions in CMakeLists.txt Fixes x64-linux build. Addresses GitHub vcpkg issue #4411. Defines `libyara_dependencies` and `libyara_definitions` CMake variables to simplify calls to `target_link_libraries` and `target_compile_definitions`, respectively. Replaces `USE_WINDOWS_PROC` definition with platform-specific definition (e.g., `USE_LINUX_PROC`) based on how `proc_interface` is defined in configure.ac. Currently supports only Windows, Linux, and Darwin. Replaces libyara/proc/windows.c source file with platform-specific source file from libyara/proc. Adds missing libyara/endian.c and libyara/stopwatch.c source files to `libyara_sources` variable. Addresses missing byte-swap symbols (`_yr_bswap16`, `_yr_bswap32`, and `_yr_bswap64`). Adds `find_package` call for `Threads`, setting pthread as preferred threads library in Linux. Adds `Threads::Threads` as a libyara dependency. Addresses missing thread and semaphore symbols. Adds `m` (math library) as a dependency if building with GCC to address missing `log2` symbol. * [yara] Bump control version
142 lines
2.9 KiB
CMake
142 lines
2.9 KiB
CMake
cmake_minimum_required(VERSION 3.8)
|
|
project(yara C)
|
|
|
|
if(MSVC)
|
|
add_compile_options(/W3 /wd4005 /wd4996 /wd4018 -D_CRT_SECURE_NO_WARNINGS)
|
|
endif()
|
|
|
|
|
|
find_package(OpenSSL REQUIRED)
|
|
find_path(JANSSON_INCLUDE_DIR NAMES jansson.h)
|
|
find_library(JANSSON_LIBRARY NAMES jansson)
|
|
|
|
|
|
include_directories(
|
|
.
|
|
libyara
|
|
libyara/include
|
|
)
|
|
|
|
set(PROC_PLATFORM_SOURCE "libyara/proc/none.c")
|
|
set(PROC_PLATFORM_INTERFACE "USE_NO_PROC")
|
|
|
|
if(APPLE AND CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
|
set(PROC_PLATFORM_SOURCE "libyara/proc/mach.c")
|
|
set(PROC_PLATFORM_INTERFACE "USE_MACH_PROC")
|
|
elseif(WIN32 OR MINGW OR CYGWIN)
|
|
set(PROC_PLATFORM_SOURCE "libyara/proc/windows.c")
|
|
set(PROC_PLATFORM_INTERFACE "USE_WINDOWS_PROC")
|
|
elseif(UNIX AND CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
|
set(PROC_PLATFORM_SOURCE "libyara/proc/linux.c")
|
|
set(PROC_PLATFORM_INTERFACE "USE_LINUX_PROC")
|
|
endif()
|
|
|
|
set(
|
|
libyara_sources
|
|
libyara/ahocorasick.c
|
|
libyara/arena.c
|
|
libyara/atoms.c
|
|
libyara/compiler.c
|
|
libyara/endian.c
|
|
libyara/exec.c
|
|
libyara/exefiles.c
|
|
libyara/filemap.c
|
|
libyara/grammar.c
|
|
libyara/hash.c
|
|
libyara/hex_grammar.c
|
|
libyara/hex_lexer.c
|
|
libyara/lexer.c
|
|
libyara/libyara.c
|
|
libyara/mem.c
|
|
libyara/modules.c
|
|
libyara/modules/cuckoo.c
|
|
libyara/modules/dotnet.c
|
|
libyara/modules/elf.c
|
|
libyara/modules/hash.c
|
|
libyara/modules/math.c
|
|
libyara/modules/macho.c
|
|
libyara/modules/pe.c
|
|
libyara/modules/pe_utils.c
|
|
libyara/modules/tests.c
|
|
libyara/modules/time.c
|
|
libyara/object.c
|
|
libyara/parser.c
|
|
libyara/proc.c
|
|
${PROC_PLATFORM_SOURCE}
|
|
libyara/re.c
|
|
libyara/re_grammar.c
|
|
libyara/re_lexer.c
|
|
libyara/rules.c
|
|
libyara/scan.c
|
|
libyara/sizedstr.c
|
|
libyara/stopwatch.c
|
|
libyara/stream.c
|
|
libyara/strutils.c
|
|
libyara/threading.c
|
|
)
|
|
|
|
set(
|
|
yara_sources
|
|
args.c
|
|
threading.c
|
|
yara.c
|
|
)
|
|
set( yarac_sources
|
|
args.c
|
|
yarac.c
|
|
)
|
|
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
set(
|
|
libyara_dependencies
|
|
OpenSSL::SSL
|
|
OpenSSL::Crypto
|
|
Threads::Threads
|
|
${JANSSON_LIBRARY}
|
|
)
|
|
|
|
if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
|
|
list(APPEND libyara_dependencies m)
|
|
endif()
|
|
|
|
set(
|
|
libyara_definitions
|
|
-DHAVE_LIBCRYPTO
|
|
-D${PROC_PLATFORM_INTERFACE}
|
|
-DCUCKOO_MODULE
|
|
-DHASH_MODULE
|
|
-DDOTNET_MODULE
|
|
)
|
|
|
|
add_library(libyara ${libyara_sources})
|
|
target_link_libraries(libyara PRIVATE ${libyara_dependencies})
|
|
target_compile_definitions(libyara PRIVATE ${libyara_definitions})
|
|
|
|
|
|
add_executable(yara ${yara_sources})
|
|
add_executable(yarac ${yarac_sources})
|
|
|
|
target_link_libraries(yarac PRIVATE libyara ${libyara_dependencies})
|
|
target_link_libraries(yara PRIVATE libyara ${libyara_dependencies})
|
|
|
|
install(
|
|
TARGETS libyara
|
|
RUNTIME DESTINATION bin
|
|
LIBRARY DESTINATION lib
|
|
ARCHIVE DESTINATION lib
|
|
)
|
|
|
|
if(NOT DISABLE_INSTALL_TOOLS)
|
|
install (
|
|
TARGETS yarac yara
|
|
RUNTIME DESTINATION tools/yara
|
|
)
|
|
endif()
|
|
|
|
if(NOT DISABLE_INSTALL_HEADERS)
|
|
install(DIRECTORY libyara/include/ DESTINATION include)
|
|
endif()
|