Skip to content

Commit

Permalink
Merge pull request #23
Browse files Browse the repository at this point in the history
  • Loading branch information
AlfredoRamos committed Dec 30, 2024
2 parents eb9281a + 5436a8a commit 950e761
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
extra: --external 7z

- name: Run Cppcheck
run: cppcheck --enable=all --inconclusive --report-progress --std=c++11 src/
run: cppcheck --enable=all --inconclusive --report-progress --std=c++17 src/

- name: Package build
run: |
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ Single application library for Qt without `network` dependency. Based on [Dmitry
### Dependencies

- Qt >= 5.9.2
- Compiler with standard >= C++11
- Compiler with standard >= C++17
- CMake >= 3.18.0

### Build

Expand Down
28 changes: 18 additions & 10 deletions cmake/FindCppStd.cmake
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

include(CheckCXXCompilerFlag)
set(HIGHEST_SUPPORTED_CXX_STANDARD 11)
set(HIGHEST_SUPPORTED_CXX_STANDARD ${CMAKE_CXX_STANDARD})

foreach(STANDARD 23 20 17 14)
string(REPLACE "." "" CXX_STANDARD_FLAG "-std=c++${STANDARD}")
check_cxx_compiler_flag(${CXX_STANDARD_FLAG} SUPPORTED_FLAG)
if(SUPPORTED_FLAG)
set(HIGHEST_SUPPORTED_CXX_STANDARD ${STANDARD})
break()
endif()
foreach(STANDARD 23 20)
string(REPLACE "." "" CXX_STANDARD_FLAG "-std=c++${STANDARD}")
check_cxx_compiler_flag(${CXX_STANDARD_FLAG} SUPPORTED_FLAG)
if(SUPPORTED_FLAG)
set(HIGHEST_SUPPORTED_CXX_STANDARD ${STANDARD})
break()
endif()
endforeach()

set(CMAKE_CXX_STANDARD ${HIGHEST_SUPPORTED_CXX_STANDARD})
add_compile_options(-Wall)
message(STATUS "Using C++${CMAKE_CXX_STANDARD} standard")

add_compile_options(-Wall -Wextra -Werror -fstack-protector-strong -D_FORTIFY_SOURCE=2 -fPIC -O2 -DNDEBUG)
add_link_options(-Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack)

if (CMAKE_BUILD_TYPE MATCHES Debug)
message(STATUS "Enabling sanitizers for Debug build")
add_compile_options(-fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer)
add_link_options(-fsanitize=address -fsanitize=undefined)
endif()
18 changes: 18 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@ include(GNUInstallDirs)
include(FindQtLib)
include(LibBuildType)

target_compile_options(
"${PROJECT_NAME}"
PRIVATE
-fstack-protector-strong
-D_FORTIFY_SOURCE=2
-O2
)

target_link_options(
"${PROJECT_NAME}"
PRIVATE
-Wl,-z,relro
-Wl,-z,now
-Wl,-z,noexecstack
)

target_sources(
"${PROJECT_NAME}"
PRIVATE
Expand All @@ -27,6 +43,8 @@ target_compile_definitions(
SINGLEAPPLICATION_LIBRARY
QT_DEPRECATED_WARNINGS
QT_DISABLE_DEPRECATED_BEFORE=0x050902
QT_NO_DEBUG_OUTPUT
QT_NO_WARNING_OUTPUT
)

set_target_properties(
Expand Down

0 comments on commit 950e761

Please sign in to comment.