Browse Source

Apply cmake-format

sendfile
Martchus 3 years ago
parent
commit
86f3bf8b3b
  1. 110
      CMakeLists.txt
  2. 381
      cmake/modules/3rdParty.cmake
  3. 364
      cmake/modules/AppTarget.cmake
  4. 506
      cmake/modules/BasicConfig.cmake
  5. 67
      cmake/modules/ConfigHeader.cmake
  6. 74
      cmake/modules/Doxygen.cmake
  7. 710
      cmake/modules/LibraryTarget.cmake
  8. 26
      cmake/modules/ListToString.cmake
  9. 34
      cmake/modules/ShellCompletion.cmake
  10. 18
      cmake/modules/TemplateFinder.cmake
  11. 461
      cmake/modules/TestTarget.cmake
  12. 57
      cmake/modules/WindowsResources.cmake

110
CMakeLists.txt

@ -36,8 +36,7 @@ set(HEADER_FILES
misc/levenshtein.h
tests/testutils.h
tests/cppunit.h
tests/outputcheck.h
)
tests/outputcheck.h)
set(SRC_FILES
application/argumentparserprivate.h
application/argumentparser.cpp
@ -61,12 +60,9 @@ set(SRC_FILES
math/math.cpp
misc/random.cpp
misc/levenshtein.cpp
tests/testutils.cpp
)
tests/testutils.cpp)
set(TEST_HEADER_FILES
)
set(TEST_HEADER_FILES)
set(TEST_SRC_FILES
tests/cppunit.cpp
tests/conversiontests.cpp
@ -75,8 +71,7 @@ set(TEST_SRC_FILES
tests/argumentparsertests.cpp
tests/traitstests.cpp
tests/mathtests.cpp
tests/misctests.cpp
)
tests/misctests.cpp)
set(CMAKE_MODULE_FILES
cmake/modules/BasicConfig.cmake
@ -89,8 +84,7 @@ set(CMAKE_MODULE_FILES
cmake/modules/Doxygen.cmake
cmake/modules/ListToString.cmake
cmake/modules/ShellCompletion.cmake
cmake/modules/3rdParty.cmake
)
cmake/modules/3rdParty.cmake)
set(CMAKE_TEMPLATE_FILES
cmake/templates/bash-completion.sh.in
cmake/templates/Config.cmake.in
@ -101,28 +95,15 @@ set(CMAKE_TEMPLATE_FILES
cmake/templates/appdata.xml.in
cmake/templates/doxygen.in
cmake/templates/global.h.in
cmake/templates/template.pc.in
)
set(SCRIPT_FILES
)
if(MINGW)
list(APPEND CMAKE_TEMPLATE_FILES
cmake/templates/windows.rc.in
)
list(APPEND SCRIPT_FILES
scripts/wine.sh
)
endif()
cmake/templates/template.pc.in)
set(SCRIPT_FILES)
if (MINGW)
list(APPEND CMAKE_TEMPLATE_FILES cmake/templates/windows.rc.in)
list(APPEND SCRIPT_FILES scripts/wine.sh)
endif ()
set(DOC_FILES
README.md
doc/buildvariables.md
doc/testapplication.md
)
set(EXTRA_FILES
tests/calculateoverallcoverage.awk
coding-style.clang-format
)
set(DOC_FILES README.md doc/buildvariables.md doc/testapplication.md)
set(EXTRA_FILES tests/calculateoverallcoverage.awk coding-style.clang-format)
# required to include CMake modules from own project directory
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" "${CMAKE_MODULE_PATH}")
@ -146,62 +127,57 @@ use_iconv(AUTO_LINKAGE REQUIRED)
# configure use of native file buffer and its backend implementation if enabled
option(USE_NATIVE_FILE_BUFFER "enables use of native file buffer, affects ABI" OFF)
option(FORCE_BOOST_IOSTREAMS_FOR_NATIVE_FILE_BUFFER "forces use of Boost.Iostreams for native file buffer" OFF)
if(USE_NATIVE_FILE_BUFFER)
if (USE_NATIVE_FILE_BUFFER)
list(APPEND META_PUBLIC_COMPILE_DEFINITIONS ${META_PROJECT_VARNAME}_USE_NATIVE_FILE_BUFFER)
# check whether __gnu_cxx::stdio_filebuf is available
try_compile(GNU_CXX_STDIO_FILEBUF_AVAILABLE ${CMAKE_CURRENT_BINARY_DIR}
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/feature_detection/stdio_filebuf.cpp
OUTPUT_VARIABLE GNU_CXX_STDIO_FILEBUF_CHECK_LOG
)
try_compile(GNU_CXX_STDIO_FILEBUF_AVAILABLE
${CMAKE_CURRENT_BINARY_DIR}
SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/feature_detection/stdio_filebuf.cpp
OUTPUT_VARIABLE GNU_CXX_STDIO_FILEBUF_CHECK_LOG)
# use __gnu_cxx::stdio_filebuf if available or fallback to boost::iostreams::stream_buffer
if(GNU_CXX_STDIO_FILEBUF_AVAILABLE AND NOT FORCE_BOOST_IOSTREAMS_FOR_NATIVE_FILE_BUFFER)
if (GNU_CXX_STDIO_FILEBUF_AVAILABLE AND NOT FORCE_BOOST_IOSTREAMS_FOR_NATIVE_FILE_BUFFER)
message(STATUS "Using __gnu_cxx::stdio_filebuf for NativeFileStream")
set_property(
SOURCE io/nativefilestream.cpp
APPEND PROPERTY COMPILE_DEFINITIONS ${META_PROJECT_VARNAME}_USE_GNU_CXX_STDIO_FILEBUF
)
else()
set_property(SOURCE io/nativefilestream.cpp
APPEND
PROPERTY COMPILE_DEFINITIONS ${META_PROJECT_VARNAME}_USE_GNU_CXX_STDIO_FILEBUF)
else ()
message(STATUS "Using boost::iostreams::stream_buffer<boost::iostreams::file_descriptor_sink> for NativeFileStream")
set(boost_iostreams_DYNAMIC_COMPILE_DEFINITIONS BOOST_IOSTREAMS_DYN_LINK)
use_external_library(boost_iostreams AUTO_LINKAGE REQUIRED)
set_property(
SOURCE io/nativefilestream.cpp
APPEND PROPERTY COMPILE_DEFINITIONS ${META_PROJECT_VARNAME}_USE_BOOST_IOSTREAMS
)
endif()
else()
set_property(SOURCE io/nativefilestream.cpp
APPEND
PROPERTY COMPILE_DEFINITIONS ${META_PROJECT_VARNAME}_USE_BOOST_IOSTREAMS)
endif ()
else ()
message(STATUS "Using std::fstream for NativeFileStream")
endif()
endif ()
# configure forcing UTF-8 code page under Windows
option(FORCE_UTF8_CODEPAGE "forces use of UTF-8 code page under Windows via ApplicationUtilities::startConsole()" OFF)
if(FORCE_UTF8_CODEPAGE)
if (FORCE_UTF8_CODEPAGE)
list(APPEND META_PRIVATE_COMPILE_DEFINITIONS ${META_PROJECT_VARNAME}_FORCE_UTF8_CODEPAGE)
endif()
endif ()
# configure whether escape codes should be enabled by default
option(ENABLE_ESCAPE_CODES_BY_DEAULT "enables usage of escape codes by default" ON)
if(ENABLE_ESCAPE_CODES_BY_DEAULT)
set_property(
SOURCE application/argumentparser.cpp
io/ansiescapecodes.cpp
tests/argumentparsertests.cpp
APPEND PROPERTY COMPILE_DEFINITIONS ${META_PROJECT_VARNAME}_ESCAPE_CODES_ENABLED_BY_DEFAULT
)
else()
if (ENABLE_ESCAPE_CODES_BY_DEAULT)
set_property(SOURCE application/argumentparser.cpp io/ansiescapecodes.cpp tests/argumentparsertests.cpp
APPEND
PROPERTY COMPILE_DEFINITIONS ${META_PROJECT_VARNAME}_ESCAPE_CODES_ENABLED_BY_DEFAULT)
else ()
message(STATUS "Disabling use of escape codes by default.")
endif()
endif ()
# configure use of thread_local
option(ENABLE_THREAD_LOCAL "enables use of Thread-Local Storage" ON)
if(NOT ENABLE_THREAD_LOCAL)
set_property(
SOURCE conversion/stringconversion.cpp
APPEND PROPERTY COMPILE_DEFINITIONS ${META_PROJECT_VARNAME}_NO_THREAD_LOCAL
)
endif()
if (NOT ENABLE_THREAD_LOCAL)
set_property(SOURCE conversion/stringconversion.cpp
APPEND
PROPERTY COMPILE_DEFINITIONS ${META_PROJECT_VARNAME}_NO_THREAD_LOCAL)
endif ()
# include modules to apply configuration
include(BasicConfig)

