diff --git a/.github/workflows/showcase.yml b/.github/workflows/showcase.yml index db54b93..450feae 100644 --- a/.github/workflows/showcase.yml +++ b/.github/workflows/showcase.yml @@ -32,6 +32,7 @@ jobs: cmake .. -DCMAKE_BUILD_TYPE=Debug \ -DWITH_COVERAGE=YES \ -DWITH_FORTIFY_SOURCE=YES \ + -DWITH_FORTIFY_SOURCE_LEVEL=3 \ -DWITH_ASAN=YES make diff --git a/CMakeLists.txt b/CMakeLists.txt index dd881e2..961c054 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,12 +7,15 @@ set(CMAKE_C_STANDARD 99) option(WITH_COVERAGE "Enable code coverage" OFF) option(ALWAYS_VERBOSE "stcunit output is permanently verbose" OFF) -option(WITH_FORTIFY_SOURCE "Enable FORTIFY_SOURCE_LEVEL" 0) -option(WITH_ASAN "Enable Address Sanitizer") +option(WITH_FORTIFY_SOURCE "Enable _FORTIFY_SOURCE" OFF) +set(CACHE{WITH_FORTIFY_SOURCE_LEVEL} + TYPE STRING + HELP "Enable _FORTIFY_SOURCE level" + CACHE + VALUE 3 +) -if (WITH_FORTIFY_SOURCE GREATER 0) - # -endif() +option(WITH_ASAN "Enable Address Sanitizer") add_compile_options(-Wall -Wextra -pedantic -fvisibility=hidden) @@ -30,10 +33,10 @@ endif() add_executable(stcunit_showcase stcunit.h showcase.c) if (WITH_FORTIFY_SOURCE) target_compile_options(stcunit_showcase PRIVATE -g -O3 -fstack-protector-all) - target_compile_definitions(stcunit_showcase PRIVATE _FORTIFY_SOURCE=3) + target_compile_definitions(stcunit_showcase PRIVATE _FORTIFY_SOURCE=${WITH_FORTIFY_SOURCE_LEVEL}) endif() if (WITH_ASAN) - target_compile_options(stcunit_showcase PRIVATE -fsanitize=address) + target_compile_options(stcunit_showcase PRIVATE -g -fno-omit-frame-pointer -fsanitize=address) target_link_options(stcunit_showcase PRIVATE -fsanitize=address) endif()