improve cmake further

This commit is contained in:
Green Sky 2023-10-25 21:00:22 +02:00
parent a52218ad2f
commit bfe7257a5a
No known key found for this signature in database
2 changed files with 54 additions and 36 deletions

View File

@ -5,12 +5,22 @@ project(solanaceae_clamav)
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(SOLANACEAE_CLAMAV_STANDALONE ON) set(SOLANACEAE_CLAMAV_STANDALONE ON)
# why the f do i need this >:(
set(NOT_SOLANACEAE_CLAMAV_STANDALONE OFF)
else() else()
set(SOLANACEAE_CLAMAV_STANDALONE OFF) set(SOLANACEAE_CLAMAV_STANDALONE OFF)
set(NOT_SOLANACEAE_CLAMAV_STANDALONE ON)
endif() endif()
message("II SOLANACEAE_CLAMAV_STANDALONE " ${SOLANACEAE_CLAMAV_STANDALONE}) message("II SOLANACEAE_CLAMAV_STANDALONE " ${SOLANACEAE_CLAMAV_STANDALONE})
option(SOLANACEAE_CLAMAV_BUILD_PLUGINS "Build the clamav plugins" ${SOLANACEAE_CLAMAV_STANDALONE}) option(SOLANACEAE_CLAMAV_INTERFACE_ONLY
"Only provide the interfaces. (effectively disabled external depencencies)"
${NOT_SOLANACEAE_CLAMAV_STANDALONE}
)
option(SOLANACEAE_CLAMAV_BUILD_PLUGINS
"Build the clamav plugins"
${SOLANACEAE_CLAMAV_STANDALONE}
)
if (SOLANACEAE_CLAMAV_STANDALONE) if (SOLANACEAE_CLAMAV_STANDALONE)
set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON)
@ -30,7 +40,9 @@ if (SOLANACEAE_CLAMAV_STANDALONE)
endif() endif()
# external libs # external libs
if (NOT SOLANACEAE_CLAMAV_INTERFACE_ONLY)
add_subdirectory(./external) # before increasing warn levels, sad :( add_subdirectory(./external) # before increasing warn levels, sad :(
endif()
if (SOLANACEAE_CLAMAV_STANDALONE) if (SOLANACEAE_CLAMAV_STANDALONE)
@ -65,7 +77,7 @@ endif()
add_subdirectory(./src) add_subdirectory(./src)
if (SOLANACEAE_CLAMAV_BUILD_PLUGINS) if (NOT SOLANACEAE_CLAMAV_INTERFACE_ONLY AND SOLANACEAE_CLAMAV_BUILD_PLUGINS)
add_subdirectory(./plugins) add_subdirectory(./plugins)
endif() endif()

View File

@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 3.24 FATAL_ERROR) cmake_minimum_required(VERSION 3.24 FATAL_ERROR)
add_library(solanaceae_clamav_interface INTERFACE add_library(solanaceae_clamav_interface INTERFACE
./solanaceae/clamav/clamav_module_interface.hpp ./solanaceae/clamav/clamav_module_interface.hpp
) )
@ -8,6 +10,16 @@ target_compile_features(solanaceae_clamav_interface INTERFACE cxx_std_17)
######################################## ########################################
add_library(solanaceae_clamav_async_interface INTERFACE
./solanaceae/clamav/clamav_module_async_interface.hpp
)
target_include_directories(solanaceae_clamav_async_interface INTERFACE .)
target_compile_features(solanaceae_clamav_async_interface INTERFACE cxx_std_17)
########################################
if (NOT ${SOLANACEAE_CLAMAV_INTERFACE_ONLY})
add_library(solanaceae_clamav add_library(solanaceae_clamav
./solanaceae/clamav/clamav_module.hpp ./solanaceae/clamav/clamav_module.hpp
./solanaceae/clamav/clamav_module.cpp ./solanaceae/clamav/clamav_module.cpp
@ -22,14 +34,6 @@ target_link_libraries(solanaceae_clamav PUBLIC
######################################## ########################################
add_library(solanaceae_clamav_async_interface INTERFACE
./solanaceae/clamav/clamav_module_async_interface.hpp
)
target_include_directories(solanaceae_clamav_async_interface INTERFACE .)
target_compile_features(solanaceae_clamav_async_interface INTERFACE cxx_std_17)
########################################
add_library(solanaceae_clamav_async_wrapper add_library(solanaceae_clamav_async_wrapper
./solanaceae/clamav/clamav_module_async_wrapper.hpp ./solanaceae/clamav/clamav_module_async_wrapper.hpp
./solanaceae/clamav/clamav_module_async_wrapper.cpp ./solanaceae/clamav/clamav_module_async_wrapper.cpp
@ -39,6 +43,7 @@ target_link_libraries(solanaceae_clamav_async_wrapper PUBLIC
solanaceae_clamav_async_interface solanaceae_clamav_async_interface
) )
######################################## ########################################
if (SOLANACEAE_CLAMAV_STANDALONE) if (SOLANACEAE_CLAMAV_STANDALONE)
@ -55,3 +60,4 @@ if (SOLANACEAE_CLAMAV_STANDALONE)
endif() endif()
endif()