381
cmake/modules/3rdParty.cmake

@ -1,195 +1,258 @@
cmake_minimum_required(VERSION 3.3.0 FATAL_ERROR)
# prevent multiple inclusion
if(DEFINED THIRD_PARTY_MODULE_LOADED)
if (DEFINED THIRD_PARTY_MODULE_LOADED)
return()
endif()
endif ()
set(THIRD_PARTY_MODULE_LOADED YES)
macro(save_default_library_suffixes)
macro (save_default_library_suffixes)
set(DEFAULT_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
endmacro()
endmacro ()
macro(restore_default_library_suffixes)
macro (restore_default_library_suffixes)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${DEFAULT_CMAKE_FIND_LIBRARY_SUFFIXES})
unset(DEFAULT_CMAKE_FIND_LIBRARY_SUFFIXES)
endmacro()
endmacro ()
macro(configure_static_library_suffixes)
macro (configure_static_library_suffixes)
# allows to look for static libraries in particular
if(WIN32)
if (WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a .lib)
else()
else ()
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
endif()
endmacro()
endif ()
endmacro ()
macro(configure_dynamic_library_suffixes)
macro (configure_dynamic_library_suffixes)
# allows to look for dynamic libraries in particular
if(WIN32)
if (WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES .dll .dll.a)
elseif(APPLE)
elseif (APPLE)
set(CMAKE_FIND_LIBRARY_SUFFIXES .dylib .so)
else()
else ()
set(CMAKE_FIND_LIBRARY_SUFFIXES .so)
endif()
endmacro()
endif ()
endmacro ()
macro(link_against_library_varnames NAME LINKAGE REQUIRED PRIVATE_LIBRARIES_VARNAME PUBLIC_LIBRARIES_VARNAME PRIVATE_STATIC_LIBRARIES_VARNAME PUBLIC_STATIC_LIBRARIES_VARNAME)
# determine whether the library is required or optional
# FIXME: improve passing required argument
if("${REQUIRED}" STREQUAL "OPTIONAL")
macro (link_against_library_varnames
NAME
LINKAGE
REQUIRED
PRIVATE_LIBRARIES_VARNAME
PUBLIC_LIBRARIES_VARNAME
PRIVATE_STATIC_LIBRARIES_VARNAME
PUBLIC_STATIC_LIBRARIES_VARNAME)
# determine whether the library is required or optional FIXME: improve passing required argument
if ("${REQUIRED}" STREQUAL "OPTIONAL")
set(${NAME}_REQUIRED "NO")
elseif("${REQUIRED}" STREQUAL "REQUIRED")
elseif ("${REQUIRED}" STREQUAL "REQUIRED")
set(${NAME}_REQUIRED "REQUIRED")
else()
else ()
message(FATAL_ERROR "Invalid use of link_against_library; must specify either REQUIRED or OPTIONAL.")
endif()
endif ()
# add library to list of libraries to link against when building dynamic libraries or applications
# - prefer dynamic lib if linkage not explicitely specified
if(${NAME}_STATIC_LIB AND (("${LINKAGE}" STREQUAL "AUTO_LINKAGE" AND ((NOT (${NAME}_DYNAMIC_LIB OR ${NAME}_SHARED_LIB)) OR (STATIC_LINKAGE AND "${META_PROJECT_TYPE}" STREQUAL "application") OR (STATIC_LIBRARY_LINKAGE AND ("${META_PROJECT_TYPE}" STREQUAL "" OR "${META_PROJECT_TYPE}" STREQUAL "library")))) OR ("${LINKAGE}" STREQUAL "STATIC")))
# add library to list of libraries to link against when building dynamic libraries or applications - prefer dynamic lib
# if linkage not explicitely specified
if (${NAME}_STATIC_LIB
AND (("${LINKAGE}" STREQUAL "AUTO_LINKAGE"
AND ((NOT (${NAME}_DYNAMIC_LIB OR ${NAME}_SHARED_LIB))
OR (STATIC_LINKAGE AND "${META_PROJECT_TYPE}" STREQUAL "application")
OR (STATIC_LIBRARY_LINKAGE
AND ("${META_PROJECT_TYPE}" STREQUAL "" OR "${META_PROJECT_TYPE}" STREQUAL "library"))))
OR ("${LINKAGE}" STREQUAL "STATIC")))
set(USE_${NAME} ON)
set(USE_STATIC_${NAME} ON)
list(APPEND LIBRARIES ${${NAME}_STATIC_LIB})
message(STATUS "Linking ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} statically against external library ${NAME} (${${NAME}_STATIC_LIB}).")
if(${NAME}_STATIC_INCLUDE_DIR)
message(
STATUS
"Linking ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} statically against external library ${NAME} (${${NAME}_STATIC_LIB})."
)
if (${NAME}_STATIC_INCLUDE_DIR)
list(APPEND ADDITIONAL_STATIC_INCLUDE_DIRS ${${NAME}_STATIC_INCLUDE_DIR})
message(STATUS "Adding include path for ${NAME} to ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}: ${${NAME}_STATIC_INCLUDE_DIR}")
endif()
if(${NAME}_STATIC_COMPILE_DEFINITIONS)
message(
STATUS
"Adding include path for ${NAME} to ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}: ${${NAME}_STATIC_INCLUDE_DIR}"
)
endif ()
if (${NAME}_STATIC_COMPILE_DEFINITIONS)
list(APPEND META_PRIVATE_STATIC_LIB_COMPILE_DEFINITIONS ${${NAME}_STATIC_COMPILE_DEFINITIONS})
endif()
endif ()
if(${${NAME}_STATIC_LIB} IN_LIST META_PUBLIC_STATIC_LIB_DEPENDS OR ${NAME} IN_LIST META_PUBLIC_STATIC_LIB_DEPENDS)
if (${${NAME}_STATIC_LIB} IN_LIST META_PUBLIC_STATIC_LIB_DEPENDS OR ${NAME} IN_LIST META_PUBLIC_STATIC_LIB_DEPENDS)
list(APPEND ${PUBLIC_LIBRARIES_VARNAME} ${${NAME}_STATIC_LIB})
if(${NAME}_STATIC_INCLUDE_DIR)
if (${NAME}_STATIC_INCLUDE_DIR)
list(APPEND PUBLIC_SHARED_INCLUDE_DIRS ${${NAME}_STATIC_INCLUDE_DIR})
endif()
else()
endif ()
else ()
list(APPEND ${PRIVATE_LIBRARIES_VARNAME} ${${NAME}_STATIC_LIB})
if(${NAME}_STATIC_INCLUDE_DIR)
if (${NAME}_STATIC_INCLUDE_DIR)
list(APPEND PRIVATE_SHARED_INCLUDE_DIRS ${${NAME}_STATIC_INCLUDE_DIR})
endif()
endif()
endif ()
endif ()
# add Qt resources of static library to be enabled
if(${NAME}_QT_RESOURCES)
if (${NAME}_QT_RESOURCES)
message(STATUS "Adding ${${NAME}_QT_RESOURCES} to LIBRARIES_QT_RESOURCES for ${META_PROJECT_NAME}.")
list(APPEND LIBRARIES_QT_RESOURCES ${${NAME}_QT_RESOURCES})
endif()
endif ()
elseif((${NAME}_DYNAMIC_LIB OR ${NAME}_SHARED_LIB) AND (("${LINKAGE}" STREQUAL "AUTO_LINKAGE") OR ("${LINKAGE}" STREQUAL "SHARED")))
elseif ((${NAME}_DYNAMIC_LIB OR ${NAME}_SHARED_LIB)
AND (("${LINKAGE}" STREQUAL "AUTO_LINKAGE") OR ("${LINKAGE}" STREQUAL "SHARED")))
set(USE_${NAME} ON)
set(USE_SHARED_${NAME} ON)
if(NOT ${NAME}_DYNAMIC_LIB)
if (NOT ${NAME}_DYNAMIC_LIB)
set(${NAME}_DYNAMIC_LIB ${${NAME}_SHARED_LIB})
endif()
endif ()
list(APPEND LIBRARIES ${${NAME}_DYNAMIC_LIB})
message(STATUS "Linking ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} dynamically against external library ${NAME} (${${NAME}_DYNAMIC_LIB}).")
if(${NAME}_DYNAMIC_INCLUDE_DIR)
message(
STATUS
"Linking ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} dynamically against external library ${NAME} (${${NAME}_DYNAMIC_LIB})."
)
if (${NAME}_DYNAMIC_INCLUDE_DIR)
list(APPEND ADDITIONAL_SHARED_INCLUDE_DIRS ${${NAME}_DYNAMIC_INCLUDE_DIR})
message(STATUS "Adding include path for ${NAME} to ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}: ${${NAME}_DYNAMIC_INCLUDE_DIR}")
endif()
if(${NAME}_DYNAMIC_COMPILE_DEFINITIONS)
message(
STATUS
"Adding include path for ${NAME} to ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}: ${${NAME}_DYNAMIC_INCLUDE_DIR}"
)
endif ()
if (${NAME}_DYNAMIC_COMPILE_DEFINITIONS)
list(APPEND META_PRIVATE_SHARED_LIB_COMPILE_DEFINITIONS ${${NAME}_DYNAMIC_COMPILE_DEFINITIONS})
endif()
endif ()
if(${${NAME}_DYNAMIC_LIB} IN_LIST META_PUBLIC_SHARED_LIB_DEPENDS OR ${NAME} IN_LIST META_PUBLIC_SHARED_LIB_DEPENDS)
if (${${NAME}_DYNAMIC_LIB} IN_LIST META_PUBLIC_SHARED_LIB_DEPENDS OR ${NAME} IN_LIST META_PUBLIC_SHARED_LIB_DEPENDS)
list(APPEND ${PUBLIC_LIBRARIES_VARNAME} ${${NAME}_DYNAMIC_LIB})
if(${NAME}_DYNAMIC_INCLUDE_DIR)
if (${NAME}_DYNAMIC_INCLUDE_DIR)
list(APPEND PUBLIC_SHARED_INCLUDE_DIRS ${${NAME}_DYNAMIC_INCLUDE_DIR})
endif()
else()
endif ()
else ()
list(APPEND ${PRIVATE_LIBRARIES_VARNAME} ${${NAME}_DYNAMIC_LIB})
if(${NAME}_DYNAMIC_INCLUDE_DIR)
if (${NAME}_DYNAMIC_INCLUDE_DIR)
list(APPEND PRIVATE_SHARED_INCLUDE_DIRS ${${NAME}_DYNAMIC_INCLUDE_DIR})
endif()
endif()
else()
if(${NAME}_REQUIRED)
message(FATAL_ERROR "External library ${NAME} required by ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} is not available for the specified linkage ${LINKAGE}.")
else()
message(WARNING "External library ${NAME} required by ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} is not available for the specified linkage ${LINKAGE}.")
endif()
endif()
endif ()
endif ()
else ()
if (${NAME}_REQUIRED)
message(
FATAL_ERROR
"External library ${NAME} required by ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} is not available for the specified linkage ${LINKAGE}."
)
else ()
message(
WARNING
"External library ${NAME} required by ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} is not available for the specified linkage ${LINKAGE}."
)
endif ()
endif ()
# add library to list of libraries to be provided as transitive dependencies when building static libraries
# - prefer static lib if linkage not explicitely specified
if(${NAME}_STATIC_LIB AND ("${LINKAGE}" STREQUAL "AUTO_LINKAGE") OR ("${LINKAGE}" STREQUAL "STATIC"))
# add library to list of libraries to be provided as transitive dependencies when building static libraries - prefer
# static lib if linkage not explicitely specified
if (${NAME}_STATIC_LIB AND ("${LINKAGE}" STREQUAL "AUTO_LINKAGE") OR ("${LINKAGE}" STREQUAL "STATIC"))
set(USE_${NAME} ON)
set(USE_STATIC_${NAME} ON)
list(APPEND STATIC_LIBRARIES ${${NAME}_STATIC_LIB})
message(STATUS "Adding static external library ${NAME} (${${NAME}_STATIC_LIB}) to dependencies of ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}.")
if(${NAME}_STATIC_INCLUDE_DIR)
message(
STATUS
"Adding static external library ${NAME} (${${NAME}_STATIC_LIB}) to dependencies of ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}."
)
if (${NAME}_STATIC_INCLUDE_DIR)
list(APPEND ADDITIONAL_STATIC_INCLUDE_DIRS ${${NAME}_STATIC_INCLUDE_DIR})
message(STATUS "Adding include path for ${NAME} to static ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}: ${${NAME}_STATIC_INCLUDE_DIR}")
endif()
message(
STATUS
"Adding include path for ${NAME} to static ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}: ${${NAME}_STATIC_INCLUDE_DIR}"
)
endif ()
if(${${NAME}_STATIC_LIB} IN_LIST META_PUBLIC_STATIC_LIB_DEPENDS OR ${NAME} IN_LIST META_PUBLIC_STATIC_LIB_DEPENDS)
if (${${NAME}_STATIC_LIB} IN_LIST META_PUBLIC_STATIC_LIB_DEPENDS OR ${NAME} IN_LIST META_PUBLIC_STATIC_LIB_DEPENDS)
list(APPEND ${PUBLIC_STATIC_LIBRARIES_VARNAME} ${${NAME}_STATIC_LIB})
if(${NAME}_STATIC_INCLUDE_DIR)
if (${NAME}_STATIC_INCLUDE_DIR)
list(APPEND PUBLIC_STATIC_INCLUDE_DIRS ${${NAME}_STATIC_INCLUDE_DIR})
endif()
else()
endif ()
else ()
list(APPEND ${PRIVATE_STATIC_LIBRARIES_VARNAME} ${${NAME}_STATIC_LIB})
if(${NAME}_STATIC_INCLUDE_DIR)
if (${NAME}_STATIC_INCLUDE_DIR)
list(APPEND PRIVATE_STATIC_INCLUDE_DIRS ${${NAME}_STATIC_INCLUDE_DIR})
endif()
endif()
endif ()
endif ()
# add Qt resources of static library for exporting it
if(${NAME}_QT_RESOURCES)
if (${NAME}_QT_RESOURCES)
message(STATUS "Adding ${${NAME}_QT_RESOURCES} to STATIC_LIBRARIES_QT_RESOURCES for ${META_PROJECT_NAME}.")
list(APPEND STATIC_LIBRARIES_QT_RESOURCES ${${NAME}_QT_RESOURCES})
endif()
endif ()
elseif((${NAME}_DYNAMIC_LIB OR ${NAME}_SHARED_LIB) AND (("${LINKAGE}" STREQUAL "AUTO_LINKAGE" AND (NOT ${NAME}_STATIC_LIB OR (NOT STATIC_LINKAGE AND "${META_PROJECT_TYPE}" STREQUAL "application") OR (NOT STATIC_LIBRARY_LINKAGE AND ("${META_PROJECT_TYPE}" STREQUAL "" OR "${META_PROJECT_TYPE}" STREQUAL "library")))) OR ("${LINKAGE}" STREQUAL "SHARED")))
elseif ((${NAME}_DYNAMIC_LIB OR ${NAME}_SHARED_LIB)
AND (("${LINKAGE}" STREQUAL "AUTO_LINKAGE"
AND (NOT ${NAME}_STATIC_LIB
OR (NOT STATIC_LINKAGE AND "${META_PROJECT_TYPE}" STREQUAL "application")
OR (NOT STATIC_LIBRARY_LINKAGE
AND ("${META_PROJECT_TYPE}" STREQUAL "" OR "${META_PROJECT_TYPE}" STREQUAL "library"))))
OR ("${LINKAGE}" STREQUAL "SHARED")))
set(USE_${NAME} ON)
set(USE_SHARED_${NAME} ON)
if(NOT ${NAME}_DYNAMIC_LIB)
if (NOT ${NAME}_DYNAMIC_LIB)
set(${NAME}_DYNAMIC_LIB ${${NAME}_SHARED_LIB})
endif()
endif ()
list(APPEND STATIC_LIBRARIES ${${NAME}_DYNAMIC_LIB})
message(STATUS "Adding dynamic external library ${NAME} (${${NAME}_DYNAMIC_LIB}) to dependencies of static ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}.")
if(${NAME}_DYNAMIC_INCLUDE_DIR)
message(
STATUS
"Adding dynamic external library ${NAME} (${${NAME}_DYNAMIC_LIB}) to dependencies of static ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}."
)
if (${NAME}_DYNAMIC_INCLUDE_DIR)
list(APPEND ADDITIONAL_SHARED_INCLUDE_DIRS ${${NAME}_DYNAMIC_INCLUDE_DIR})
message(STATUS "Adding include path for ${NAME} to static ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}: ${${NAME}_DYNAMIC_INCLUDE_DIR}")
endif()
message(
STATUS
"Adding include path for ${NAME} to static ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}: ${${NAME}_DYNAMIC_INCLUDE_DIR}"
)
endif ()
if(${${NAME}_DYNAMIC_LIB} IN_LIST META_PUBLIC_SHARED_LIB_DEPENDS OR ${NAME} IN_LIST META_PUBLIC_SHARED_LIB_DEPENDS)
if (${${NAME}_DYNAMIC_LIB} IN_LIST META_PUBLIC_SHARED_LIB_DEPENDS OR ${NAME} IN_LIST META_PUBLIC_SHARED_LIB_DEPENDS)
list(APPEND ${PUBLIC_STATIC_LIBRARIES_VARNAME} ${${NAME}_DYNAMIC_LIB})
if(${NAME}_DYNAMIC_INCLUDE_DIR)
if (${NAME}_DYNAMIC_INCLUDE_DIR)
list(APPEND PUBLIC_STATIC_INCLUDE_DIRS ${${NAME}_DYNAMIC_INCLUDE_DIR})
endif()
else()
endif ()
else ()
list(APPEND ${PRIVATE_STATIC_LIBRARIES_VARNAME} ${${NAME}_DYNAMIC_LIB})
if(${NAME}_DYNAMIC_INCLUDE_DIR)
if (${NAME}_DYNAMIC_INCLUDE_DIR)
list(APPEND PRIVATE_STATIC_INCLUDE_DIRS ${${NAME}_DYNAMIC_INCLUDE_DIR})
endif()
endif()
else()
if(${NAME}_REQUIRED)
message(FATAL_ERROR "External library ${NAME} required by ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} is not available for the specified linkage ${LINKAGE}.")
else()
message(WARNING "External library ${NAME} required by ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} is not available for the specified linkage ${LINKAGE}.")
endif()
endif()
endmacro()
endif ()
endif ()
else ()
if (${NAME}_REQUIRED)
message(
FATAL_ERROR
"External library ${NAME} required by ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} is not available for the specified linkage ${LINKAGE}."
)
else ()
message(
WARNING
"External library ${NAME} required by ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} is not available for the specified linkage ${LINKAGE}."
)
endif ()
endif ()
endmacro ()
macro(link_against_library NAME LINKAGE REQUIRED)
link_against_library_varnames("${NAME}" "${LINKAGE}" "${REQUIRED}"
PRIVATE_LIBRARIES PUBLIC_LIBRARIES PRIVATE_STATIC_LIBRARIES PUBLIC_STATIC_LIBRARIES
)
endmacro()
macro (link_against_library NAME LINKAGE REQUIRED)
link_against_library_varnames("${NAME}"
"${LINKAGE}"
"${REQUIRED}"
PRIVATE_LIBRARIES
PUBLIC_LIBRARIES
PRIVATE_STATIC_LIBRARIES
PUBLIC_STATIC_LIBRARIES)
endmacro ()
macro(link_tests_against_library NAME LINKAGE REQUIRED)
link_against_library_varnames("${NAME}" "${LINKAGE}" "${REQUIRED}"
TEST_LIBRARIES TEST_LIBRARIES STATIC_TEST_LIBRARIES STATIC_TEST_LIBRARIES
)
endmacro()
macro (link_tests_against_library NAME LINKAGE REQUIRED)
link_against_library_varnames("${NAME}"
"${LINKAGE}"
"${REQUIRED}"
TEST_LIBRARIES
TEST_LIBRARIES
STATIC_TEST_LIBRARIES
STATIC_TEST_LIBRARIES)
endmacro ()
macro(find_external_library NAME LINKAGE REQUIRED)
macro (find_external_library NAME LINKAGE REQUIRED)
set(${NAME}_DYNAMIC_INCLUDE_DIR NOTFOUND CACHE PATH "${NAME} include dir (dynamic)")
set(${NAME}_DYNAMIC_LIB NOTFOUND CACHE FILEPATH "${NAME} lib (dynamic)")
set(${NAME}_STATIC_INCLUDE_DIR NOTFOUND CACHE PATH "${NAME} include dir (static)")
@ -197,83 +260,97 @@ macro(find_external_library NAME LINKAGE REQUIRED)
save_default_library_suffixes()
if(NOT ${NAME}_DYNAMIC_LIB)
if (NOT ${NAME}_DYNAMIC_LIB)
configure_dynamic_library_suffixes()
find_library(DETECTED_${NAME}_DYNAMIC_LIB ${NAME})
set(${NAME}_DYNAMIC_LIB ${DETECTED_${NAME}_DYNAMIC_LIB} CACHE FILEPATH "${NAME} lib (dynamic)" FORCE)
endif()
endif ()
if(NOT ${NAME}_STATIC_LIB)
if (NOT ${NAME}_STATIC_LIB)
configure_static_library_suffixes()
find_library(DETECTED_${NAME}_STATIC_LIB ${NAME})
set(${NAME}_STATIC_LIB ${DETECTED_${NAME}_STATIC_LIB} CACHE FILEPATH "${NAME} lib (static)" FORCE)
endif()
endif ()
restore_default_library_suffixes()
endmacro()
endmacro ()
macro(use_external_library NAME LINKAGE REQUIRED)
macro (use_external_library NAME LINKAGE REQUIRED)
find_external_library("${NAME}" "${LINKAGE}" "${REQUIRED}")
link_against_library("${NAME}" "${LINKAGE}" "${REQUIRED}")
endmacro()
endmacro ()
function(use_external_library_from_package_dynamic NAME PKGNAME INCLUDE_VAR LIBRARY_VAR COMPAT_VERSION)
function (use_external_library_from_package_dynamic NAME PKGNAME INCLUDE_VAR LIBRARY_VAR COMPAT_VERSION)
# internally used by find_external_library_from_package to find dynamic libraries
configure_dynamic_library_suffixes()
find_package(${PKGNAME} ${COMPAT_VERSION})
set(${NAME}_DYNAMIC_INCLUDE_DIR ${${INCLUDE_VAR}} CACHE PATH "${NAME} include dir (dynamic)" FORCE)
set(${NAME}_DYNAMIC_LIB ${${LIBRARY_VAR}} CACHE FILEPATH "${NAME} lib (dynamic)" FORCE)
endfunction()
endfunction ()
function(use_external_library_from_package_static NAME PKGNAME INCLUDE_VAR LIBRARY_VAR COMPAT_VERSION)
function (use_external_library_from_package_static NAME PKGNAME INCLUDE_VAR LIBRARY_VAR COMPAT_VERSION)
# internally used by find_external_library_from_package to find static libraries
configure_static_library_suffixes()
find_package(${PKGNAME} ${COMPAT_VERSION})
set(${NAME}_STATIC_INCLUDE_DIR ${${INCLUDE_VAR}} CACHE PATH "${NAME} include dir (static)" FORCE)
set(${NAME}_STATIC_LIB ${${LIBRARY_VAR}} CACHE FILEPATH "${NAME} lib (static)" FORCE)
endfunction()
endfunction ()
macro(find_external_library_from_package NAME PKGNAME VERSION INCLUDE_VAR LIBRARY_VAR LINKAGE REQUIRED)
macro (find_external_library_from_package NAME PKGNAME VERSION INCLUDE_VAR LIBRARY_VAR LINKAGE REQUIRED)
# handle specified VERSION
if("${VERSION}" STREQUAL "ANY_VERSION")
if ("${VERSION}" STREQUAL "ANY_VERSION")
set(${NAME}_COMPATIBLE_VERSION "")
else()
else ()
set(${NAME}_COMPATIBLE_VERSION ${VERSION})
endif()
endif ()
# use the find_library approach first because it is less buggy when trying to detect static libraries
# caveat: this way include dirs are not detected - however those are mostly the default anyways and
# can also be set manually by the user in case the auto-detection is not sufficient
# use the find_library approach first because it is less buggy when trying to detect static libraries caveat: this way
# include dirs are not detected - however those are mostly the default anyways and can also be set manually by the user
# in case the auto-detection is not sufficient
find_external_library("${NAME}" "${LINKAGE}" OPTIONAL)
# fall back to actual use of find_package
# use separate functions to get a new scope
# fall back to actual use of find_package use separate functions to get a new scope
save_default_library_suffixes()
if(NOT ${NAME}_DYNAMIC_LIB)
use_external_library_from_package_dynamic(${NAME} ${PKGNAME} ${INCLUDE_VAR} "${LIBRARY_VAR}" "${${NAME}_COMPATIBLE_VERSION}")
endif()
if(NOT ${NAME}_STATIC_LIB)
use_external_library_from_package_static(${NAME} ${PKGNAME} ${INCLUDE_VAR} "${LIBRARY_VAR}" "${${NAME}_COMPATIBLE_VERSION}")
endif()
if (NOT ${NAME}_DYNAMIC_LIB)
use_external_library_from_package_dynamic(${NAME}
${PKGNAME}
${INCLUDE_VAR}
"${LIBRARY_VAR}"
"${${NAME}_COMPATIBLE_VERSION}")
endif ()
if (NOT ${NAME}_STATIC_LIB)
use_external_library_from_package_static(${NAME}
${PKGNAME}
${INCLUDE_VAR}
"${LIBRARY_VAR}"
"${${NAME}_COMPATIBLE_VERSION}")
endif ()
restore_default_library_suffixes()
endmacro()
endmacro ()
macro(use_external_library_from_package NAME PKGNAME VERSION INCLUDE_VAR LIBRARY_VAR LINKAGE REQUIRED)
find_external_library_from_package("${NAME}" "${PKGNAME}" "${VERSION}" "${INCLUDE_VAR}" "${LIBRARY_VAR}" "${LINKAGE}" "${REQUIRED}")
macro (use_external_library_from_package NAME PKGNAME VERSION INCLUDE_VAR LIBRARY_VAR LINKAGE REQUIRED)
find_external_library_from_package("${NAME}"
"${PKGNAME}"
"${VERSION}"
"${INCLUDE_VAR}"
"${LIBRARY_VAR}"
"${LINKAGE}"
"${REQUIRED}")
link_against_library("${NAME}" "${LINKAGE}" "${REQUIRED}")
endmacro()
endmacro ()
macro(use_iconv LINKAGE REQUIRED)
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)
macro (use_iconv LINKAGE REQUIRED)
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
include(CheckFunctionExists)
check_function_exists(iconv HAS_ICONV)
endif()
if(NOT FORCE_EXTERNAL_ICONV AND HAS_ICONV)
endif ()
if (NOT FORCE_EXTERNAL_ICONV AND HAS_ICONV)
message(STATUS "Using iconv from the standard library for ${META_PROJECT_NAME}.")
else()
else ()
# find external iconv library
use_external_library(iconv ${LINKAGE} ${REQUIRED})
endif()
endmacro()
endif ()
endmacro ()

