Browse Source

Apply cmake-format 0.5.1

* Disable autosort as it messes with add_library and
  add_executable calls
sendfile
Martchus 3 years ago
parent
commit
bc0d7af67f
  1. 7
      CMakeLists.txt
  2. 22
      cmake/modules/3rdParty.cmake
  3. 20
      cmake/modules/AppTarget.cmake
  4. 30
      cmake/modules/BasicConfig.cmake
  5. 17
      cmake/modules/ConfigHeader.cmake
  6. 9
      cmake/modules/Doxygen.cmake
  7. 69
      cmake/modules/LibraryTarget.cmake
  8. 7
      cmake/modules/ListToString.cmake
  9. 3
      cmake/modules/ShellCompletion.cmake
  10. 5
      cmake/modules/TemplateFinder.cmake
  11. 99
      cmake/modules/TestTarget.cmake
  12. 7
      cmake/modules/WindowsResources.cmake

7
CMakeLists.txt

@ -140,7 +140,12 @@ if (USE_NATIVE_FILE_BUFFER)
endforeach ()
else ()
message(STATUS "Using boost::iostreams::stream_buffer<boost::iostreams::file_descriptor_sink> for NativeFileStream")
use_package(TARGET_NAME Boost::iostreams PACKAGE_NAME Boost PACKAGE_ARGS "REQUIRED;COMPONENTS;iostreams")
use_package(TARGET_NAME
Boost::iostreams
PACKAGE_NAME
Boost
PACKAGE_ARGS
"REQUIRED;COMPONENTS;iostreams")
foreach (NATIVE_FILE_STREAM_IMPL_FILE ${NATIVE_FILE_STREAM_IMPL_FILES})
set_property(SOURCE ${NATIVE_FILE_STREAM_IMPL_FILE}
APPEND

22
cmake/modules/3rdParty.cmake

@ -44,9 +44,19 @@ endfunction ()
function (parse_arguments_for_use_functions)
# parse arguments
set(OPTIONAL_ARGS OPTIONAL)
set(ONE_VALUE_ARGS VISIBILITY LIBRARIES_VARIABLE PACKAGES_VARIABLE PKG_CONFIG_MODULES_VARIABLE TARGET_NAME PACKAGE_NAME)
set(ONE_VALUE_ARGS
VISIBILITY
LIBRARIES_VARIABLE
PACKAGES_VARIABLE
PKG_CONFIG_MODULES_VARIABLE
TARGET_NAME
PACKAGE_NAME)
set(MULTI_VALUE_ARGS PKG_CONFIG_MODULES PACKAGE_ARGS)
cmake_parse_arguments(ARGS "${OPTIONAL_ARGS}" "${ONE_VALUE_ARGS}" "${MULTI_VALUE_ARGS}" ${ARGN})
cmake_parse_arguments(ARGS
"${OPTIONAL_ARGS}"
"${ONE_VALUE_ARGS}"
"${MULTI_VALUE_ARGS}"
${ARGN})
# validate values
if (ARGS_VISIBILITY)
@ -93,7 +103,8 @@ function (use_iconv)
parse_arguments_for_use_functions(${ARGN})
# check whether iconv from the standard library can be used
set(FORCE_EXTERNAL_ICONV OFF
set(FORCE_EXTERNAL_ICONV
OFF
CACHE PATH "whether to force usage of external iconv (rather than the using the one bundled with glibc)")
if (NOT FORCE_EXTERNAL_ICONV)
# check whether iconv exists in standard lib
@ -145,7 +156,8 @@ function (use_crypto)
set("${ARGS_LIBRARIES_VARIABLE}" "${${ARGS_LIBRARIES_VARIABLE}};OpenSSL::Crypto" PARENT_SCOPE)
set("${ARGS_PACKAGES_VARIABLE}" "${${ARGS_PACKAGES_VARIABLE}};OpenSSL" PARENT_SCOPE)
if (WIN32 AND OPENSSL_USE_STATIC_LIBS)
set("${ARGS_LIBRARIES_VARIABLE}" "${${ARGS_LIBRARIES_VARIABLE}};OpenSSL::Crypto;-lws2_32;-lgdi32;-lcrypt32"
set("${ARGS_LIBRARIES_VARIABLE}"
"${${ARGS_LIBRARIES_VARIABLE}};OpenSSL::Crypto;-lws2_32;-lgdi32;-lcrypt32"
PARENT_SCOPE)
endif ()
set("PKG_CONFIG_OpenSSL_Crypto" "libcrypto" PARENT_SCOPE)
@ -204,7 +216,7 @@ function (use_package)
set("${ARGS_LIBRARIES_VARIABLE}" "${${ARGS_LIBRARIES_VARIABLE}};${ARGS_TARGET_NAME}" PARENT_SCOPE)
set("${ARGS_PACKAGES_VARIABLE}" "${${ARGS_PACKAGES_VARIABLE}};${ARGS_PACKAGE_NAME}" PARENT_SCOPE)
set("PACKAGE_ARGS_${ARGS_PACKAGE_NAME}" "${ARGS_PACKAGE_ARGS}" PARENT_SCOPE)
endfunction()
endfunction ()
function (use_pkg_config_module)
# parse and validate arguments

20
cmake/modules/AppTarget.cmake

@ -34,7 +34,7 @@ endif ()
# add target for building the application
if (ANDROID)
# create a shared library which can be loaded from the Java-side
add_library(${META_TARGET_NAME} SHARED ${GUI_TYPE} ${ALL_FILES})
add_library(${META_TARGET_NAME} SHARED ${ALL_FILES})
else ()
add_executable(${META_TARGET_NAME} ${GUI_TYPE} ${ALL_FILES})
endif ()
@ -79,7 +79,8 @@ if (NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
if (NOT TARGET install-binary)
add_custom_target(install-binary
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=binary -P
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=binary -P
"${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif ()
add_dependencies(install-binary ${META_TARGET_NAME})
@ -101,13 +102,15 @@ if (NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
endforeach ()
if (NOT TARGET install-desktop)
add_custom_target(install-desktop
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=desktop -P
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=desktop -P
"${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif ()
add_dependencies(install-desktop ${META_TARGET_NAME})
if (NOT TARGET install-appimage)
add_custom_target(install-appimage
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=appimage -P
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=appimage -P
"${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif ()
add_dependencies(install-appimage ${META_TARGET_NAME})
@ -115,7 +118,8 @@ if (NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
# add install target for stripped binaries
if (NOT TARGET install-binary-strip)
add_custom_target(install-binary-strip
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_DO_STRIP=1 -DCMAKE_INSTALL_COMPONENT=binary -P
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_DO_STRIP=1 -DCMAKE_INSTALL_COMPONENT=binary -P
"${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif ()
add_dependencies(install-binary-strip ${META_TARGET_NAME})
@ -171,7 +175,11 @@ function (add_custom_desktop_file)
DESKTOP_FILE_ADDITIONAL_ENTRIES)
set(MULTI_VALUE_ARGS)
set(OPTIONAL_ARGS)
cmake_parse_arguments(ARGS "${OPTIONAL_ARGS}" "${ONE_VALUE_ARGS}" "${MULTI_VALUE_ARGS}" ${ARGN})
cmake_parse_arguments(ARGS
"${OPTIONAL_ARGS}"
"${ONE_VALUE_ARGS}"
"${MULTI_VALUE_ARGS}"
${ARGN})
if (NOT ARGS_FILE_NAME OR NOT ARGS_DESKTOP_FILE_APP_NAME OR NOT ARGS_DESKTOP_FILE_CMD)
message(FATAL_ERROR "Not all mandatory arguments specified.")
endif ()

30
cmake/modules/BasicConfig.cmake

@ -51,7 +51,8 @@ endif ()
# allow setting a library/application target suffix - A different configuration name might not require a different target
# name since it might differ anyways (e.g. library extensions for static and shared configuration). Hence there's not simply
# the configuration name used to distinguish targets as well.
set(${META_PROJECT_VARNAME_UPPER}_CONFIGURATION_TARGET_SUFFIX ""
set(${META_PROJECT_VARNAME_UPPER}_CONFIGURATION_TARGET_SUFFIX
""
CACHE STRING "sets a target suffix for ${META_PROJECT_NAME}")
set(CONFIGURATION_TARGET_SUFFIX "" CACHE STRING "sets the target suffix for all projects within the current build")
if (${META_PROJECT_VARNAME_UPPER}_CONFIGURATION_TARGET_SUFFIX STREQUAL "none")
@ -275,7 +276,11 @@ set(FORMATABLE_FILES
${QML_SRC_FILES})
# only format C/C++ files (and not eg. QML files)
if (FORMATABLE_FILES)
list(FILTER FORMATABLE_FILES INCLUDE REGEX ".*\\.(c|cpp|h|hpp)")
list(FILTER
FORMATABLE_FILES
INCLUDE
REGEX
".*\\.(c|cpp|h|hpp)")
endif ()
# determine source files which might be passed to cmake-format
@ -285,7 +290,7 @@ set(FORMATABLE_FILES_CMAKE ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${CMAKE_MO
if (EXISTS "${CLANG_FORMAT_RULES}")
add_custom_command(OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/.clang-format"
COMMAND "${CMAKE_COMMAND}" -E create_symlink "${CLANG_FORMAT_RULES}"
"${CMAKE_CURRENT_SOURCE_DIR}/.clang-format"
"${CMAKE_CURRENT_SOURCE_DIR}/.clang-format"
COMMENT "Linking coding style from ${CLANG_FORMAT_RULES}")
else ()
message(WARNING "Format rules for clang-format not found.")
@ -332,7 +337,7 @@ if (NOT META_NO_TIDY AND CMAKE_FORMAT_ENABLED AND FORMATABLE_FILES_CMAKE)
message(FATAL_ERROR "Unable to add tidy target; cmake-format not found")
endif ()
if (NOT META_CMAKE_FORMAT_OPTIONS)
set(META_CMAKE_FORMAT_OPTIONS --tab-size=4 --separate-ctrl-name-with-space=True --line-width=125)
set(META_CMAKE_FORMAT_OPTIONS --tab-size=4 --separate-ctrl-name-with-space=True --line-width=125 --autosort=False)
endif ()
add_custom_target("${META_TARGET_NAME}_cmake_tidy"
COMMAND "${CMAKE_FORMAT_BIN}" --in-place ${META_CMAKE_FORMAT_OPTIONS} ${FORMATABLE_FILES_CMAKE}
@ -348,7 +353,8 @@ endif ()
# add target for static code analysis using clang-tidy
if (NOT META_NO_STATIC_ANALYSIS AND FORMATABLE_FILES)
option(CLANG_TIDY_ENABLED "enables creation of static-check target using clang-tidy" OFF)
set(CLANG_TIDY_CHECKS ""
set(CLANG_TIDY_CHECKS
""
CACHE STRING
"-*,clang-analyzer-*,cppcoreguidelines-*,modernize-*,performance-*,portability-*,readability-*,android-*")
if (CLANG_TIDY_ENABLED)
@ -411,7 +417,10 @@ if (NOT META_NO_STATIC_ANALYSIS AND FORMATABLE_FILES)
endforeach ()
# mark all symbolic output files actually as symbolic
set_source_files_properties(${CLANG_TIDY_SYMBOLIC_OUTPUT_FILES} PROPERTIES SYMBOLIC YES)
set_source_files_properties(${CLANG_TIDY_SYMBOLIC_OUTPUT_FILES}
PROPERTIES
SYMBOLIC
YES)
# add targets
add_custom_target("${META_TARGET_NAME}_static_check"
@ -436,11 +445,7 @@ endif ()
# enable source code based coverage analysis using clang
option(CLANG_SOURCE_BASED_COVERAGE_ENABLED "enables creation of coverage targets for source-based coverage with clang" OFF)
if (CLANG_SOURCE_BASED_COVERAGE_ENABLED)
if (NOT CMAKE_HOST_UNIX
OR NOT
"${CMAKE_CXX_COMPILER_ID}"
STREQUAL
"Clang")
if (NOT CMAKE_HOST_UNIX OR NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
message(FATAL_ERROR "Source-based coverage only available under UNIX with Clang")
endif ()
if (NOT META_PROJECT_TYPE STREQUAL "application" AND DISABLE_SHARED_LIBS)
@ -467,7 +472,8 @@ if (NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
endforeach ()
if (NOT TARGET install-extra-files)
add_custom_target(install-extra-files
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=extra-files -P
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=extra-files -P
"${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif ()
endif ()

17
cmake/modules/ConfigHeader.cmake

@ -26,7 +26,11 @@ endif ()
get_target_property(INTERFACE_LINK_LIBRARIES_LIST "${META_TARGET_NAME}" INTERFACE_LINK_LIBRARIES)
# make list with link-time dependency versions and display names
foreach (DEPENDENCY IN LISTS LINK_LIBRARIES_LIST INTERFACE_LINK_LIBRARIES_LIST)
foreach (DEPENDENCY
IN
LISTS
LINK_LIBRARIES_LIST
INTERFACE_LINK_LIBRARIES_LIST)
# skip non-targets and already processed dependencies
if (NOT TARGET "${DEPENDENCY}" OR "${DEPENDENCY}" IN_LIST PROCESSED_DEPENDENCIES)
continue()
@ -69,7 +73,11 @@ endforeach ()
# format "DEPENCENCY_VERSIONS_ARRAY"
if (DEPENCENCY_VERSIONS)
include(ListToString)
list_to_string("," " \\\n \"" "\"" "${DEPENCENCY_VERSIONS}" DEPENCENCY_VERSIONS_ARRAY)
list_to_string(","
" \\\n \""
"\""
"${DEPENCENCY_VERSIONS}"
DEPENCENCY_VERSIONS_ARRAY)
endif ()
# add configuration header
@ -77,7 +85,10 @@ configure_file("${CONFIG_H_TEMPLATE_FILE}" "${CMAKE_CURRENT_BINARY_DIR}/resource
# ensure generated include files can be included via #include "resources/config.h"
if (NOT META_HEADER_ONLY_LIB)
foreach (TARGET_NAME ${META_TARGET_NAME} ${META_TARGET_NAME}_tests ${META_TARGET_NAME}_testlib)
foreach (TARGET_NAME
${META_TARGET_NAME}
${META_TARGET_NAME}_tests
${META_TARGET_NAME}_testlib)
if (TARGET ${TARGET_NAME})
target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
endif ()

9
cmake/modules/Doxygen.cmake

@ -52,7 +52,11 @@ set(DOXY_MAIN_PAGE_FILE "${DOXY_PATH_PREFIX}${DOXY_MAIN_PAGE_FILE}")
# convert DOXY_INPUT_FILES to whitespace-separated list
include(ListToString)
list_to_string(" " "\"${DOXY_PATH_PREFIX}" "\"" "${DOXY_INPUT_FILES}" DOXY_INPUT_FILES_WHITESPACE_SEPARATED)
list_to_string(" "
"\"${DOXY_PATH_PREFIX}"
"\""
"${DOXY_INPUT_FILES}"
DOXY_INPUT_FILES_WHITESPACE_SEPARATED)
# generate Doxygen configuration
configure_file("${DOXYGEN_TEMPLATE_FILE}" "${CMAKE_CURRENT_BINARY_DIR}/doxygen.config")
@ -69,7 +73,8 @@ if (NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/api-doc" DESTINATION "${META_DATA_DIR}" COMPONENT api-doc OPTIONAL)
if (NOT TARGET install-api-doc)
add_custom_target(install-api-doc
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=api-doc -P
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=api-doc -P
"${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif ()
endif ()

69
cmake/modules/LibraryTarget.cmake

@ -160,14 +160,7 @@ endforeach ()
# populate META_PRIVATE_LIB_DEPENDS (only required when building static libraries)
if (NOT BUILD_SHARED_LIBS)
foreach (DEPENDENCY ${PRIVATE_LIBRARIES})
if (NOT
"${DEPENDENCY}"
IN_LIST
META_PUBLIC_LIB_DEPENDS
AND NOT
"${DEPENDENCY}"
IN_LIST
META_PRIVATE_LIB_DEPENDS)
if (NOT "${DEPENDENCY}" IN_LIST META_PUBLIC_LIB_DEPENDS AND NOT "${DEPENDENCY}" IN_LIST META_PRIVATE_LIB_DEPENDS)
list(APPEND META_PRIVATE_LIB_DEPENDS ${DEPENDENCY})
endif ()
endforeach ()
@ -176,11 +169,9 @@ endif ()
# Qt Creator does not show INTERFACE_SOURCES in project tree, so create a custom target as workaround
if (META_HEADER_ONLY_LIB)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/headeronly.cpp"
"// not belonging to a real target, only for header-only lib files showing up in Qt Creator")
add_library(${META_TARGET_NAME}_interface_sources_for_qtcreator
EXCLUDE_FROM_ALL
"${CMAKE_CURRENT_BINARY_DIR}/headeronly.cpp"
${HEADER_FILES})
"// not belonging to a real target, only for header-only lib files showing up in Qt Creator")
add_library(${META_TARGET_NAME}_interface_sources_for_qtcreator EXCLUDE_FROM_ALL
"${CMAKE_CURRENT_BINARY_DIR}/headeronly.cpp" ${HEADER_FILES})
target_include_directories(${META_TARGET_NAME}_interface_sources_for_qtcreator
INTERFACE $<BUILD_INTERFACE:${TARGET_INCLUDE_DIRECTORY_BUILD_INTERFACE}>
$<INSTALL_INTERFACE:${HEADER_INSTALL_DESTINATION}> ${PUBLIC_INCLUDE_DIRS})
@ -205,7 +196,8 @@ endif ()
set(ADDITIONAL_ARGUMENTS_FOR_REQUIRED_CMAKE_PACKAGES)
foreach (INTERFACE_REQUIRED_PACKAGE ${INTERFACE_REQUIRED_PACKAGES})
if (PACKAGE_ARGS_${INTERFACE_REQUIRED_PACKAGE})
set(ADDITIONAL_ARGUMENTS_FOR_REQUIRED_CMAKE_PACKAGES
set(
ADDITIONAL_ARGUMENTS_FOR_REQUIRED_CMAKE_PACKAGES
"${ADDITIONAL_ARGUMENTS_FOR_REQUIRED_CMAKE_PACKAGES}set(${META_PROJECT_VARNAME_UPPER}_FIND_PACKAGE_ARGS_${INTERFACE_REQUIRED_PACKAGE} \"${PACKAGE_ARGS_${INTERFACE_REQUIRED_PACKAGE}}\")\n"
)
endif ()
@ -260,7 +252,10 @@ write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${META_PROJECT_NAME
COMPATIBILITY SameMajorVersion)
# compute dependencies for pkg-config file
macro (compute_dependencies_for_package_config DEPENDS OUTPUT_VAR_PKGS OUTPUT_VAR_LIBS)
macro (compute_dependencies_for_package_config
DEPENDS
OUTPUT_VAR_PKGS
OUTPUT_VAR_LIBS)
unset(${OUTPUT_VAR_PKGS})
unset(${OUTPUT_VAR_LIBS})
foreach (DEPENDENCY ${${DEPENDS}})
@ -336,7 +331,8 @@ if (NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
install(FILES ${CMAKE_CONFIG_FILES} DESTINATION "${META_DATA_DIR}/cmake" COMPONENT cmake-config)
if (NOT TARGET install-cmake-config)
add_custom_target(install-cmake-config
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=cmake-config -P
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=cmake-config -P
"${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif ()
@ -346,21 +342,24 @@ if (NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
endif ()
if (NOT TARGET install-pkg-config)
add_custom_target(install-pkg-config
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=pkg-config -P
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=pkg-config -P
"${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif ()
# add install target for libs
if (NOT TARGET install-binary)
add_custom_target(install-binary
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=binary -P
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=binary -P
"${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif ()
# add install target for stripped libs
if (NOT TARGET install-binary-strip)
add_custom_target(install-binary-strip
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_DO_STRIP=1 -DCMAKE_INSTALL_COMPONENT=binary -P
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_DO_STRIP=1 -DCMAKE_INSTALL_COMPONENT=binary -P
"${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif ()
@ -412,7 +411,8 @@ if (NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
endforeach ()
if (NOT TARGET install-header)
add_custom_target(install-header
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=header -P
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=header -P
"${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif ()
endif ()
@ -424,7 +424,8 @@ if (NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
endforeach ()
if (NOT TARGET install-cmake-modules)
add_custom_target(install-cmake-modules
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=cmake-modules -P
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=cmake-modules -P
"${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif ()
@ -435,14 +436,18 @@ if (NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
endforeach ()
if (NOT TARGET install-cmake-templates)
add_custom_target(install-cmake-templates
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=cmake-templates -P
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=cmake-templates -P
"${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif ()
# add install target for all the cmake stuff
if (NOT TARGET install-cmake-stuff)
add_custom_target(install-cmake-stuff)
add_dependencies(install-cmake-stuff install-cmake-config install-cmake-modules install-cmake-templates)
add_dependencies(install-cmake-stuff
install-cmake-config
install-cmake-modules
install-cmake-templates)
endif ()
# add mingw-w64 specific install targets
@ -450,11 +455,19 @@ if (NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
if (NOT TARGET install-mingw-w64)
add_custom_target(install-mingw-w64)
endif ()
add_dependencies(install-mingw-w64 install-binary install-header install-cmake-stuff install-pkg-config)
add_dependencies(install-mingw-w64
install-binary
install-header
install-cmake-stuff
install-pkg-config)
if (NOT TARGET install-mingw-w64-strip)
add_custom_target(install-mingw-w64-strip)
endif ()
add_dependencies(install-mingw-w64-strip install-binary-strip install-header install-cmake-stuff install-pkg-config)
add_dependencies(install-mingw-w64-strip
install-binary-strip
install-header
install-cmake-stuff
install-pkg-config)
if (LOCALIZATION_TARGET)
add_dependencies(install-mingw-w64 ${LOCALIZATION_TARGET})
add_dependencies(install-mingw-w64-strip ${LOCALIZATION_TARGET})
@ -468,14 +481,16 @@ if (NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
if (BUILD_SHARED_LIBS AND NOT META_HEADER_ONLY_LIB)
add_custom_target(
install-${META_TARGET_NAME}-mingw-w64-importlib-strip
COMMAND "${STRIP_BINARY_PATH}" -g
COMMAND "${STRIP_BINARY_PATH}"
-g
"\$\{DESTDIR\}\$\{DESTDIR:+/\}${CMAKE_INSTALL_PREFIX}/lib/lib${META_TARGET_NAME}.dll.a")
add_dependencies(install-${META_TARGET_NAME}-mingw-w64-importlib-strip install-binary-strip)
add_dependencies(install-mingw-w64-strip install-${META_TARGET_NAME}-mingw-w64-importlib-strip)
endif ()
if (BUILD_STATIC_LIBS AND NOT META_HEADER_ONLY_LIB)
add_custom_target(install-${META_TARGET_NAME}-mingw-w64-staticlib-strip
COMMAND "${STRIP_BINARY_PATH}" -g
COMMAND "${STRIP_BINARY_PATH}"
-g
"\$\{DESTDIR\}\$\{DESTDIR:+/\}${CMAKE_INSTALL_PREFIX}/lib/lib${META_TARGET_NAME}.a")
add_dependencies(install-${META_TARGET_NAME}-mingw-w64-staticlib-strip install-binary-strip)
add_dependencies(install-mingw-w64-strip install-${META_TARGET_NAME}-mingw-w64-staticlib-strip)

7
cmake/modules/ListToString.cmake

@ -4,7 +4,12 @@ if (DEFINED LIST_TO_STRING_LOADED)
endif ()
set(LIST_TO_STRING_LOADED ON)
function (list_to_string separator prefix suffix input_list output_string_var)
function (list_to_string
separator
prefix
suffix
input_list
output_string_var)
set(res "")
# get list length
list(LENGTH input_list list_length)

3
cmake/modules/ShellCompletion.cmake

@ -25,7 +25,8 @@ if (BASH_COMPLETION_ENABLED)
COMPONENT bash-completion)
if (NOT TARGET install-bash-completion)
add_custom_target(install-bash-completion
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=bash-completion -P
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=bash-completion -P
"${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif ()
endif ()

5
cmake/modules/TemplateFinder.cmake

@ -4,7 +4,10 @@ if (DEFINED TEMPLATE_FINDER_LOADED)
endif ()
set(TEMPLATE_FINDER_LOADED YES)
function (find_template_file FILE_NAME PROJECT_VAR_NAME OUTPUT_VAR)
function (find_template_file
FILE_NAME
PROJECT_VAR_NAME
OUTPUT_VAR)
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/${FILE_NAME}.in")
# check own source directory
set(${OUTPUT_VAR} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/${FILE_NAME}.in" PARENT_SCOPE)

99
cmake/modules/TestTarget.cmake

@ -24,12 +24,10 @@ if (NOT META_NO_CPP_UNIT)
pkg_search_module(CPP_UNIT_CONFIG_${META_PROJECT_NAME} cppunit>=${META_REQUIRED_CPP_UNIT_VERSION})
if (CPP_UNIT_CONFIG_${META_PROJECT_NAME}_FOUND)
set(CPP_UNIT_LIB "${CPP_UNIT_CONFIG_${META_PROJECT_NAME}_LDFLAGS_OTHER}"
"${CPP_UNIT_CONFIG_${META_PROJECT_NAME}_LIBRARIES}"
CACHE FILEPATH "cppunit lib"
FORCE)
set(CPP_UNIT_INCLUDE_DIR ${CPP_UNIT_CONFIG_${META_PROJECT_NAME}_INCLUDE_DIRS}
CACHE FILEPATH "cppunit include dir"
FORCE)
"${CPP_UNIT_CONFIG_${META_PROJECT_NAME}_LIBRARIES}" CACHE FILEPATH "cppunit lib" FORCE)
set(CPP_UNIT_INCLUDE_DIR
${CPP_UNIT_CONFIG_${META_PROJECT_NAME}_INCLUDE_DIRS}
CACHE FILEPATH "cppunit include dir" FORCE)
link_directories(${CPP_UNIT_CONFIG_${META_PROJECT_NAME}_LIBRARY_DIRS})
else ()
# fall back to find_library
@ -102,7 +100,13 @@ if (META_PROJECT_IS_APPLICATION)
# using functions directly from the tests might be required -> also create a 'testlib' and link tests against it
if (LINK_TESTS_AGAINST_APP_TARGET)
# create target for the 'testlib'
set(TESTLIB_FILES ${HEADER_FILES} ${SRC_FILES} ${WIDGETS_FILES} ${QML_FILES} ${RES_FILES} ${QM_FILES})
set(TESTLIB_FILES
${HEADER_FILES}
${SRC_FILES}
${WIDGETS_FILES}
${QML_FILES}
${RES_FILES}
${QM_FILES})
list(REMOVE_ITEM TESTLIB_FILES main.h main.cpp)
add_library(${META_TARGET_NAME}_testlib SHARED ${TESTLIB_FILES})
target_link_libraries(${META_TARGET_NAME}_testlib
@ -173,7 +177,10 @@ if (META_PROJECT_TYPE STREQUAL "application")
endif ()
if (NOT META_TEST_TARGET_IS_MANUAL)
add_test(NAME ${META_PROJECT_NAME}_run_tests
COMMAND ${META_TARGET_NAME}_tests -p "${CMAKE_CURRENT_SOURCE_DIR}/testfiles" -w
COMMAND ${META_TARGET_NAME}_tests
-p
"${CMAKE_CURRENT_SOURCE_DIR}/testfiles"
-w
"${CMAKE_CURRENT_BINARY_DIR}/testworkingdir" ${RUN_TESTS_APPLICATION_ARGS})
endif ()
@ -203,10 +210,16 @@ if (CLANG_SOURCE_BASED_COVERAGE_AVAILABLE)
# add command to execute tests generating raw profiling data
add_custom_command(
OUTPUT "${LLVM_PROFILE_RAW_FILE}" "${LLVM_PROFILE_RAW_LIST_FILE}"
COMMAND "${CMAKE_COMMAND}" -E env "LLVM_PROFILE_FILE=${LLVM_PROFILE_RAW_FILE}"
"LLVM_PROFILE_LIST_FILE=${LLVM_PROFILE_RAW_LIST_FILE}" $<TARGET_FILE:${META_TARGET_NAME}_tests> -p
"${CMAKE_CURRENT_SOURCE_DIR}/testfiles" -w "${CMAKE_CURRENT_BINARY_DIR}/testworkingdir"
${RUN_TESTS_APPLICATION_ARGS}
COMMAND "${CMAKE_COMMAND}"
-E
env
"LLVM_PROFILE_FILE=${LLVM_PROFILE_RAW_FILE}"
"LLVM_PROFILE_LIST_FILE=${LLVM_PROFILE_RAW_LIST_FILE}"
$<TARGET_FILE:${META_TARGET_NAME}_tests>
-p
"${CMAKE_CURRENT_SOURCE_DIR}/testfiles"
-w
"${CMAKE_CURRENT_BINARY_DIR}/testworkingdir" ${RUN_TESTS_APPLICATION_ARGS}
COMMENT "Executing ${META_TARGET_NAME}_tests to generate raw profiling data for source-based coverage report"
DEPENDS "${META_TARGET_NAME}_tests")
@ -216,8 +229,16 @@ if (CLANG_SOURCE_BASED_COVERAGE_AVAILABLE)
if (LLVM_PROFDATA_BIN AND LLVM_COV_BIN)
# merge profiling data
add_custom_command(OUTPUT "${LLVM_PROFILE_DATA_FILE}"
COMMAND cat "${LLVM_PROFILE_RAW_LIST_FILE}" | xargs "${LLVM_PROFDATA_BIN}" merge -o
"${LLVM_PROFILE_DATA_FILE}" -sparse "${LLVM_PROFILE_RAW_FILE}"
COMMAND cat
"${LLVM_PROFILE_RAW_LIST_FILE}"
|
xargs
"${LLVM_PROFDATA_BIN}"
merge
-o
"${LLVM_PROFILE_DATA_FILE}"
-sparse
"${LLVM_PROFILE_RAW_FILE}"
COMMENT "Generating profiling data for source-based coverage report"
DEPENDS "${LLVM_PROFILE_RAW_FILE}" "${LLVM_PROFILE_RAW_LIST_FILE}")
@ -250,9 +271,18 @@ if (CLANG_SOURCE_BASED_COVERAGE_AVAILABLE)
list(APPEND LLVM_COV_ADDITIONAL_OPTIONS -show-functions)
endif ()
add_custom_command(OUTPUT "${COVERAGE_REPORT_FILE}"
COMMAND "${LLVM_COV_BIN}" report -format=text -stats -instr-profile "${LLVM_PROFILE_DATA_FILE}"
${LLVM_COV_ADDITIONAL_OPTIONS} ${LLVM_COV_TARGET_FILE} ${HEADER_FILES} ${SRC_FILES}
${WIDGETS_HEADER_FILES} ${WIDGETS_SOURCE_FILES} ${QML_HEADER_FILES} ${QML_SOURCE_FILES} >
COMMAND "${LLVM_COV_BIN}" report
-format=text -stats -instr-profile
"${LLVM_PROFILE_DATA_FILE}"
${LLVM_COV_ADDITIONAL_OPTIONS}
${LLVM_COV_TARGET_FILE}
${HEADER_FILES}
${SRC_FILES}
${WIDGETS_HEADER_FILES}
${WIDGETS_SOURCE_FILES}
${QML_HEADER_FILES}
${QML_SOURCE_FILES}
>
"${COVERAGE_REPORT_FILE}"
COMMENT "Generating coverage report (statistics per function)"
DEPENDS "${LLVM_PROFILE_DATA_FILE}"
@ -261,10 +291,18 @@ if (CLANG_SOURCE_BASED_COVERAGE_AVAILABLE)
# generate coverage report with statistics per file (only possible with LLVM 5 if source files are specified)
if (LLVM_COV_VERSION GREATER_EQUAL 5.0.0)
add_custom_command(OUTPUT "${COVERAGE_PER_FILE_REPORT_FILE}"
COMMAND "${LLVM_COV_BIN}" report -format=text -stats -instr-profile
"${LLVM_PROFILE_DATA_FILE}" ${LLVM_COV_TARGET_FILE} ${HEADER_FILES} ${SRC_FILES}
${WIDGETS_HEADER_FILES} ${WIDGETS_SOURCE_FILES} ${QML_HEADER_FILES}
${QML_SOURCE_FILES} > "${COVERAGE_PER_FILE_REPORT_FILE}"
COMMAND "${LLVM_COV_BIN}" report
-format=text -stats -instr-profile
"${LLVM_PROFILE_DATA_FILE}"
${LLVM_COV_TARGET_FILE}
${HEADER_FILES}
${SRC_FILES}
${WIDGETS_HEADER_FILES}
${WIDGETS_SOURCE_FILES}
${QML_HEADER_FILES}
${QML_SOURCE_FILES}
>
"${COVERAGE_PER_FILE_REPORT_FILE}"
COMMENT "Generating coverage report (statistics per file)"
DEPENDS "${LLVM_PROFILE_DATA_FILE}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
@ -286,7 +324,11 @@ if (CLANG_SOURCE_BASED_COVERAGE_AVAILABLE)
set(OVERALL_COVERAGE_AKW_SCRIPT "${CPP_UTILITIES_CONFIG_DIRS}/tests/calculateoverallcoverage.awk")
endif ()
add_custom_command(OUTPUT "${COVERAGE_OVERALL_REPORT_FILE}"
COMMAND awk -f "${OVERALL_COVERAGE_AKW_SCRIPT}" "${COVERAGE_REPORT_FILE}" >
COMMAND awk
-f
"${OVERALL_COVERAGE_AKW_SCRIPT}"
"${COVERAGE_REPORT_FILE}"
>
"${COVERAGE_OVERALL_REPORT_FILE}"
COMMENT "Generating coverage report (overall figures)"
DEPENDS "${OVERALL_COVERAGE_AKW_SCRIPT}" "${COVERAGE_REPORT_FILE}")
@ -294,9 +336,16 @@ if (CLANG_SOURCE_BASED_COVERAGE_AVAILABLE)
# generate HTML document showing covered/uncovered code
add_custom_command(OUTPUT "${COVERAGE_HTML_REPORT_FILE}"
COMMAND "${LLVM_COV_BIN}" show -project-title="${META_APP_NAME}" -format=html -instr-profile
"${LLVM_PROFILE_DATA_FILE}" ${LLVM_COV_TARGET_FILE} ${HEADER_FILES} ${SRC_FILES}
${WIDGETS_FILES} ${QML_FILES} > "${COVERAGE_HTML_REPORT_FILE}"
COMMAND "${LLVM_COV_BIN}" show
-project-title="${META_APP_NAME}" -format=html -instr-profile
"${LLVM_PROFILE_DATA_FILE}"
${LLVM_COV_TARGET_FILE}
${HEADER_FILES}
${SRC_FILES}
${WIDGETS_FILES}
${QML_FILES}
>
"${COVERAGE_HTML_REPORT_FILE}"
COMMENT "Generating HTML document showing covered/uncovered code"
DEPENDS "${LLVM_PROFILE_DATA_FILE}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")

7
cmake/modules/WindowsResources.cmake

@ -40,9 +40,12 @@ if (WINDOWS_ICON_ENABLED)
set(WINDOWS_ICON_RC_ENTRY "IDI_ICON1 ICON DISCARDABLE \"${WINDOWS_ICON_PATH}\"")
add_custom_command(OUTPUT "${WINDOWS_ICON_PATH}"
COMMAND ${FFMPEG_BIN} -y -i "${PNG_ICON_PATH}" -vf crop=${PNG_ICON_CROP},scale=64:64
"${WINDOWS_ICON_PATH}"
"${WINDOWS_ICON_PATH}"
DEPENDS "${PNG_ICON_PATH}")
set_source_files_properties("${WINDOWS_RC_FILE}" PROPERTIES OBJECT_DEPENDS "${WINDOWS_ICON_PATH}")
set_source_files_properties("${WINDOWS_RC_FILE}"
PROPERTIES
OBJECT_DEPENDS
"${WINDOWS_ICON_PATH}")
message(STATUS "Generating Windows icon from \"${PNG_ICON_PATH}\" via ${FFMPEG_BIN}.")
elseif (NOT USING_DEFAULT_PNG_ICON_PATH)
message(FATAL_ERROR "The specified PNG_ICON_PATH \"${PNG_ICON_PATH}\" is invalid.")

Loading…
Cancel
Save