Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorJonathan White <jwhite.uscg@gmail.com>2018-12-19 06:28:56 +0300
committerJonathan White <jwhite.uscg@gmail.com>2018-12-19 06:28:56 +0300
commit9e2be34897d4a4be7339df2bc0997b312ee7c567 (patch)
tree180cf63a8d3113555b9f2f6f2b5efa358aff32de /cmake
parent66a36b3af11b597da3ae2bb867244443a5b71199 (diff)
parenta070f1bce7efcc5ce89aea533b181b0fa8c6dea0 (diff)
Merge branch 'develop'
Conflicts: CMakeLists.txt cmake/CLangFormat.cmake snapcraft.yaml src/CMakeLists.txt src/core/Database.cpp src/core/Database.h src/core/Tools.cpp src/crypto/CryptoHash.h src/crypto/ssh/ASN1Key.h src/crypto/ssh/OpenSSHKey.cpp src/format/Kdbx4Reader.cpp src/gui/DatabaseTabWidget.cpp src/gui/DatabaseTabWidget.h src/gui/DatabaseWidget.cpp src/gui/DatabaseWidget.h src/gui/DetailsWidget.cpp src/gui/DetailsWidget.ui src/gui/EditWidgetProperties.cpp src/gui/EntryPreviewWidget.cpp src/gui/EntryPreviewWidget.ui src/gui/FileDialog.cpp src/gui/dbsettings/DatabaseSettingsDialog.cpp src/gui/dbsettings/DatabaseSettingsDialog.h src/gui/group/EditGroupWidget.cpp src/gui/group/EditGroupWidget.h src/sshagent/ASN1Key.h src/sshagent/OpenSSHKey.cpp src/sshagent/SSHAgent.cpp tests/CMakeLists.txt
Diffstat (limited to 'cmake')
-rw-r--r--cmake/CLangFormat.cmake62
-rw-r--r--cmake/CodeCoverage.cmake378
-rw-r--r--cmake/FindArgon2.cmake28
-rw-r--r--cmake/FindGcrypt.cmake2
-rw-r--r--cmake/FindQREncode.cmake22
5 files changed, 307 insertions, 185 deletions
diff --git a/cmake/CLangFormat.cmake b/cmake/CLangFormat.cmake
index 68d28311b..3a0274236 100644
--- a/cmake/CLangFormat.cmake
+++ b/cmake/CLangFormat.cmake
@@ -14,45 +14,43 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set(EXCLUDED_DIRS
- # third-party directories
- zxcvbn/
- streams/QtIOCompressor
- # objective-c directories
- autotype/mac
-)
+ # third-party directories
+ zxcvbn/
+ streams/QtIOCompressor
+ # objective-c directories
+ autotype/mac)
set(EXCLUDED_FILES
- # third-party files
- streams/qtiocompressor.cpp
- streams/qtiocompressor.h
- gui/KMessageWidget.h
- gui/KMessageWidget.cpp
- gui/MainWindowAdaptor.h
- gui/MainWindowAdaptor.cpp
- crypto/ssh/bcrypt_pbkdf.cpp
- crypto/ssh/blf.h
- crypto/ssh/blowfish.c
- tests/modeltest.cpp
- tests/modeltest.h
- # objective-c files
- core/ScreenLockListenerMac.h
- core/ScreenLockListenerMac.cpp
-)
+ # third-party files
+ streams/qtiocompressor.cpp
+ streams/qtiocompressor.h
+ gui/KMessageWidget.h
+ gui/KMessageWidget.cpp
+ gui/MainWindowAdaptor.h
+ gui/MainWindowAdaptor.cpp
+ crypto/ssh/bcrypt_pbkdf.cpp
+ crypto/ssh/blf.h
+ crypto/ssh/blowfish.c
+ tests/modeltest.cpp
+ tests/modeltest.h
+ # objective-c files
+ core/ScreenLockListenerMac.h
+ core/ScreenLockListenerMac.cpp)
file(GLOB_RECURSE ALL_SOURCE_FILES *.cpp *.h)
-foreach (SOURCE_FILE ${ALL_SOURCE_FILES})
- foreach (EXCLUDED_DIR ${EXCLUDED_DIRS})
+foreach(SOURCE_FILE ${ALL_SOURCE_FILES})
+ foreach(EXCLUDED_DIR ${EXCLUDED_DIRS})
string(FIND ${SOURCE_FILE} ${EXCLUDED_DIR} SOURCE_FILE_EXCLUDED)
- if (NOT ${SOURCE_FILE_EXCLUDED} EQUAL -1)
+ if(NOT ${SOURCE_FILE_EXCLUDED} EQUAL -1)
list(REMOVE_ITEM ALL_SOURCE_FILES ${SOURCE_FILE})
- endif ()
- endforeach ()
- foreach (EXCLUDED_FILE ${EXCLUDED_FILES})
- if (${SOURCE_FILE} MATCHES ".*${EXCLUDED_FILE}$")
+ endif()
+ endforeach()
+ foreach(EXCLUDED_FILE ${EXCLUDED_FILES})
+ if(${SOURCE_FILE} MATCHES ".*${EXCLUDED_FILE}$")
list(REMOVE_ITEM ALL_SOURCE_FILES ${SOURCE_FILE})
- endif ()
- endforeach ()
-endforeach ()
+ endif()
+ endforeach()
+endforeach()
add_custom_target(
format
diff --git a/cmake/CodeCoverage.cmake b/cmake/CodeCoverage.cmake
index d10f79723..d10791745 100644
--- a/cmake/CodeCoverage.cmake
+++ b/cmake/CodeCoverage.cmake
@@ -1,4 +1,4 @@
-# Copyright (c) 2012 - 2015, Lars Bilke
+# Copyright (c) 2012 - 2017, Lars Bilke
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
@@ -26,7 +26,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
-#
+# CHANGES:
#
# 2012-01-31, Lars Bilke
# - Enable Code Coverage
@@ -35,167 +35,269 @@
# - Added support for Clang.
# - Some additional usage instructions.
#
+# 2016-02-03, Lars Bilke
+# - Refactored functions to use named parameters
+#
+# 2017-06-02, Lars Bilke
+# - Merged with modified version from github.com/ufz/ogs
+#
+#
# USAGE:
-
-# 0. (Mac only) If you use Xcode 5.1 make sure to patch geninfo as described here:
-# http://stackoverflow.com/a/22404544/80480
#
# 1. Copy this file into your cmake modules path.
#
# 2. Add the following line to your CMakeLists.txt:
-# INCLUDE(CodeCoverage)
+# include(CodeCoverage)
#
-# 3. Set compiler flags to turn off optimization and enable coverage:
-# SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
-# SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
+# 3. Append necessary compiler flags:
+# APPEND_COVERAGE_COMPILER_FLAGS()
#
-# 3. Use the function SETUP_TARGET_FOR_COVERAGE to create a custom make target
-# which runs your test executable and produces a lcov code coverage report:
+# 4. If you need to exclude additional directories from the report, specify them
+# using the COVERAGE_LCOV_EXCLUDES variable before calling SETUP_TARGET_FOR_COVERAGE_LCOV.
# Example:
-# SETUP_TARGET_FOR_COVERAGE(
-# my_coverage_target # Name for custom target.
-# test_driver # Name of the test driver executable that runs the tests.
-# # NOTE! This should always have a ZERO as exit code
-# # otherwise the coverage generation will not complete.
-# coverage # Name of output directory.
-# )
+# set(COVERAGE_LCOV_EXCLUDES 'dir1/*' 'dir2/*')
#
-# 4. Build a Debug build:
-# cmake -DCMAKE_BUILD_TYPE=Debug ..
-# make
-# make my_coverage_target
+# 5. Use the functions described below to create a custom make target which
+# runs your test executable and produces a code coverage report.
#
+# 6. Build a Debug build:
+# cmake -DCMAKE_BUILD_TYPE=Debug ..
+# make
+# make my_coverage_target
#
+include(CMakeParseArguments)
+
# Check prereqs
-FIND_PROGRAM( GCOV_PATH gcov )
-FIND_PROGRAM( LCOV_PATH lcov )
-FIND_PROGRAM( GENHTML_PATH genhtml )
-FIND_PROGRAM( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/tests)
-
-IF(NOT GCOV_PATH)
- MESSAGE(FATAL_ERROR "gcov not found! Aborting...")
-ENDIF() # NOT GCOV_PATH
-
-IF("${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang")
- IF("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 3)
- MESSAGE(FATAL_ERROR "Clang version must be 3.0.0 or greater! Aborting...")
- ENDIF()
-ELSEIF(NOT CMAKE_COMPILER_IS_GNUCXX)
- MESSAGE(FATAL_ERROR "Compiler is not GNU gcc! Aborting...")
-ENDIF() # CHECK VALID COMPILER
-
-SET(CMAKE_CXX_FLAGS_COVERAGE
- "-g -O0 --coverage -fprofile-arcs -ftest-coverage"
+find_program( GCOV_PATH gcov )
+find_program( LCOV_PATH NAMES lcov lcov.bat lcov.exe lcov.perl)
+find_program( GENHTML_PATH NAMES genhtml genhtml.perl genhtml.bat )
+find_program( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/scripts/test)
+find_program( SIMPLE_PYTHON_EXECUTABLE python )
+
+if(NOT GCOV_PATH)
+ message(FATAL_ERROR "gcov not found! Aborting...")
+endif() # NOT GCOV_PATH
+
+if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang")
+ if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 3)
+ message(FATAL_ERROR "Clang version must be 3.0.0 or greater! Aborting...")
+ endif()
+elseif(NOT CMAKE_COMPILER_IS_GNUCXX)
+ message(FATAL_ERROR "Compiler is not GNU gcc! Aborting...")
+endif()
+
+set(COVERAGE_COMPILER_FLAGS "-g -O0 --coverage -fprofile-arcs -ftest-coverage"
+ CACHE INTERNAL "")
+
+set(CMAKE_CXX_FLAGS_COVERAGE
+ ${COVERAGE_COMPILER_FLAGS}
CACHE STRING "Flags used by the C++ compiler during coverage builds."
FORCE )
-SET(CMAKE_C_FLAGS_COVERAGE
- "-g -O0 --coverage -fprofile-arcs -ftest-coverage"
+set(CMAKE_C_FLAGS_COVERAGE
+ ${COVERAGE_COMPILER_FLAGS}
CACHE STRING "Flags used by the C compiler during coverage builds."
FORCE )
-SET(CMAKE_EXE_LINKER_FLAGS_COVERAGE
+set(CMAKE_EXE_LINKER_FLAGS_COVERAGE
""
CACHE STRING "Flags used for linking binaries during coverage builds."
FORCE )
-SET(CMAKE_SHARED_LINKER_FLAGS_COVERAGE
+set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE
""
CACHE STRING "Flags used by the shared libraries linker during coverage builds."
FORCE )
-MARK_AS_ADVANCED(
+mark_as_advanced(
CMAKE_CXX_FLAGS_COVERAGE
CMAKE_C_FLAGS_COVERAGE
CMAKE_EXE_LINKER_FLAGS_COVERAGE
CMAKE_SHARED_LINKER_FLAGS_COVERAGE )
-IF ( NOT (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "Coverage"))
- MESSAGE( WARNING "Code coverage results with an optimized (non-Debug) build may be misleading" )
-ENDIF() # NOT CMAKE_BUILD_TYPE STREQUAL "Debug"
-
-
-# Param _targetname The name of new the custom make target
-# Param _testrunner The name of the target which runs the tests.
-# MUST return ZERO always, even on errors.
-# If not, no coverage report will be created!
-# Param _outputname lcov output is generated as _outputname.info
-# HTML report is generated in _outputname/index.html
-# Optional fourth parameter is passed as arguments to _testrunner
-# Pass them in list form, e.g.: "-j;2" for -j 2
-FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname)
-
- IF(NOT LCOV_PATH)
- MESSAGE(FATAL_ERROR "lcov not found! Aborting...")
- ENDIF() # NOT LCOV_PATH
-
- IF(NOT GENHTML_PATH)
- MESSAGE(FATAL_ERROR "genhtml not found! Aborting...")
- ENDIF() # NOT GENHTML_PATH
-
- SET(coverage_info "${CMAKE_BINARY_DIR}/${_outputname}.info")
- IF(MINGW)
- # Replace C:/ with /C for MINGW
- STRING(REGEX REPLACE "^([a-zA-Z]):" "/\\1" coverage_info ${coverage_info})
- ENDIF()
- SET(coverage_cleaned "${coverage_info}.cleaned")
-
- SEPARATE_ARGUMENTS(test_command UNIX_COMMAND "${_testrunner}")
-
- # Setup target
- ADD_CUSTOM_TARGET(${_targetname}
-
- # Cleanup lcov
- ${LCOV_PATH} --directory . --zerocounters
-
- # Run tests
- COMMAND ${test_command} ${ARGV3}
-
- # Capturing lcov counters and generating report
- COMMAND ${LCOV_PATH} --directory . --capture --output-file ${coverage_info}
- COMMAND ${LCOV_PATH} --remove ${coverage_info} 'tests/*' '/usr/*' --output-file ${coverage_cleaned}
- COMMAND ${GENHTML_PATH} -o ${_outputname} ${coverage_cleaned}
- COMMAND ${CMAKE_COMMAND} -E remove ${coverage_info} ${coverage_cleaned}
-
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
- COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report."
- )
-
- # Show info where to find the report
- ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD
- COMMAND ;
- COMMENT "Open ./${_outputname}/index.html in your browser to view the coverage report."
- )
-
-ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE
-
-# Param _targetname The name of new the custom make target
-# Param _testrunner The name of the target which runs the tests
-# Param _outputname cobertura output is generated as _outputname.xml
-# Optional fourth parameter is passed as arguments to _testrunner
-# Pass them in list form, e.g.: "-j;2" for -j 2
-FUNCTION(SETUP_TARGET_FOR_COVERAGE_COBERTURA _targetname _testrunner _outputname)
-
- IF(NOT PYTHON_EXECUTABLE)
- MESSAGE(FATAL_ERROR "Python not found! Aborting...")
- ENDIF() # NOT PYTHON_EXECUTABLE
-
- IF(NOT GCOVR_PATH)
- MESSAGE(FATAL_ERROR "gcovr not found! Aborting...")
- ENDIF() # NOT GCOVR_PATH
-
- ADD_CUSTOM_TARGET(${_targetname}
-
- # Run tests
- ${_testrunner} ${ARGV3}
-
- # Running gcovr
- COMMAND ${GCOVR_PATH} -x -r ${CMAKE_SOURCE_DIR} -e '${CMAKE_SOURCE_DIR}/tests/' -o ${_outputname}.xml
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
- COMMENT "Running gcovr to produce Cobertura code coverage report."
- )
-
- # Show info where to find the report
- ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD
- COMMAND ;
- COMMENT "Cobertura code coverage report saved in ${_outputname}.xml."
- )
-
-ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE_COBERTURA
+if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
+ message(WARNING "Code coverage results with an optimised (non-Debug) build may be misleading")
+endif() # NOT CMAKE_BUILD_TYPE STREQUAL "Debug"
+
+if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ link_libraries(gcov)
+else()
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
+endif()
+
+# Defines a target for running and collection code coverage information
+# Builds dependencies, runs the given executable and outputs reports.
+# NOTE! The executable should always have a ZERO as exit code otherwise
+# the coverage generation will not complete.
+#
+# SETUP_TARGET_FOR_COVERAGE_LCOV(
+# NAME testrunner_coverage # New target name
+# EXECUTABLE testrunner -j ${PROCESSOR_COUNT} # Executable in PROJECT_BINARY_DIR
+# DEPENDENCIES testrunner # Dependencies to build first
+# )
+function(SETUP_TARGET_FOR_COVERAGE_LCOV)
+
+ set(options NONE)
+ set(oneValueArgs NAME)
+ set(multiValueArgs EXECUTABLE EXECUTABLE_ARGS DEPENDENCIES)
+ cmake_parse_arguments(Coverage "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ if(NOT LCOV_PATH)
+ message(FATAL_ERROR "lcov not found! Aborting...")
+ endif() # NOT LCOV_PATH
+
+ if(NOT GENHTML_PATH)
+ message(FATAL_ERROR "genhtml not found! Aborting...")
+ endif() # NOT GENHTML_PATH
+
+ # Setup target
+ add_custom_target(${Coverage_NAME}
+
+ # Cleanup lcov
+ COMMAND ${LCOV_PATH} --gcov-tool ${GCOV_PATH} -directory . --zerocounters
+ # Create baseline to make sure untouched files show up in the report
+ COMMAND ${LCOV_PATH} --gcov-tool ${GCOV_PATH} -c -i -d . -o ${Coverage_NAME}.base
+
+ # Run tests
+ COMMAND ${Coverage_EXECUTABLE}
+
+ # Capturing lcov counters and generating report
+ COMMAND ${LCOV_PATH} --gcov-tool ${GCOV_PATH} --directory . --capture --output-file ${Coverage_NAME}.info
+ # add baseline counters
+ COMMAND ${LCOV_PATH} --gcov-tool ${GCOV_PATH} -a ${Coverage_NAME}.base -a ${Coverage_NAME}.info --output-file ${Coverage_NAME}.total
+ COMMAND ${LCOV_PATH} --gcov-tool ${GCOV_PATH} --remove ${Coverage_NAME}.total ${COVERAGE_LCOV_EXCLUDES} --output-file ${PROJECT_BINARY_DIR}/${Coverage_NAME}.info.cleaned
+ COMMAND ${GENHTML_PATH} -o ${Coverage_NAME} ${PROJECT_BINARY_DIR}/${Coverage_NAME}.info.cleaned
+ COMMAND ${CMAKE_COMMAND} -E remove ${Coverage_NAME}.base ${Coverage_NAME}.total ${PROJECT_BINARY_DIR}/${Coverage_NAME}.info.cleaned
+
+ WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
+ DEPENDS ${Coverage_DEPENDENCIES}
+ COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report."
+ )
+
+ # Show where to find the lcov info report
+ add_custom_command(TARGET ${Coverage_NAME} POST_BUILD
+ COMMAND ;
+ COMMENT "Lcov code coverage info report saved in ${Coverage_NAME}.info."
+ )
+
+ # Show info where to find the report
+ add_custom_command(TARGET ${Coverage_NAME} POST_BUILD
+ COMMAND ;
+ COMMENT "Open ./${Coverage_NAME}/index.html in your browser to view the coverage report."
+ )
+
+endfunction() # SETUP_TARGET_FOR_COVERAGE_LCOV
+
+# Defines a target for running and collection code coverage information
+# Builds dependencies, runs the given executable and outputs reports.
+# NOTE! The executable should always have a ZERO as exit code otherwise
+# the coverage generation will not complete.
+#
+# SETUP_TARGET_FOR_COVERAGE_GCOVR_XML(
+# NAME ctest_coverage # New target name
+# EXECUTABLE ctest -j ${PROCESSOR_COUNT} # Executable in PROJECT_BINARY_DIR
+# DEPENDENCIES executable_target # Dependencies to build first
+# )
+function(SETUP_TARGET_FOR_COVERAGE_GCOVR_XML)
+
+ set(options NONE)
+ set(oneValueArgs NAME)
+ set(multiValueArgs EXECUTABLE EXECUTABLE_ARGS DEPENDENCIES)
+ cmake_parse_arguments(Coverage "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ if(NOT SIMPLE_PYTHON_EXECUTABLE)
+ message(FATAL_ERROR "python not found! Aborting...")
+ endif() # NOT SIMPLE_PYTHON_EXECUTABLE
+
+ if(NOT GCOVR_PATH)
+ message(FATAL_ERROR "gcovr not found! Aborting...")
+ endif() # NOT GCOVR_PATH
+
+ # Combine excludes to several -e arguments
+ set(GCOVR_EXCLUDES "")
+ foreach(EXCLUDE ${COVERAGE_GCOVR_EXCLUDES})
+ list(APPEND GCOVR_EXCLUDES "-e")
+ list(APPEND GCOVR_EXCLUDES "${EXCLUDE}")
+ endforeach()
+
+ add_custom_target(${Coverage_NAME}
+ # Run tests
+ ${Coverage_EXECUTABLE}
+
+ # Running gcovr
+ COMMAND ${GCOVR_PATH} --xml
+ -r ${PROJECT_SOURCE_DIR} ${GCOVR_EXCLUDES}
+ --object-directory=${PROJECT_BINARY_DIR}
+ -o ${Coverage_NAME}.xml
+ WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
+ DEPENDS ${Coverage_DEPENDENCIES}
+ COMMENT "Running gcovr to produce Cobertura code coverage report."
+ )
+
+ # Show info where to find the report
+ add_custom_command(TARGET ${Coverage_NAME} POST_BUILD
+ COMMAND ;
+ COMMENT "Cobertura code coverage report saved in ${Coverage_NAME}.xml."
+ )
+
+endfunction() # SETUP_TARGET_FOR_COVERAGE_GCOVR_XML
+
+# Defines a target for running and collection code coverage information
+# Builds dependencies, runs the given executable and outputs reports.
+# NOTE! The executable should always have a ZERO as exit code otherwise
+# the coverage generation will not complete.
+#
+# SETUP_TARGET_FOR_COVERAGE_GCOVR_HTML(
+# NAME ctest_coverage # New target name
+# EXECUTABLE ctest -j ${PROCESSOR_COUNT} # Executable in PROJECT_BINARY_DIR
+# DEPENDENCIES executable_target # Dependencies to build first
+# )
+function(SETUP_TARGET_FOR_COVERAGE_GCOVR_HTML)
+
+ set(options NONE)
+ set(oneValueArgs NAME)
+ set(multiValueArgs EXECUTABLE EXECUTABLE_ARGS DEPENDENCIES)
+ cmake_parse_arguments(Coverage "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ if(NOT SIMPLE_PYTHON_EXECUTABLE)
+ message(FATAL_ERROR "python not found! Aborting...")
+ endif() # NOT SIMPLE_PYTHON_EXECUTABLE
+
+ if(NOT GCOVR_PATH)
+ message(FATAL_ERROR "gcovr not found! Aborting...")
+ endif() # NOT GCOVR_PATH
+
+ # Combine excludes to several -e arguments
+ set(GCOVR_EXCLUDES "")
+ foreach(EXCLUDE ${COVERAGE_GCOVR_EXCLUDES})
+ list(APPEND GCOVR_EXCLUDES "-e")
+ list(APPEND GCOVR_EXCLUDES "${EXCLUDE}")
+ endforeach()
+
+ add_custom_target(${Coverage_NAME}
+ # Run tests
+ ${Coverage_EXECUTABLE}
+
+ # Create folder
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/${Coverage_NAME}
+
+ # Running gcovr
+ COMMAND ${GCOVR_PATH} --html --html-details
+ -r ${PROJECT_SOURCE_DIR} ${GCOVR_EXCLUDES}
+ --object-directory=${PROJECT_BINARY_DIR}
+ -o ${Coverage_NAME}/index.html
+ WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
+ DEPENDS ${Coverage_DEPENDENCIES}
+ COMMENT "Running gcovr to produce HTML code coverage report."
+ )
+
+ # Show info where to find the report
+ add_custom_command(TARGET ${Coverage_NAME} POST_BUILD
+ COMMAND ;
+ COMMENT "Open ./${Coverage_NAME}/index.html in your browser to view the coverage report."
+ )
+
+endfunction() # SETUP_TARGET_FOR_COVERAGE_GCOVR_HTML
+
+function(APPEND_COVERAGE_COMPILER_FLAGS)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COVERAGE_COMPILER_FLAGS}" PARENT_SCOPE)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}" PARENT_SCOPE)
+ message(STATUS "Appending code coverage compiler flags: ${COVERAGE_COMPILER_FLAGS}")
+endfunction() # APPEND_COVERAGE_COMPILER_FLAGS \ No newline at end of file
diff --git a/cmake/FindArgon2.cmake b/cmake/FindArgon2.cmake
index bb2f5811d..766e659b3 100644
--- a/cmake/FindArgon2.cmake
+++ b/cmake/FindArgon2.cmake
@@ -14,21 +14,21 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
find_path(ARGON2_INCLUDE_DIR argon2.h)
-if (MINGW)
- # find static library on Windows, and redefine used symbols to
- # avoid definition name conflicts with libsodium
- find_library(ARGON2_SYS_LIBRARIES libargon2.a)
- message(STATUS "Patching libargon2...\n")
- execute_process(COMMAND objcopy
- --redefine-sym argon2_hash=libargon2_argon2_hash
- --redefine-sym _argon2_hash=_libargon2_argon2_hash
- --redefine-sym argon2_error_message=libargon2_argon2_error_message
- --redefine-sym _argon2_error_message=_libargon2_argon2_error_message
- ${ARGON2_SYS_LIBRARIES} ${CMAKE_BINARY_DIR}/libargon2_patched.a
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
- find_library(ARGON2_LIBRARIES libargon2_patched.a PATHS ${CMAKE_BINARY_DIR} NO_DEFAULT_PATH)
+if(MINGW)
+ # find static library on Windows, and redefine used symbols to
+ # avoid definition name conflicts with libsodium
+ find_library(ARGON2_SYS_LIBRARIES libargon2.a)
+ message(STATUS "Patching libargon2...\n")
+ execute_process(COMMAND objcopy
+ --redefine-sym argon2_hash=libargon2_argon2_hash
+ --redefine-sym _argon2_hash=_libargon2_argon2_hash
+ --redefine-sym argon2_error_message=libargon2_argon2_error_message
+ --redefine-sym _argon2_error_message=_libargon2_argon2_error_message
+ ${ARGON2_SYS_LIBRARIES} ${CMAKE_BINARY_DIR}/libargon2_patched.a
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
+ find_library(ARGON2_LIBRARIES libargon2_patched.a PATHS ${CMAKE_BINARY_DIR} NO_DEFAULT_PATH)
else()
- find_library(ARGON2_LIBRARIES argon2)
+ find_library(ARGON2_LIBRARIES argon2)
endif()
mark_as_advanced(ARGON2_LIBRARIES ARGON2_INCLUDE_DIR)
diff --git a/cmake/FindGcrypt.cmake b/cmake/FindGcrypt.cmake
index 077570462..59c6f473a 100644
--- a/cmake/FindGcrypt.cmake
+++ b/cmake/FindGcrypt.cmake
@@ -22,7 +22,7 @@ mark_as_advanced(GCRYPT_LIBRARIES GCRYPT_INCLUDE_DIR)
if(GCRYPT_INCLUDE_DIR AND EXISTS "${GCRYPT_INCLUDE_DIR}/gcrypt.h")
file(STRINGS "${GCRYPT_INCLUDE_DIR}/gcrypt.h" GCRYPT_H REGEX "^#define GCRYPT_VERSION \"[^\"]*\"$")
string(REGEX REPLACE "^.*GCRYPT_VERSION \"([0-9]+).*$" "\\1" GCRYPT_VERSION_MAJOR "${GCRYPT_H}")
- string(REGEX REPLACE "^.*GCRYPT_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" GCRYPT_VERSION_MINOR "${GCRYPT_H}")
+ string(REGEX REPLACE "^.*GCRYPT_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" GCRYPT_VERSION_MINOR "${GCRYPT_H}")
string(REGEX REPLACE "^.*GCRYPT_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" GCRYPT_VERSION_PATCH "${GCRYPT_H}")
set(GCRYPT_VERSION_STRING "${GCRYPT_VERSION_MAJOR}.${GCRYPT_VERSION_MINOR}.${GCRYPT_VERSION_PATCH}")
endif()
diff --git a/cmake/FindQREncode.cmake b/cmake/FindQREncode.cmake
new file mode 100644
index 000000000..6328d9699
--- /dev/null
+++ b/cmake/FindQREncode.cmake
@@ -0,0 +1,22 @@
+# Copyright (C) 2017 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/>.
+
+find_path(QRENCODE_INCLUDE_DIR qrencode.h)
+find_library(QRENCODE_LIBRARY qrencode)
+
+mark_as_advanced(QRENCODE_LIBRARY QRENCODE_INCLUDE_DIR)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(QREncode DEFAULT_MSG QRENCODE_LIBRARY QRENCODE_INCLUDE_DIR)