Browse Source

Polish CMake code

sendfile
Martchus 3 years ago
parent
commit
8ffe0e6a51
  1. 3
      cmake/modules/3rdParty.cmake
  2. 36
      cmake/modules/AppTarget.cmake
  3. 30
      cmake/modules/BasicConfig.cmake
  4. 10
      cmake/modules/ConfigHeader.cmake
  5. 8
      cmake/modules/Doxygen.cmake
  6. 58
      cmake/modules/LibraryTarget.cmake
  7. 82
      cmake/modules/TestTarget.cmake
  8. 2
      cmake/templates/Config.cmake.in
  9. 2
      cmake/templates/appdata.xml.in
  10. 4
      cmake/templates/bash-completion.sh.in

3
cmake/modules/3rdParty.cmake

@ -138,11 +138,12 @@ function (use_target)
set("${ARGS_LIBRARIES_VARIABLE}" "${${ARGS_LIBRARIES_VARIABLE}};${ARGS_TARGET_NAME}" PARENT_SCOPE)
endfunction()
# skip subsequent configuration if only the function includes are wanted
if (META_NO_3RDPARTY_CONFIG)
return()
endif()
# option for deciding whether to build/use static or shared libraries
# add options for deciding whether to build/use static or shared libraries
if (("${META_PROJECT_TYPE}" STREQUAL "library")
OR ("${META_PROJECT_TYPE}" STREQUAL "plugin")
OR ("${META_PROJECT_TYPE}" STREQUAL "qtplugin")

36
cmake/modules/AppTarget.cmake

@ -34,29 +34,29 @@ endif ()
# add target for building the application
if (ANDROID)
# create a shared library which can be loaded from the Java-side
add_library(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} SHARED ${GUI_TYPE} ${ALL_FILES})
add_library(${META_TARGET_NAME} SHARED ${GUI_TYPE} ${ALL_FILES})
else ()
add_executable(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} ${GUI_TYPE} ${ALL_FILES})
add_executable(${META_TARGET_NAME} ${GUI_TYPE} ${ALL_FILES})
endif ()
message(STATUS LINKING ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
message(STATUS LINKING ${META_TARGET_NAME}
PUBLIC ${META_ADDITIONAL_LINK_FLAGS} "${PUBLIC_LIBRARIES}"
PRIVATE "${PRIVATE_LIBRARIES}")
target_link_libraries(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
target_link_libraries(${META_TARGET_NAME}
PUBLIC ${META_ADDITIONAL_LINK_FLAGS} "${PUBLIC_LIBRARIES}"
PRIVATE "${PRIVATE_LIBRARIES}")
target_include_directories(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
target_include_directories(${META_TARGET_NAME}
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${HEADER_INSTALL_DESTINATION}> ${PUBLIC_SHARED_INCLUDE_DIRS}
PRIVATE "${PRIVATE_INCLUDE_DIRS}")
target_compile_definitions(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
target_compile_definitions(${META_TARGET_NAME}
PUBLIC
"${META_PUBLIC_COMPILE_DEFINITIONS}"
PRIVATE
"${META_PRIVATE_COMPILE_DEFINITIONS}")
target_compile_options(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
target_compile_options(${META_TARGET_NAME}
PUBLIC "${META_PUBLIC_COMPILE_OPTIONS}"
PRIVATE "${META_PRIVATE_COMPILE_OPTIONS}")
set_target_properties(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
set_target_properties(${META_TARGET_NAME}
PROPERTIES CXX_STANDARD
"${META_CXX_STANDARD}"
LINK_SEARCH_START_STATIC
@ -70,16 +70,16 @@ if (NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
# add install target for binary
if (APPLE)
set(BUNDLE_INSTALL_DESTINATION bin CACHE STRING "specifies the install destination for bundles")
install(TARGETS ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
install(TARGETS ${META_TARGET_NAME}
RUNTIME DESTINATION bin
BUNDLE DESTINATION "${BUNDLE_INSTALL_DESTINATION}" COMPONENT binary)
elseif (ANDROID)
install(TARGETS ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
install(TARGETS ${META_TARGET_NAME}
RUNTIME DESTINATION bin COMPONENT binary
LIBRARY DESTINATION lib${SELECTED_LIB_SUFFIX} COMPONENT binary
ARCHIVE DESTINATION lib${SELECTED_LIB_SUFFIX} COMPONENT binary)
else ()
install(TARGETS ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} RUNTIME DESTINATION bin COMPONENT binary)
install(TARGETS ${META_TARGET_NAME} RUNTIME DESTINATION bin COMPONENT binary)
endif ()
if (NOT TARGET install-binary)
@ -87,14 +87,14 @@ if (NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=binary -P
"${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif ()
add_dependencies(install-binary ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX})
add_dependencies(install-binary ${META_TARGET_NAME})
# add mingw-w64 specific install target
if (NOT TARGET install-mingw-w64)
add_custom_target(install-mingw-w64)
add_dependencies(install-mingw-w64 install-binary)
endif ()
add_dependencies(install-mingw-w64 ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX})
add_dependencies(install-mingw-w64 ${META_TARGET_NAME})
# add install target for desktop entries and icons
foreach (DESKTOP_FILE ${DESKTOP_FILES})
@ -109,13 +109,13 @@ if (NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=desktop -P
"${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif ()
add_dependencies(install-desktop ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX})
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
"${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif ()
add_dependencies(install-appimage ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX})
add_dependencies(install-appimage ${META_TARGET_NAME})
# add install target for stripped binaries
if (NOT TARGET install-binary-strip)
@ -123,7 +123,7 @@ if (NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
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 ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX})
add_dependencies(install-binary-strip ${META_TARGET_NAME})
# add mingw-w64 specific install targets
if (MINGW)
@ -199,7 +199,7 @@ function(add_desktop_file)
list(GET META_APP_ACTION_${ACTION_VAR} 2 ACTION_ARGS)
set(
DESKTOP_FILE_ADDITIONAL_ENTRIES
"${DESKTOP_FILE_ADDITIONAL_ENTRIES}\n[Desktop Action ${ACTION_ID}]\nName=${ACTION_NAME}\nExec=${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} ${ACTION_ARGS}"
"${DESKTOP_FILE_ADDITIONAL_ENTRIES}\n[Desktop Action ${ACTION_ID}]\nName=${ACTION_NAME}\nExec=${META_TARGET_NAME} ${ACTION_ARGS}"
)
endforeach ()
@ -210,7 +210,7 @@ function(add_desktop_file)
DESKTOP_FILE_GENERIC_NAME "${META_GENERIC_NAME}"
DESKTOP_FILE_DESCRIPTION "${META_APP_DESCRIPTION}"
DESKTOP_FILE_CATEGORIES "${META_APP_CATEGORIES}"
DESKTOP_FILE_CMD "${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}"
DESKTOP_FILE_CMD "${META_TARGET_NAME}"
DESKTOP_FILE_ICON "${META_PROJECT_NAME}"
DESKTOP_FILE_ADDITIONAL_ENTRIES "${DESKTOP_FILE_ADDITIONAL_ENTRIES}"
)

30
cmake/modules/BasicConfig.cmake

@ -12,10 +12,12 @@ if (NOT META_APP_DESCRIPTION)
message(FATAL_ERROR "No project name (META_APP_DESCRIPTION) specified.")
endif ()
# define a few variables
set(META_TARGET_NAME "${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}")
string(TOUPPER "${CMAKE_BUILD_TYPE}" META_CURRENT_CONFIGURATION)
# set project name (displayed in Qt Creator)
message(STATUS "Configuring project ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}")
message(STATUS "Configuring project ${META_TARGET_NAME}")
project(${META_PROJECT_NAME})
# set META_PROJECT_VARNAME and META_PROJECT_VARNAME_UPPER if not specified explicitely
@ -55,9 +57,9 @@ if (NOT META_VERSION_PATCH)
set(META_VERSION_PATCH 0)
endif ()
# set META_ID to META_PROJECT_NAME if not specified
# set META_ID to target name if not specified
if (NOT META_ID)
set(META_ID "${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}")
set(META_ID "${META_TARGET_NAME}")
endif ()
# set bugtracker URL
@ -129,7 +131,7 @@ if (APPEND_GIT_REVISION)
endif ()
# set TARGET_EXECUTABLE which is used to refer to the target executable at its installation location
set(TARGET_EXECUTABLE "${CMAKE_INSTALL_PREFIX}/bin/${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}")
set(TARGET_EXECUTABLE "${CMAKE_INSTALL_PREFIX}/bin/${META_TARGET_NAME}")
# create header for feature detection
if (META_FEATURES_FOR_COMPILER_DETECTION_HEADER)
@ -270,7 +272,7 @@ if (NOT META_NO_TIDY AND CLANG_FORMAT_ENABLED AND FORMATABLE_FILES AND EXISTS "$
if (NOT CLANG_FORMAT_BIN)
message(FATAL_ERROR "Unable to add tidy target; clang-format not found")
endif ()
add_custom_target("${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tidy"
add_custom_target("${META_TARGET_NAME}_tidy"
COMMAND "${CLANG_FORMAT_BIN}" -style=file -i ${FORMATABLE_FILES}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Tidying ${META_PROJECT_NAME} sources using clang-format"
@ -278,14 +280,14 @@ if (NOT META_NO_TIDY AND CLANG_FORMAT_ENABLED AND FORMATABLE_FILES AND EXISTS "$
if (NOT TARGET tidy)
add_custom_target(tidy)
endif ()
add_dependencies(tidy "${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tidy")
add_dependencies(tidy "${META_TARGET_NAME}_tidy")
# also add a test to verify whether sources are tidy
add_test(NAME "${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tidy_test"
add_test(NAME "${META_TARGET_NAME}_tidy_test"
COMMAND "${CLANG_FORMAT_BIN}" -output-replacements-xml -style=file ${FORMATABLE_FILES}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
list(APPEND CHECK_TARGET_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/.clang-format")
set_tests_properties("${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tidy_test"
set_tests_properties("${META_TARGET_NAME}_tidy_test"
PROPERTIES FAIL_REGULAR_EXPRESSION
"<replacement.*>.*</replacement>"
REQUIRED_FILES
@ -301,7 +303,7 @@ if (NOT META_NO_TIDY AND CMAKE_FORMAT_ENABLED AND FORMATABLE_FILES_CMAKE)
if (NOT META_CMAKE_FORMAT_OPTIONS)
set(META_CMAKE_FORMAT_OPTIONS --tab-size=4 --separate-ctrl-name-with-space=True --line-width=125)
endif ()
add_custom_target("${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_cmake_tidy"
add_custom_target("${META_TARGET_NAME}_cmake_tidy"
COMMAND "${CMAKE_FORMAT_BIN}" --in-place ${META_CMAKE_FORMAT_OPTIONS} ${FORMATABLE_FILES_CMAKE}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Tidying ${META_PROJECT_NAME} sources using cmake-format"
@ -309,7 +311,7 @@ if (NOT META_NO_TIDY AND CMAKE_FORMAT_ENABLED AND FORMATABLE_FILES_CMAKE)
if (NOT TARGET tidy)
add_custom_target(tidy)
endif ()
add_dependencies(tidy "${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_cmake_tidy")
add_dependencies(tidy "${META_TARGET_NAME}_cmake_tidy")
endif ()
# add target for static code analysis using clang-tidy
@ -337,7 +339,7 @@ if (NOT META_NO_STATIC_ANALYSIS AND FORMATABLE_FILES)
set(CLANG_TIDY_CXX_FLAGS "")
if (NOT META_HEADER_ONLY_LIB)
# deduce flags from target
set(TARGET_NAME ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX})
set(TARGET_NAME ${META_TARGET_NAME})
if (NOT BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS)
set(TARGET_NAME "${TARGET_NAME}_static")
endif ()
@ -381,13 +383,13 @@ if (NOT META_NO_STATIC_ANALYSIS AND FORMATABLE_FILES)
set_source_files_properties(${CLANG_TIDY_SYMBOLIC_OUTPUT_FILES} PROPERTIES SYMBOLIC YES)
# add targets
add_custom_target("${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_static_check"
add_custom_target("${META_TARGET_NAME}_static_check"
DEPENDS ${CLANG_TIDY_SYMBOLIC_OUTPUT_FILES}
COMMENT "Linting ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} sources using clang-tidy")
COMMENT "Linting ${META_TARGET_NAME} sources using clang-tidy")
if (NOT TARGET static-check)
add_custom_target(static-check)
endif ()
add_dependencies(static-check "${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_static_check")
add_dependencies(static-check "${META_TARGET_NAME}_static_check")
endif ()
endif ()

10
cmake/modules/ConfigHeader.cmake

@ -20,9 +20,9 @@ unset(INTERFACE_LINK_LIBRARIES_LIST)
unset(PROCESSED_DEPENDENCIES)
unset(HAVE_OPENSSL)
if (NOT META_HEADER_ONLY_LIB)
get_target_property(LINK_LIBRARIES_LIST "${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}" LINK_LIBRARIES)
get_target_property(LINK_LIBRARIES_LIST "${META_TARGET_NAME}" LINK_LIBRARIES)
endif()
get_target_property(INTERFACE_LINK_LIBRARIES_LIST "${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}" INTERFACE_LINK_LIBRARIES)
get_target_property(INTERFACE_LINK_LIBRARIES_LIST "${META_TARGET_NAME}" INTERFACE_LINK_LIBRARIES)
foreach (DEPENDENCY IN LISTS LINK_LIBRARIES_LIST INTERFACE_LINK_LIBRARIES_LIST)
if (NOT TARGET "${DEPENDENCY}" OR "${DEPENDENCY}" IN_LIST PROCESSED_DEPENDENCIES)
continue()
@ -73,9 +73,9 @@ 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
${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests
${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_testlib)
${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 ()

8
cmake/modules/Doxygen.cmake

@ -30,7 +30,7 @@ endif ()
if (NOT DOXYGEN_BIN)
message(
WARNING
"Doxygen not found, unable to add target for generating API documentation for ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}"
"Doxygen not found, unable to add target for generating API documentation for ${META_TARGET_NAME}"
)
return()
endif ()
@ -62,12 +62,12 @@ list_to_string(" " "\"${DOXY_PATH_PREFIX}" "\"" "${DOXY_INPUT_FILES}" DOXY_INPUT
configure_file("${DOXYGEN_TEMPLATE_FILE}" "${CMAKE_CURRENT_BINARY_DIR}/doxygen.config")
# add target for generating API documentation
add_custom_target("${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_apidoc"
add_custom_target("${META_TARGET_NAME}_apidoc"
COMMAND "${DOXYGEN_BIN}" "${CMAKE_CURRENT_BINARY_DIR}/doxygen.config")
if (NOT TARGET apidoc)
add_custom_target(apidoc)
endif ()
add_dependencies(apidoc "${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_apidoc")
add_dependencies(apidoc "${META_TARGET_NAME}_apidoc")
# add install target for API documentation
if (NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
@ -84,5 +84,5 @@ endif ()
message(
STATUS
"Generating target for generating API documentation for ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} with Doxygen"
"Generating target for generating API documentation for ${META_TARGET_NAME} with Doxygen"
)

58
cmake/modules/LibraryTarget.cmake

@ -102,38 +102,38 @@ endif()
# add library to be created, set libs to link against, set version and C++ standard
if (META_HEADER_ONLY_LIB)
add_library(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} INTERFACE)
target_link_libraries(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
add_library(${META_TARGET_NAME} INTERFACE)
target_link_libraries(${META_TARGET_NAME}
INTERFACE ${META_ADDITIONAL_LINK_FLAGS} "${PUBLIC_LIBRARIES}" "${PRIVATE_LIBRARIES}")
target_include_directories(
${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
${META_TARGET_NAME}
INTERFACE $<BUILD_INTERFACE:${TARGET_INCLUDE_DIRECTORY_BUILD_INTERFACE}>
$<INSTALL_INTERFACE:${HEADER_INSTALL_DESTINATION}> ${PUBLIC_INCLUDE_DIRS})
target_compile_definitions(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
target_compile_definitions(${META_TARGET_NAME}
INTERFACE
"${META_PUBLIC_COMPILE_DEFINITIONS}"
"${META_PRIVATE_COMPILE_DEFINITIONS}")
target_compile_options(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
target_compile_options(${META_TARGET_NAME}
INTERFACE "${META_PUBLIC_COMPILE_OPTIONS}"
"${META_PRIVATE_COMPILE_OPTIONS}")
else ()
add_library(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} ${META_LIBRARY_TYPE} ${ALL_FILES})
target_link_libraries(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
add_library(${META_TARGET_NAME} ${META_LIBRARY_TYPE} ${ALL_FILES})
target_link_libraries(${META_TARGET_NAME}
PUBLIC ${META_ADDITIONAL_LINK_FLAGS} "${PUBLIC_LIBRARIES}"
PRIVATE "${PRIVATE_LIBRARIES}")
target_include_directories(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
target_include_directories(${META_TARGET_NAME}
PUBLIC $<BUILD_INTERFACE:${TARGET_INCLUDE_DIRECTORY_BUILD_INTERFACE}>
$<INSTALL_INTERFACE:${HEADER_INSTALL_DESTINATION}> ${PUBLIC_INCLUDE_DIRS}
PRIVATE "${PRIVATE_INCLUDE_DIRS}")
target_compile_definitions(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
target_compile_definitions(${META_TARGET_NAME}
PUBLIC
"${META_PUBLIC_COMPILE_DEFINITIONS}"
PRIVATE
"${META_PRIVATE_COMPILE_DEFINITIONS}")
target_compile_options(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
target_compile_options(${META_TARGET_NAME}
PUBLIC "${META_PUBLIC_LIB_COMPILE_OPTIONS}"
PRIVATE "${META_PRIVATE_LIB_COMPILE_OPTIONS}")
set_target_properties(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
set_target_properties(${META_TARGET_NAME}
PROPERTIES VERSION
"${META_VESION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}"
SOVERSION
@ -159,21 +159,21 @@ endif()
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(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_interface_sources_for_qtcreator
add_library(${META_TARGET_NAME}_interface_sources_for_qtcreator
EXCLUDE_FROM_ALL
"${CMAKE_CURRENT_BINARY_DIR}/headeronly.cpp"
${HEADER_FILES})
target_include_directories(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_interface_sources_for_qtcreator
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})
target_compile_definitions(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_interface_sources_for_qtcreator
target_compile_definitions(${META_TARGET_NAME}_interface_sources_for_qtcreator
INTERFACE
"${META_PUBLIC_LIB_COMPILE_DEFINITIONS}"
"${META_PRIVATE_LIB_COMPILE_DEFINITIONS}")
target_compile_options(
${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_interface_sources_for_qtcreator
${META_TARGET_NAME}_interface_sources_for_qtcreator
INTERFACE "${META_PUBLIC_LIB_COMPILE_OPTIONS}" "${META_PRIVATE_LIB_COMPILE_OPTIONS}")
set_target_properties(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_interface_sources_for_qtcreator
set_target_properties(${META_TARGET_NAME}_interface_sources_for_qtcreator
PROPERTIES VERSION
"${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}"
SOVERSION
@ -239,7 +239,7 @@ macro (depends_for_pc DEPENDS OUTPUT_VAR_PKGS OUTPUT_VAR_LIBS)
endforeach ()
endmacro ()
unset(PC_FILES)
set(META_PROJECT_NAME_FOR_PC "${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}")
set(META_PROJECT_NAME_FOR_PC "${META_TARGET_NAME}")
depends_for_pc(META_PUBLIC_LIB_DEPENDS META_PUBLIC_PC_PKGS META_PUBLIC_LIB_DEPENDS_FOR_PC)
depends_for_pc(META_PRIVATE_LIB_DEPENDS META_PRIVATE_PC_PKGS META_PRIVATE_LIB_DEPENDS_FOR_PC)
foreach (COMPILE_DEFINITION ${META_PUBLIC_LIB_COMPILE_DEFINITIONS})
@ -247,7 +247,7 @@ foreach (COMPILE_DEFINITION ${META_PUBLIC_LIB_COMPILE_DEFINITIONS})
endforeach ()
if (NOT META_HEADER_ONLY_LIB)
set(META_PUBLIC_LIB_DEPENDS_FOR_PC
" -l${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}${META_PUBLIC_LIB_DEPENDS_FOR_PC}")
" -l${META_TARGET_NAME}${META_PUBLIC_LIB_DEPENDS_FOR_PC}")
endif ()
if (META_PUBLIC_LIB_DEPENDS_FOR_PC)
set(META_PUBLIC_LIB_DEPENDS_FOR_PC " -L\${libdir}${META_PUBLIC_LIB_DEPENDS_FOR_PC}")
@ -311,13 +311,13 @@ if (NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
endif ()
# add install targets and export targets
install(TARGETS ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
install(TARGETS ${META_TARGET_NAME}
EXPORT ${META_PROJECT_NAME}Targets
RUNTIME DESTINATION bin COMPONENT binary
LIBRARY DESTINATION ${LIBRARY_DESTINATION} COMPONENT binary
ARCHIVE DESTINATION ${LIBRARY_DESTINATION} COMPONENT binary)
add_dependencies(install-binary ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX})
add_dependencies(install-binary-strip ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX})
add_dependencies(install-binary ${META_TARGET_NAME})
add_dependencies(install-binary-strip ${META_TARGET_NAME})
install(EXPORT ${META_PROJECT_NAME}Targets
DESTINATION "share/${META_PROJECT_NAME}/cmake"
EXPORT_LINK_INTERFACE_LIBRARIES
@ -390,27 +390,27 @@ if (NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
endif ()
if (BUILD_SHARED_LIBS AND NOT META_HEADER_ONLY_LIB)
add_custom_target(
install-${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}-mingw-w64-importlib-strip
install-${META_TARGET_NAME}-mingw-w64-importlib-strip
COMMAND
"${STRIP_BINARY_PATH}" -g
"\$\{DESTDIR\}\$\{DESTDIR:+/\}${CMAKE_INSTALL_PREFIX}/lib/lib${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}.dll.a"
"\$\{DESTDIR\}\$\{DESTDIR:+/\}${CMAKE_INSTALL_PREFIX}/lib/lib${META_TARGET_NAME}.dll.a"
)
add_dependencies(install-${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}-mingw-w64-importlib-strip
add_dependencies(install-${META_TARGET_NAME}-mingw-w64-importlib-strip
install-binary-strip)
add_dependencies(install-mingw-w64-strip
install-${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}-mingw-w64-importlib-strip)
install-${META_TARGET_NAME}-mingw-w64-importlib-strip)
endif ()
if (BUILD_STATIC_LIBS AND NOT META_HEADER_ONLY_LIB)
add_custom_target(
install-${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}-mingw-w64-staticlib-strip
install-${META_TARGET_NAME}-mingw-w64-staticlib-strip
COMMAND
"${STRIP_BINARY_PATH}" -g
"\$\{DESTDIR\}\$\{DESTDIR:+/\}${CMAKE_INSTALL_PREFIX}/lib/lib${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}.a"
"\$\{DESTDIR\}\$\{DESTDIR:+/\}${CMAKE_INSTALL_PREFIX}/lib/lib${META_TARGET_NAME}.a"
)
add_dependencies(install-${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}-mingw-w64-staticlib-strip
add_dependencies(install-${META_TARGET_NAME}-mingw-w64-staticlib-strip
install-binary-strip)
add_dependencies(install-mingw-w64-strip
install-${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}-mingw-w64-staticlib-strip)
install-${META_TARGET_NAME}-mingw-w64-staticlib-strip)
endif ()
endif ()
endif ()

82
cmake/modules/TestTarget.cmake

@ -81,23 +81,23 @@ if (EXCLUDE_TESTS_FROM_ALL)
else ()
unset(TESTS_EXCLUSION)
endif ()
add_executable(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests
add_executable(${META_TARGET_NAME}_tests
${TESTS_EXCLUSION}
${TEST_HEADER_FILES}
${TEST_SRC_FILES})
# add top-level target to build all test targets conveniently, also when excluded from "all" target
if (NOT TARGET tests)
add_custom_target(tests DEPENDS ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests)
add_custom_target(tests DEPENDS ${META_TARGET_NAME}_tests)
else ()
add_dependencies(tests ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests)
add_dependencies(tests ${META_TARGET_NAME}_tests)
endif ()
# handle testing a library (which is default project type)
if (META_PROJECT_IS_LIBRARY)
# when testing a library, the test application always needs to link against it
list(APPEND TEST_LIBRARIES ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX})
message(STATUS "Linking test target against ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}")
list(APPEND TEST_LIBRARIES ${META_TARGET_NAME})
message(STATUS "Linking test target against ${META_TARGET_NAME}")
endif ()
# handle testing an application
@ -107,23 +107,23 @@ if (META_PROJECT_IS_APPLICATION)
# create target for the 'testlib'
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(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_testlib SHARED ${TESTLIB_FILES})
target_link_libraries(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_testlib
add_library(${META_TARGET_NAME}_testlib SHARED ${TESTLIB_FILES})
target_link_libraries(${META_TARGET_NAME}_testlib
PUBLIC ${ACTUAL_ADDITIONAL_LINK_FLAGS} "${PUBLIC_LIBRARIES}"
PRIVATE "${PRIVATE_LIBRARIES}")
target_include_directories(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_testlib
target_include_directories(${META_TARGET_NAME}_testlib
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${HEADER_INSTALL_DESTINATION}> ${PUBLIC_INCLUDE_DIRS}
PRIVATE "${PRIVATE_INCLUDE_DIRS}")
target_compile_definitions(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_testlib
target_compile_definitions(${META_TARGET_NAME}_testlib
PUBLIC
"${META_PUBLIC_COMPILE_DEFINITIONS}"
PRIVATE
"${META_PRIVATE_COMPILE_DEFINITIONS}")
target_compile_options(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_testlib
target_compile_options(${META_TARGET_NAME}_testlib
PUBLIC "${META_PUBLIC_COMPILE_OPTIONS}"
PRIVATE "${META_PRIVATE_COMPILE_OPTIONS}")
set_target_properties(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_testlib
set_target_properties(${META_TARGET_NAME}_testlib
PROPERTIES CXX_STANDARD
"${META_CXX_STANDARD}"
LINK_SEARCH_START_STATIC
@ -133,36 +133,36 @@ if (META_PROJECT_IS_APPLICATION)
AUTOGEN_TARGET_DEPENDS
"${AUTOGEN_DEPS}")
if (CPP_UNIT_CONFIG_${META_PROJECT_NAME}_FOUND)
target_include_directories(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_testlib
target_include_directories(${META_TARGET_NAME}_testlib
PRIVATE "${CPP_UNIT_CONFIG_${META_PROJECT_NAME}_INCLUDE_DIRS}")
target_compile_options(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_testlib
target_compile_options(${META_TARGET_NAME}_testlib
PRIVATE "${CPP_UNIT_CONFIG_${META_PROJECT_NAME}_CFLAGS_OTHER}")
endif ()
# link tests against it
list(APPEND TEST_LIBRARIES ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_testlib)
list(APPEND TEST_LIBRARIES ${META_TARGET_NAME}_testlib)
# ensure all symbols are visible (man gcc: "Despite the nomenclature, default always means public")
set_target_properties(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_testlib
set_target_properties(${META_TARGET_NAME}_testlib
PROPERTIES CXX_VISIBILITY_PRESET default)
endif ()
endif ()
# configure test target
target_link_libraries(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests
target_link_libraries(${META_TARGET_NAME}_tests
PUBLIC ${ACTUAL_ADDITIONAL_LINK_FLAGS} "${PUBLIC_LIBRARIES}"
PRIVATE "${TEST_LIBRARIES}" "${PRIVATE_LIBRARIES}")
target_include_directories(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests
target_include_directories(${META_TARGET_NAME}_tests
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${HEADER_INSTALL_DESTINATION}> ${PUBLIC_INCLUDE_DIRS}
PRIVATE ${TEST_INCLUDE_DIRS} "${PRIVATE_INCLUDE_DIRS}")
target_compile_definitions(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests
target_compile_definitions(${META_TARGET_NAME}_tests
PUBLIC
"${META_PUBLIC_COMPILE_DEFINITIONS}"
PRIVATE
"${META_PRIVATE_COMPILE_DEFINITIONS}")
target_compile_options(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests
target_compile_options(${META_TARGET_NAME}_tests
PUBLIC "${META_PUBLIC_COMPILE_OPTIONS}"
PRIVATE "${META_PRIVATE_COMPILE_OPTIONS}")
set_target_properties(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests
set_target_properties(${META_TARGET_NAME}_tests
PROPERTIES CXX_STANDARD
"${META_CXX_STANDARD}"
LINK_SEARCH_START_STATIC
@ -173,11 +173,11 @@ set_target_properties(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests
# make the test recognized by ctest
unset(RUN_TESTS_APPLICATION_ARG)
if (META_PROJECT_TYPE STREQUAL "application")
set(RUN_TESTS_APPLICATION_ARGS -a "$<TARGET_FILE:${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}>")
set(RUN_TESTS_APPLICATION_ARGS -a "$<TARGET_FILE:${META_TARGET_NAME}>")
endif ()
if (NOT META_TEST_TARGET_IS_MANUAL)
add_test(NAME ${META_PROJECT_NAME}_run_tests
COMMAND ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_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 ()
@ -185,22 +185,22 @@ endif ()
if (CLANG_SOURCE_BASED_COVERAGE_AVAILABLE)
# define path of raw profile data
set(LLVM_PROFILE_RAW_FILE
"${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests.profraw")
"${CMAKE_CURRENT_BINARY_DIR}/${META_TARGET_NAME}_tests.profraw")
# define path of list with additional raw profile data from fork processes spawned during tests
set(LLVM_PROFILE_RAW_LIST_FILE
"${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests.profraw.list")
"${CMAKE_CURRENT_BINARY_DIR}/${META_TARGET_NAME}_tests.profraw.list")
# define path of merged profile data generated from raw profiling data
set(LLVM_PROFILE_DATA_FILE
"${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests.profdata")
"${CMAKE_CURRENT_BINARY_DIR}/${META_TARGET_NAME}_tests.profdata")
# define paths of output files
set(COVERAGE_REPORT_FILE
"${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests_coverage.txt")
"${CMAKE_CURRENT_BINARY_DIR}/${META_TARGET_NAME}_tests_coverage.txt")
set(COVERAGE_PER_FILE_REPORT_FILE
"${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests_coverage_per_file.txt")
"${CMAKE_CURRENT_BINARY_DIR}/${META_TARGET_NAME}_tests_coverage_per_file.txt")
set(COVERAGE_OVERALL_REPORT_FILE
"${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests_coverage_overall.txt")
"${CMAKE_CURRENT_BINARY_DIR}/${META_TARGET_NAME}_tests_coverage_overall.txt")
set(COVERAGE_HTML_REPORT_FILE
"${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests_coverage.html")
"${CMAKE_CURRENT_BINARY_DIR}/${META_TARGET_NAME}_tests_coverage.html")
set(COVERAGE_REPORT_FILES "${COVERAGE_REPORT_FILE}")
# specify where to store raw clang profiling data via environment variable
if (NOT META_TEST_TARGET_IS_MANUAL)
@ -213,12 +213,12 @@ if (CLANG_SOURCE_BASED_COVERAGE_AVAILABLE)
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:${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests> -p
$<TARGET_FILE:${META_TARGET_NAME}_tests> -p
"${CMAKE_CURRENT_SOURCE_DIR}/testfiles" -w "${CMAKE_CURRENT_BINARY_DIR}/testworkingdir"
${RUN_TESTS_APPLICATION_ARGS}
COMMENT
"Executing ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests to generate raw profiling data for source-based coverage report"
DEPENDS "${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests")
"Executing ${META_TARGET_NAME}_tests to generate raw profiling data for source-based coverage report"
DEPENDS "${META_TARGET_NAME}_tests")
find_program(LLVM_PROFDATA_BIN llvm-profdata)
find_program(LLVM_COV_BIN llvm-cov)
if (LLVM_PROFDATA_BIN AND LLVM_COV_BIN)
@ -243,10 +243,10 @@ if (CLANG_SOURCE_BASED_COVERAGE_AVAILABLE)
endif ()
# determine the target file for llvm-cov
if (NOT META_HEADER_ONLY_LIB)
set(LLVM_COV_TARGET_FILE $<TARGET_FILE:${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}>
$<TARGET_FILE:${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests>)
set(LLVM_COV_TARGET_FILE $<TARGET_FILE:${META_TARGET_NAME}>
$<TARGET_FILE:${META_TARGET_NAME}_tests>)
else ()
set(LLVM_COV_TARGET_FILE $<TARGET_FILE:${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests>)
set(LLVM_COV_TARGET_FILE $<TARGET_FILE:${META_TARGET_NAME}_tests>)
endif ()
# generate coverage report with statistics per function
unset(LLVM_COV_ADDITIONAL_OPTIONS)
@ -276,7 +276,7 @@ if (CLANG_SOURCE_BASED_COVERAGE_AVAILABLE)
list(APPEND COVERAGE_REPORT_FILES "${COVERAGE_PER_FILE_REPORT_FILE}")
endif ()
# add target for the coverage reports
add_custom_target("${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests_coverage_summary"
add_custom_target("${META_TARGET_NAME}_tests_coverage_summary"
DEPENDS ${COVERAGE_REPORT_FILES})
# generate coverage overall report (total region/line coverage) NOTE: added before release of LLVM 5 where coverage
# report with statistics per file could not be generated
@ -292,7 +292,7 @@ if (CLANG_SOURCE_BASED_COVERAGE_AVAILABLE)
"${COVERAGE_OVERALL_REPORT_FILE}"
COMMENT "Generating coverage report (overall figures)"
DEPENDS "${OVERALL_COVERAGE_AKW_SCRIPT}" "${COVERAGE_REPORT_FILE}")
add_custom_target("${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests_coverage_overall_summary"
add_custom_target("${META_TARGET_NAME}_tests_coverage_overall_summary"
DEPENDS "${COVERAGE_OVERALL_REPORT_FILE}")
# generate HTML document showing covered/uncovered code
add_custom_command(OUTPUT "${COVERAGE_HTML_REPORT_FILE}"
@ -302,10 +302,10 @@ if (CLANG_SOURCE_BASED_COVERAGE_AVAILABLE)
COMMENT "Generating HTML document showing covered/uncovered code"
DEPENDS "${LLVM_PROFILE_DATA_FILE}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
add_custom_target("${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests_coverage_html"
add_custom_target("${META_TARGET_NAME}_tests_coverage_html"
DEPENDS "${COVERAGE_HTML_REPORT_FILE}")
# create target for all coverage docs
add_custom_target("${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests_coverage"
add_custom_target("${META_TARGET_NAME}_tests_coverage"
DEPENDS ${COVERAGE_REPORT_FILES}
DEPENDS "${COVERAGE_OVERALL_REPORT_FILE}"
DEPENDS "${COVERAGE_HTML_REPORT_FILE}")
@ -313,7 +313,7 @@ if (CLANG_SOURCE_BASED_COVERAGE_AVAILABLE)
if (NOT TARGET coverage)
add_custom_target(coverage)
endif ()
add_dependencies(coverage "${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests_coverage")
add_dependencies(coverage "${META_TARGET_NAME}_tests_coverage")
else ()
message(
FATAL_ERROR "Unable to generate target for coverage report because llvm-profdata and llvm-cov are not available."
@ -323,7 +323,7 @@ endif ()
# add the test executable to the dependencies of the check target
if (NOT META_TEST_TARGET_IS_MANUAL)
add_dependencies(check ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests)
add_dependencies(check ${META_TARGET_NAME}_tests)
endif ()
set(META_HAVE_TESTS YES)

2
cmake/templates/Config.cmake.in

@ -29,7 +29,7 @@ set(@META_PROJECT_VARNAME_UPPER@_HAS_QT_TRANSLATION_FILES @APP_SPECIFIC_QT_TRANS
set(@META_PROJECT_VARNAME_UPPER@_QT_RESOURCES @QT_RESOURCES@)
# define library config
set(@META_PROJECT_VARNAME_UPPER@_LIB "@TARGET_PREFIX@@META_PROJECT_NAME@@TARGET_SUFFIX@")
set(@META_PROJECT_VARNAME_UPPER@_LIB "@META_TARGET_NAME@")
set(@META_PROJECT_VARNAME_UPPER@_LIB_IS_SHARED "@BUILD_SHARED_LIBS@")
set(PKG_CONFIG_@META_PROJECT_NAME@ "@META_PROJECT_NAME@")
if(NOT TARGET "${@META_PROJECT_VARNAME_UPPER@_LIB}")

2
cmake/templates/appdata.xml.in

@ -11,7 +11,7 @@
<launchable type="desktop-id">@META_ID@.desktop</launchable>
<developer_name>@META_APP_AUTHOR@</developer_name>
<provides>
<binary>@TARGET_PREFIX@@META_PROJECT_NAME@@TARGET_SUFFIX@</binary>
<binary>@META_TARGET_NAME@/binary>
</provides>
<releases>
<release version="@META_APP_VERSION@"/>

4
cmake/templates/bash-completion.sh.in

@ -1,6 +1,6 @@
_@TARGET_PREFIX@@META_PROJECT_NAME@@TARGET_SUFFIX@()
_@META_TARGET_NAME@()
{
eval "$(@TARGET_EXECUTABLE@ --bash-completion-for "$((COMP_CWORD - 1))" "${COMP_WORDS[@]:1}")"
return 0;
}
complete -F _@TARGET_PREFIX@@META_PROJECT_NAME@@TARGET_SUFFIX@ @TARGET_PREFIX@@META_PROJECT_NAME@@TARGET_SUFFIX@
complete -F _@META_TARGET_NAME@ @META_TARGET_NAME@

Loading…
Cancel
Save