fix(cmake): various fixes for windows build

Signed-off-by: Roberto Scolaro <roberto.scolaro21@gmail.com>

Signed-off-by: Roberto Scolaro <roberto.scolaro21@gmail.com>
This commit is contained in:
Roberto Scolaro 2023-10-24 15:53:18 +00:00 committed by poiana
parent e0f7c597be
commit 916d571cd0
2 changed files with 47 additions and 22 deletions

View File

@ -109,9 +109,11 @@ endif()
# explicitly set hardening flags # explicitly set hardening flags
set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(FALCO_SECURITY_FLAGS "") set(FALCO_SECURITY_FLAGS "")
if(NOT EMSCRIPTEN AND NOT APPLE) if(LINUX)
set(FALCO_SECURITY_FLAGS "${FALCO_SECURITY_FLAGS} -Wl,-z,relro,-z,now -fstack-protector-strong") set(FALCO_SECURITY_FLAGS "${FALCO_SECURITY_FLAGS} -Wl,-z,relro,-z,now -fstack-protector-strong")
endif() endif()
if(NOT WIN32)
if(CMAKE_BUILD_TYPE STREQUAL "release") if(CMAKE_BUILD_TYPE STREQUAL "release")
set(FALCO_SECURITY_FLAGS "${FALCO_SECURITY_FLAGS} -D_FORTIFY_SOURCE=2") set(FALCO_SECURITY_FLAGS "${FALCO_SECURITY_FLAGS} -D_FORTIFY_SOURCE=2")
endif() endif()
@ -134,6 +136,24 @@ set(CMAKE_CXX_FLAGS_DEBUG "${FALCO_EXTRA_DEBUG_FLAGS}")
set(CMAKE_C_FLAGS_RELEASE "-O3 -fno-strict-aliasing -DNDEBUG") set(CMAKE_C_FLAGS_RELEASE "-O3 -fno-strict-aliasing -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -fno-strict-aliasing -DNDEBUG") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -fno-strict-aliasing -DNDEBUG")
else()
add_compile_definitions(_HAS_STD_BYTE=0)
set(FALCO_SECURITY_FLAGS_WIN "-D_CRT_SECURE_NO_WARNINGS -DWIN32 -DMINIMAL_BUILD /EHsc /W3 /Zi")
set(FALCO_SECURITY_FLAGS_WIN_DEBUG "/MTd /Od")
set(FALCO_SECURITY_FLAGS_WIN_RELEASE "/MT")
set(CMAKE_C_FLAGS "${FALCO_SECURITY_FLAGS_WIN}")
set(CMAKE_CXX_FLAGS "${FALCO_SECURITY_FLAGS_WIN}")
set(CMAKE_C_FLAGS_DEBUG "${FALCO_SECURITY_FLAGS_WIN_DEBUG}")
set(CMAKE_CXX_FLAGS_DEBUG "${FALCO_SECURITY_FLAGS_WIN_DEBUG}")
set(CMAKE_C_FLAGS_RELEASE "${FALCO_SECURITY_FLAGS_WIN_RELEASE}")
set(CMAKE_CXX_FLAGS_RELEASE "${FALCO_SECURITY_FLAGS_WIN_RELEASE}")
endif()
set(PACKAGE_NAME "falco") set(PACKAGE_NAME "falco")
set(DRIVER_NAME "falco") set(DRIVER_NAME "falco")
set(DRIVER_DEVICE_NAME "falco") set(DRIVER_DEVICE_NAME "falco")
@ -174,6 +194,9 @@ include(njson)
include(yaml-cpp) include(yaml-cpp)
if(NOT WIN32 AND NOT APPLE AND NOT MINIMAL_BUILD AND NOT EMSCRIPTEN) if(NOT WIN32 AND NOT APPLE AND NOT MINIMAL_BUILD AND NOT EMSCRIPTEN)
# jq
include(jq)
# OpenSSL # OpenSSL
include(openssl) include(openssl)

View File

@ -102,6 +102,8 @@ else()
message(STATUS "No strlcpy and strlcat found, will use local definition") message(STATUS "No strlcpy and strlcat found, will use local definition")
endif() endif()
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
include(driver) include(driver)
endif()
include(libscap) include(libscap)
include(libsinsp) include(libsinsp)