Use ECMInstalledLibraryCheck
Needs extra-cmake-modules!590 (merged) (see also now published online docs or related blog port)
For a better idea of what the added function calls calls provide in their effort to simulate the consumer view on the installed development artifacts, see below the content of the generated CMakeLists.txt file (in build subdir src/KF6TextEditor_ECMInstalledLibraryCheck), which also injects some checks for certain variables and macros.
The check is invoked by the build target all_installed_library_check (to be done post-installation only), the evaluation currently is as primitive as requiring the build to pass, any issues found have to be taken from the build log.
# This file was generated by ecm_add_installed_library_check(). DO NOT EDIT!
cmake_minimum_required(VERSION 3.29)
project(InstalledLibraryCheck LANGUAGES C CXX)
find_package(KF6TextEditor 6.30.0 EXACT CONFIG REQUIRED NO_DEFAULT_PATH
PATHS "/path/where/you/install/to"
)
include(FeatureSummary)
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
add_library(InstalledLibraryCheck MODULE)
target_link_libraries(InstalledLibraryCheck
KF6::TextEditor
)
set(_include_strings
KTextEditor/AbstractAnnotationItemDelegate
KTextEditor/AnnotationInterface
KTextEditor/Application
KTextEditor/Attribute
KTextEditor/CodeCompletionModel
KTextEditor/CodeCompletionModelControllerInterface
KTextEditor/Command
KTextEditor/ConfigPage
KTextEditor/Cursor
KTextEditor/Document
KTextEditor/DocumentCursor
KTextEditor/Editor
KTextEditor/InlineNote
KTextEditor/InlineNoteProvider
KTextEditor/LineRange
KTextEditor/MainWindow
KTextEditor/Message
KTextEditor/MovingCursor
KTextEditor/MovingRange
KTextEditor/MovingRangeFeedback
KTextEditor/Plugin
KTextEditor/Range
KTextEditor/SessionConfigInterface
KTextEditor/TextHintInterface
KTextEditor/View
)
set(_preprocessor_macro_check_statements
"#define _ECM_INSTALLED_LIBRARY_CHECK_VALUE_TO_STRING(x) #x
#define _ECM_INSTALLED_LIBRARY_CHECK_VALUE(x) _ECM_INSTALLED_LIBRARY_CHECK_VALUE_TO_STRING(x)
#if !defined(KTEXTEDITOR_VERSION)
#error(\"KTEXTEDITOR_VERSION: not defined\")
#else
#if KTEXTEDITOR_VERSION != 0x61e00
#pragma message(\"KTEXTEDITOR_VERSION: is '\" _ECM_INSTALLED_LIBRARY_CHECK_VALUE(KTEXTEDITOR_VERSION) \"'\")
#error(\"KTEXTEDITOR_VERSION: expecting '0x61e00'\")
#endif
#endif
#if !defined(KTEXTEDITOR_VERSION_MAJOR)
#error(\"KTEXTEDITOR_VERSION_MAJOR: not defined\")
#else
#if KTEXTEDITOR_VERSION_MAJOR != 6
#pragma message(\"KTEXTEDITOR_VERSION_MAJOR: is '\" _ECM_INSTALLED_LIBRARY_CHECK_VALUE(KTEXTEDITOR_VERSION_MAJOR) \"'\")
#error(\"KTEXTEDITOR_VERSION_MAJOR: expecting '6'\")
#endif
#endif
#if !defined(KTEXTEDITOR_VERSION_MINOR)
#error(\"KTEXTEDITOR_VERSION_MINOR: not defined\")
#else
#if KTEXTEDITOR_VERSION_MINOR != 30
#pragma message(\"KTEXTEDITOR_VERSION_MINOR: is '\" _ECM_INSTALLED_LIBRARY_CHECK_VALUE(KTEXTEDITOR_VERSION_MINOR) \"'\")
#error(\"KTEXTEDITOR_VERSION_MINOR: expecting '30'\")
#endif
#endif
#if !defined(KTEXTEDITOR_VERSION_PATCH)
#error(\"KTEXTEDITOR_VERSION_PATCH: not defined\")
#else
#if KTEXTEDITOR_VERSION_PATCH != 0
#pragma message(\"KTEXTEDITOR_VERSION_PATCH: is '\" _ECM_INSTALLED_LIBRARY_CHECK_VALUE(KTEXTEDITOR_VERSION_PATCH) \"'\")
#error(\"KTEXTEDITOR_VERSION_PATCH: expecting '0'\")
#endif
#endif
")
foreach(_include_string IN LISTS _include_strings)
string(REPLACE "/" "__" _escaped_include_string ${_include_string})
set(_source_file "${CMAKE_CURRENT_BINARY_DIR}/${_escaped_include_string}.cpp")
file(GENERATE OUTPUT ${_source_file} CONTENT "#include <${_include_string}>\n${_preprocessor_macro_check_statements}")
target_sources(InstalledLibraryCheck PRIVATE ${_source_file})
endforeach()Edited by Friedrich W. H. Kossebau