From 036ed9ea1ecd19a4022a176193310aad4f19fe16 Mon Sep 17 00:00:00 2001 From: simon987 Date: Fri, 15 Apr 2022 15:35:20 -0400 Subject: [PATCH] Update libmagic cmake things --- CMakeLists.txt | 21 +++++++++++++++++---- third-party/libscan/CMakeLists.txt | 16 ++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 59b0d65..d47ee37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,7 @@ set(CMAKE_C_STANDARD 11) project(sist2 C) option(SIST_DEBUG "Build a debug executable" on) +option(SIST_FAST "Enable more optimisation flags" off) option(SIST_FAKE_STORE "Disable IO operations of LMDB stores for debugging purposes" 0) add_compile_definitions( @@ -54,6 +55,10 @@ find_package(lmdb CONFIG REQUIRED) find_package(cJSON CONFIG REQUIRED) find_package(unofficial-mongoose CONFIG REQUIRED) find_package(CURL CONFIG REQUIRED) +find_library(MAGIC_LIB + NAMES libmagic.so.1 magic + PATHS /usr/lib/x86_64-linux-gnu/ /usr/lib/aarch64-linux-gnu/ +) target_include_directories( @@ -93,16 +98,25 @@ if (SIST_DEBUG) PROPERTIES OUTPUT_NAME sist2_debug ) +elseif (SIST_FAST) + target_compile_options( + sist2 + PRIVATE + + -Ofast + -march=native + -fno-stack-protector + -fomit-frame-pointer + -freciprocal-math + ) else () target_compile_options( sist2 PRIVATE -Ofast - #-march=native -fno-stack-protector -fomit-frame-pointer - #-freciprocal-math ) endif () @@ -124,13 +138,12 @@ target_link_libraries( CURL::libcurl pthread - #magic c scan - /usr/lib/x86_64-linux-gnu/libmagic.so.1 + ${MAGIC_LIB} ) add_custom_target( diff --git a/third-party/libscan/CMakeLists.txt b/third-party/libscan/CMakeLists.txt index 71d2d9f..ea712b8 100644 --- a/third-party/libscan/CMakeLists.txt +++ b/third-party/libscan/CMakeLists.txt @@ -42,6 +42,22 @@ if (SIST_DEBUG) -fsanitize=address -fno-inline ) +elseif (SIST_FAST) + add_compile_definitions( + antiword + NDEBUG + ) + + target_compile_options( + scan + PRIVATE + + -Ofast + -march=native + -fno-stack-protector + -fomit-frame-pointer + -freciprocal-math + ) else() add_compile_definitions( antiword