mirror of
https://github.com/keepassxreboot/keepassxc
synced 2026-06-08 15:14:27 +00:00
aa0cac5c03
* Remove individual feature flags in favor of a single `KPXC_MINIMAL` flag that removes advanced features from the build. Basic features are no longer guarded by feature flags. * Basic features: Auto-Type, Yubikey, KeeShare * Advanced features include: Browser (and passkeys), SSH Agent, and Secret Service * Networking, Documentation, and Update Checking remain as feature flags to accommodate various distro requirements. This change also cleans up the main CMakeLists.txt by re-arranging some content and placing macros into a dedicated include file. The minimum CMake version was bumped to 3.16.0 to conform to our minimum Ubuntu support of Focal (20.04). This also allows us to default to C++20, we fall back to C++17 for Qt versions less than 5.15.0 due to lack of support. Lastly this change removes the KEEPASSXC_BUILD_TYPE="PreRelease" which is never used. We only support "Snapshot" and "Release" now. Additional cleanup of CMakeLists: 1. Removed always-true CMake version guard if(CMAKE_VERSION >= 3.14.0) 2. Removed dead GCC 4.8 stack protector fallback; C++20 requires GCC 10+, and -fstack-protector-strong has been available since GCC 4.9. 3. Removed dead ASan LSan version guard for the same reason. 4. Converted set_target_properties( COMPILE_DEFINITIONS) to target_compile_definitions() on both keepassxc_core and keepassxc_gui. Both are now PRIVATE since the symbol is an internal build detail. 5. Scoped Qt5Gui_PRIVATE_INCLUDE_DIRS to keepassxc_gui preventing Qt-internal headers from leaking into every target in the build. 6. Use cmake_parse_arguments to cleanup test case definition macros. Remove test output formats as they are never used and can be controlled when tests are run. * moved /fsanitize=address to compile options instead of definitions for MSVC builds --------- Co-authored-by: varjolintu <sami.vanttinen@ahmala.org>
66 lines
2.3 KiB
CMake
66 lines
2.3 KiB
CMake
# Copyright (C) 2024 KeePassXC Team <team@keepassxc.org>
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 2 or (at your option)
|
|
# version 3 of the License.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
macro(add_gcc_compiler_cxxflags FLAGS)
|
|
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}")
|
|
endif()
|
|
endmacro()
|
|
|
|
macro(add_gcc_compiler_cflags FLAGS)
|
|
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAGS}")
|
|
endif()
|
|
endmacro()
|
|
|
|
macro(add_gcc_compiler_flags FLAGS)
|
|
add_gcc_compiler_cxxflags("${FLAGS}")
|
|
add_gcc_compiler_cflags("${FLAGS}")
|
|
endmacro()
|
|
|
|
# Copies of above macros that first ensure the compiler understands a given flag
|
|
# Because check_*_compiler_flag() sets -D with name, need to provide "safe" FLAGNAME
|
|
macro(check_add_gcc_compiler_cxxflag FLAG FLAGNAME)
|
|
check_cxx_compiler_flag("${FLAG}" CXX_HAS${FLAGNAME})
|
|
if(CXX_HAS${FLAGNAME})
|
|
add_gcc_compiler_cxxflags("${FLAG}")
|
|
endif()
|
|
endmacro()
|
|
|
|
macro(check_add_gcc_compiler_cflag FLAG FLAGNAME)
|
|
check_c_compiler_flag("${FLAG}" CC_HAS${FLAGNAME})
|
|
if(CC_HAS${FLAGNAME})
|
|
add_gcc_compiler_cflags("${FLAG}")
|
|
endif()
|
|
endmacro()
|
|
|
|
# This is the "front-end" for the above macros
|
|
# Optionally takes additional parameter(s) with language to check (currently "C" or "CXX")
|
|
macro(check_add_gcc_compiler_flag FLAG)
|
|
string(REGEX REPLACE "[-=]" "_" FLAGNAME "${FLAG}")
|
|
set(check_lang_spec ${ARGN})
|
|
list(LENGTH check_lang_spec num_extra_args)
|
|
set(langs C CXX)
|
|
if(num_extra_args GREATER 0)
|
|
set(langs "${check_lang_spec}")
|
|
endif()
|
|
if("C" IN_LIST langs)
|
|
check_add_gcc_compiler_cflag("${FLAG}" "${FLAGNAME}")
|
|
endif()
|
|
if("CXX" IN_LIST langs)
|
|
check_add_gcc_compiler_cxxflag("${FLAG}" "${FLAGNAME}")
|
|
endif()
|
|
endmacro()
|