vectorscan/tools/hscollider/CMakeLists.txt
Mitchell Wasson 9c139c3a6d Correct set_source_files_properties usage
The use of `CMAKE_BINARY_DIR` and `CMAKE_CURRENT_BINARY_DIR` when
specifying files to set_source_files_properties caused problems
when this project is used from another CMake project.

More specifically, these variables aren't set to the expected path,
and the properties are attempted to be set for non-existant files.

This was benign before vectorscan 5.4.8 as the only properties
set were warning suppression flags.

Starting with 5.4.9, `-funsigned-char` was applied to Ragel outputs
using this method. The result is projects depending on Vectorscan
through Cmake do not have this compile flag properly applied.
2023-10-31 09:35:50 -06:00

100 lines
2.6 KiB
CMake

if (NOT CORRECT_PCRE_VERSION)
message(STATUS "PCRE ${PCRE_REQUIRED_VERSION} not found, not building hscollider")
return()
endif()
include_directories(${PCRE_INCLUDE_DIRS})
include(${CMAKE_MODULE_PATH}/backtrace.cmake)
# we need static libs - too much deep magic for shared libs
if (NOT BUILD_STATIC_LIBS)
return ()
endif ()
CHECK_FUNCTION_EXISTS(sigaltstack HAVE_SIGALTSTACK)
CHECK_FUNCTION_EXISTS(sigaction HAVE_SIGACTION)
CHECK_FUNCTION_EXISTS(setrlimit HAVE_SETRLIMIT)
set_source_files_properties(
ColliderCorporaParser.cpp
PROPERTIES
COMPILE_FLAGS "${RAGEL_C_FLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}")
ragelmaker(ColliderCorporaParser.rl)
if (BUILD_CHIMERA)
add_definitions(-DHS_HYBRID)
endif()
# only set these after all tests are done
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXX_FLAGS}")
SET(hscollider_SOURCES
common.h
BoundedQueue.h
Corpora.cpp
FileCorpora.h
FileCorpora.cpp
ColliderCorporaParser.h
ColliderCorporaParser.cpp
NfaGeneratedCorpora.h
NfaGeneratedCorpora.cpp
GraphTruth.h
GraphTruth.cpp
GroundTruth.h
GroundTruth.cpp
UltimateTruth.h
UltimateTruth.cpp
ResultSet.h
args.cpp
args.h
limit.cpp
pcre_util.cpp
sig.cpp
sig.h
DatabaseProxy.h
Thread.h
Thread.cpp
main.cpp
)
set_source_files_properties(${hscollider_SOURCES} PROPERTIES
INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR})
add_executable(hscollider ${hscollider_SOURCES})
add_dependencies(hscollider ragel_ColliderCorporaParser)
if (BUILD_CHIMERA)
target_link_libraries(hscollider hs chimera ${PCRE_LDFLAGS} databaseutil
expressionutil corpusomatic crosscompileutil pthread
"${BACKTRACE_LDFLAGS}")
else()
target_link_libraries(hscollider hs ${PCRE_LDFLAGS} databaseutil
expressionutil corpusomatic crosscompileutil pthread
"${BACKTRACE_LDFLAGS}")
endif()
if(HAVE_BACKTRACE)
set_source_files_properties(hscollider_SOURCES COMPILE_FLAGS
"${BACKTRACE_CFLAGS}")
endif()
add_custom_target(
collide_quick_test
COMMAND ${CMAKE_BINARY_DIR}/bin/hscollider
-s ${CMAKE_SOURCE_DIR}/tools/hscollider/test_cases/signatures/collider_tests.txt
-c ${CMAKE_SOURCE_DIR}/tools/hscollider/test_cases/corpora/*
-Z0 -t3
DEPENDS hscollider
)
add_custom_target(
collide_quick_test_block
COMMAND ${CMAKE_BINARY_DIR}/bin/hscollider
-s ${CMAKE_SOURCE_DIR}/tools/hscollider/test_cases/signatures/collider_tests.txt
-c ${CMAKE_SOURCE_DIR}/tools/hscollider/test_cases/corpora/*
-Z0
DEPENDS hscollider
)