364
cmake/modules/AppTarget.cmake

@ -1,282 +1,264 @@
if(NOT BASIC_PROJECT_CONFIG_DONE)
if (NOT BASIC_PROJECT_CONFIG_DONE)
message(FATAL_ERROR "Before including the AppTarget module, the BasicConfig module must be included.")
endif()
if(TARGET_CONFIG_DONE)
endif ()
if (TARGET_CONFIG_DONE)
message(FATAL_ERROR "Can not include AppTarget module when targets are already configured.")
endif()
endif ()
# check whether project type is set correctly
if(NOT "${META_PROJECT_TYPE}" STREQUAL "application")
message(FATAL_ERROR "The AppTarget CMake module is intended to be used for building application projects only (and not for libraries).")
endif()
if (NOT "${META_PROJECT_TYPE}" STREQUAL "application")
message(
FATAL_ERROR
"The AppTarget CMake module is intended to be used for building application projects only (and not for libraries)."
)
endif ()
# set the windows extension to "exe", this is required by the Windows specific WindowsResources module
if(WIN32)
if (WIN32)
set(WINDOWS_EXT "exe")
endif(WIN32)
endif (WIN32)
# set compile definitions
if(NOT META_PUBLIC_SHARED_LIB_COMPILE_DEFINITIONS)
set(META_PUBLIC_SHARED_LIB_COMPILE_DEFINITIONS ${META_PUBLIC_COMPILE_DEFINITIONS} ${META_ADDITIONAL_PUBLIC_SHARED_COMPILE_DEFINITIONS})
endif()
if(NOT META_PRIVATE_SHARED_LIB_COMPILE_DEFINITIONS)
set(META_PRIVATE_SHARED_LIB_COMPILE_DEFINITIONS ${META_PRIVATE_COMPILE_DEFINITIONS} ${META_ADDITIONAL_PRIVATE_SHARED_COMPILE_DEFINITIONS})
if(STATIC_LINKAGE)
if (NOT META_PUBLIC_SHARED_LIB_COMPILE_DEFINITIONS)
set(META_PUBLIC_SHARED_LIB_COMPILE_DEFINITIONS ${META_PUBLIC_COMPILE_DEFINITIONS}
${META_ADDITIONAL_PUBLIC_SHARED_COMPILE_DEFINITIONS})
endif ()
if (NOT META_PRIVATE_SHARED_LIB_COMPILE_DEFINITIONS)
set(META_PRIVATE_SHARED_LIB_COMPILE_DEFINITIONS ${META_PRIVATE_COMPILE_DEFINITIONS}
${META_ADDITIONAL_PRIVATE_SHARED_COMPILE_DEFINITIONS})
if (STATIC_LINKAGE)
list(APPEND META_PRIVATE_SHARED_LIB_COMPILE_DEFINITIONS APP_STATICALLY_LINKED)
endif()
endif()
endif ()
endif ()
# set linker flags
if(STATIC_LINKAGE)
if (STATIC_LINKAGE)
set(ACTUAL_ADDITIONAL_LINK_FLAGS ${META_ADDITIONAL_STATIC_LINK_FLAGS})
else()
else ()
set(ACTUAL_ADDITIONAL_LINK_FLAGS ${META_ADDITIONAL_LINK_FLAGS})
endif()
endif ()
# define relevant files
set(ALL_FILES ${HEADER_FILES} ${SRC_FILES} ${GENERATED_DBUS_FILES} ${WIDGETS_FILES} ${QML_FILES} ${RES_FILES} ${WINDOWS_ICON_PATH})
if(NOT BUILTIN_TRANSLATIONS)
set(ALL_FILES
${HEADER_FILES}
${SRC_FILES}
${GENERATED_DBUS_FILES}
${WIDGETS_FILES}
${QML_FILES}
${RES_FILES}
${WINDOWS_ICON_PATH})
if (NOT BUILTIN_TRANSLATIONS)
list(APPEND ALL_FILES ${QM_FILES})
endif()
endif ()
# add target for building the application
if (NOT ANDROID)
add_executable(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} ${GUI_TYPE} ${ALL_FILES})
else()
else ()
# create a library which can be loaded from the Java-side
add_library(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} SHARED ${GUI_TYPE} ${ALL_FILES})
endif()
endif ()
target_link_libraries(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
PUBLIC ${ACTUAL_ADDITIONAL_LINK_FLAGS} "${PUBLIC_LIBRARIES}"
PRIVATE "${PRIVATE_LIBRARIES}"
)
PUBLIC ${ACTUAL_ADDITIONAL_LINK_FLAGS} "${PUBLIC_LIBRARIES}"
PRIVATE "${PRIVATE_LIBRARIES}")
target_include_directories(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${HEADER_INSTALL_DESTINATION}>
${PUBLIC_SHARED_INCLUDE_DIRS}
PRIVATE
"${PRIVATE_SHARED_INCLUDE_DIRS}"
)
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${HEADER_INSTALL_DESTINATION}> ${PUBLIC_SHARED_INCLUDE_DIRS}
PRIVATE "${PRIVATE_SHARED_INCLUDE_DIRS}")
target_compile_definitions(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
PUBLIC "${META_PUBLIC_SHARED_LIB_COMPILE_DEFINITIONS}"
PRIVATE "${META_PRIVATE_SHARED_LIB_COMPILE_DEFINITIONS}"
)
PUBLIC
"${META_PUBLIC_SHARED_LIB_COMPILE_DEFINITIONS}"
PRIVATE
"${META_PRIVATE_SHARED_LIB_COMPILE_DEFINITIONS}")
target_compile_options(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
PUBLIC "${META_PUBLIC_SHARED_LIB_COMPILE_OPTIONS}"
PRIVATE "${META_PRIVATE_SHARED_LIB_COMPILE_OPTIONS}"
)
set_target_properties(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} PROPERTIES
CXX_STANDARD "${META_CXX_STANDARD}"
LINK_SEARCH_START_STATIC ${STATIC_LINKAGE}
LINK_SEARCH_END_STATIC ${STATIC_LINKAGE}
AUTOGEN_TARGET_DEPENDS "${AUTOGEN_DEPS}"
)
PUBLIC "${META_PUBLIC_SHARED_LIB_COMPILE_OPTIONS}"
PRIVATE "${META_PRIVATE_SHARED_LIB_COMPILE_OPTIONS}")
set_target_properties(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
PROPERTIES CXX_STANDARD
"${META_CXX_STANDARD}"
LINK_SEARCH_START_STATIC
${STATIC_LINKAGE}
LINK_SEARCH_END_STATIC
${STATIC_LINKAGE}
AUTOGEN_TARGET_DEPENDS
"${AUTOGEN_DEPS}")
if(NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
if (NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
# add install target for binary
if(APPLE)
if (APPLE)
set(BUNDLE_INSTALL_DESTINATION bin CACHE STRING "specifies the install destination for bundles")
install(TARGETS ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
RUNTIME DESTINATION bin
BUNDLE DESTINATION "${BUNDLE_INSTALL_DESTINATION}"
COMPONENT binary
)
elseif(ANDROID)
install(
TARGETS ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
RUNTIME DESTINATION bin
COMPONENT binary
LIBRARY DESTINATION lib${SELECTED_LIB_SUFFIX}
COMPONENT binary
ARCHIVE DESTINATION lib${SELECTED_LIB_SUFFIX}
COMPONENT binary
)
else()
RUNTIME DESTINATION bin
BUNDLE DESTINATION "${BUNDLE_INSTALL_DESTINATION}" COMPONENT binary)
elseif (ANDROID)
install(TARGETS ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
RUNTIME DESTINATION bin
COMPONENT binary
)
endif()
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)
endif ()
if(NOT TARGET install-binary)
if (NOT TARGET install-binary)
add_custom_target(install-binary
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=binary -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
)
endif()
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 mingw-w64 specific install target
if(NOT TARGET install-mingw-w64)
if (NOT TARGET install-mingw-w64)
add_custom_target(install-mingw-w64)
add_dependencies(install-mingw-w64 install-binary)
endif()
endif ()
add_dependencies(install-mingw-w64 ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX})
# add install target for desktop entries and icons
foreach(DESKTOP_FILE ${DESKTOP_FILES})
install(
FILES "${DESKTOP_FILE}"
DESTINATION "share/applications"
COMPONENT desktop
)
endforeach()
foreach (DESKTOP_FILE ${DESKTOP_FILES})
install(FILES "${DESKTOP_FILE}" DESTINATION "share/applications" COMPONENT desktop)
endforeach ()
foreach(ICON_FILE ${ICON_FILES})
install(
FILES "${ICON_FILE}"
DESTINATION "share/icons/hicolor/scalable/apps"
COMPONENT desktop
)
endforeach()
if(NOT TARGET install-desktop)
foreach (ICON_FILE ${ICON_FILES})
install(FILES "${ICON_FILE}" DESTINATION "share/icons/hicolor/scalable/apps" COMPONENT desktop)
endforeach ()
if (NOT TARGET install-desktop)
add_custom_target(install-desktop
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=desktop -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
)
endif()
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})
if(NOT TARGET install-appimage)
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()
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 install target for stripped binaries
if(NOT TARGET install-binary-strip)
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 "${CMAKE_BINARY_DIR}/cmake_install.cmake"
)
endif()
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 mingw-w64 specific install targets
if(MINGW)
if(NOT TARGET install-mingw-w64)
if (MINGW)
if (NOT TARGET install-mingw-w64)
add_custom_target(install-mingw-w64)
add_dependencies(install-mingw-w64 install-binary)
endif()
if(NOT TARGET install-mingw-w64-strip)
endif ()
if (NOT TARGET install-mingw-w64-strip)
add_custom_target(install-mingw-w64-strip)
add_dependencies(install-mingw-w64-strip install-binary-strip)
endif()
if(LOCALIZATION_TARGET)
endif ()
if (LOCALIZATION_TARGET)
add_dependencies(install-mingw-w64 ${LOCALIZATION_TARGET})
add_dependencies(install-mingw-w64-strip ${LOCALIZATION_TARGET})
endif()
endif()
endif()
endif ()
endif ()
endif ()
# add target for launching application with wine ensuring the WINEPATH is set correctly so wine is able to find all required *.dll files
# requires script from c++utilities, hence the sources of c++utilities must be present
if(MINGW AND CMAKE_CROSSCOMPILING AND CPP_UTILITIES_SOURCE_DIR)
if(NOT TARGET ${META_PROJECT_NAME}_run)
if(CMAKE_FIND_ROOT_PATH)
# add target for launching application with wine ensuring the WINEPATH is set correctly so wine is able to find all required
# *.dll files requires script from c++utilities, hence the sources of c++utilities must be present
if (MINGW AND CMAKE_CROSSCOMPILING AND CPP_UTILITIES_SOURCE_DIR)
if (NOT TARGET ${META_PROJECT_NAME}_run)
if (CMAKE_FIND_ROOT_PATH)
list(APPEND RUNTIME_LIBRARY_PATH "${CMAKE_FIND_ROOT_PATH}/bin")
endif()
add_custom_target(${META_PROJECT_NAME}_run COMMAND "${CPP_UTILITIES_SOURCE_DIR}/scripts/wine.sh" "${CMAKE_CURRENT_BINARY_DIR}/${META_PROJECT_NAME}.${WINDOWS_EXT}" ${RUNTIME_LIBRARY_PATH})
endif ()
add_custom_target(${META_PROJECT_NAME}_run
COMMAND "${CPP_UTILITIES_SOURCE_DIR}/scripts/wine.sh"
"${CMAKE_CURRENT_BINARY_DIR}/${META_PROJECT_NAME}.${WINDOWS_EXT}" ${RUNTIME_LIBRARY_PATH})
add_dependencies(${META_PROJECT_NAME}_run ${META_PROJECT_NAME})
endif()
endif()
endif ()
endif ()
# find template for *.desktop files
include(TemplateFinder)
find_template_file("desktop" CPP_UTILITIES APP_DESKTOP_TEMPLATE_FILE)
find_template_file("appdata.xml" CPP_UTILITIES APP_APPSTREAM_TEMPLATE_FILE)
# function to add *.desktop files with additional entries
# FIXME v5: use "include(CMakeParseArguments)" like in ReflectionGenerator.cmake
function(add_custom_desktop_file_with_additional_entries
FILE_NAME
DESKTOP_FILE_APP_NAME
DESKTOP_FILE_GENERIC_NAME
DESKTOP_FILE_DESCRIPTION
DESKTOP_FILE_CATEGORIES
DESKTOP_FILE_CMD
DESKTOP_FILE_ICON
DESKTOP_FILE_ADDITIONAL_ENTRIES)
# function to add *.desktop files with additional entries FIXME v5: use "include(CMakeParseArguments)" like in
# ReflectionGenerator.cmake
function (add_custom_desktop_file_with_additional_entries
FILE_NAME
DESKTOP_FILE_APP_NAME
DESKTOP_FILE_GENERIC_NAME
DESKTOP_FILE_DESCRIPTION
DESKTOP_FILE_CATEGORIES
DESKTOP_FILE_CMD
DESKTOP_FILE_ICON
DESKTOP_FILE_ADDITIONAL_ENTRIES)
# create desktop file from template
configure_file(
"${APP_DESKTOP_TEMPLATE_FILE}"
"${CMAKE_CURRENT_BINARY_DIR}/resources/${FILE_NAME}.desktop"
)
configure_file("${APP_DESKTOP_TEMPLATE_FILE}" "${CMAKE_CURRENT_BINARY_DIR}/resources/${FILE_NAME}.desktop")
# add install for the desktop file
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/resources/${FILE_NAME}.desktop"
DESTINATION "share/applications