Warning, /libraries/perceptualcolor/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 # SPDX-FileCopyrightText: Lukas Sommer <sommerluk@gmail.com>
0002 # SPDX-License-Identifier: BSD-2-Clause OR MIT
0003 
0004 
0005 
0006 
0007 
0008 ################# General setup #################
0009 # Contrary to the name, “cmake_minimum_required()” does not (only) set a
0010 # minimal required CMake version, but a compatibility mode: If the library
0011 # user or the packages has a newer CMake version than indicated, than it will
0012 # run in a compatibility mode that makes sure we get the exact same result
0013 # as if actually CMake in the indicated version would have been invoked.
0014 #
0015 # Qt 6.0 requires at least CMake version 3.16.
0016 # https://doc.qt.io/archives/qt-6.0/cmake-get-started.html
0017 # Qt 6.2 LTS requires at least CMake version 3.16 for the Qt shared library
0018 # and CMake version 3.21.1 for Qt static library.
0019 # https://doc.qt.io/archives/qt-6.2/cmake-get-started.html
0020 cmake_minimum_required(VERSION 3.22.0)
0021 message(STATUS "CMAKE_VERSION: ${CMAKE_VERSION}")
0022 
0023 # Project setup. We need only a C++ (CXX) compiler, and no C compiler.
0024 # Therefore, we set LANGUAGES explicitly.
0025 project(
0026     perceptualcolor
0027     DESCRIPTION "Perceptual color components"
0028     LANGUAGES CXX
0029 )
0030 message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
0031 message(STATUS "CMAKE_SYSTEM_VERSION: ${CMAKE_SYSTEM_VERSION}")
0032 message(STATUS "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")
0033 message(STATUS "CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}")
0034 message(STATUS "CMAKE_CXX_COMPILER_VERSION: ${CMAKE_CXX_COMPILER_VERSION}")
0035 
0036 # Find includes in corresponding build directories
0037 set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
0038 
0039 # Get predefined directories for installation process
0040 # Don’t worry, this is no lock-in into GNU, it simply provides
0041 # better default directories on Linux, and also works fine on
0042 # non-Linux systems.
0043 include(GNUInstallDirs)
0044 
0045 message(CHECK_START "Checking for iwyu (include-what-you-use)")
0046 find_program(
0047     iwyu_path
0048     NAMES "iwyu" "include-what-you-use")
0049 if(iwyu_path)
0050     message(
0051         CHECK_PASS
0052         "Found.\n"
0053             "   Run cmake again with "
0054             "“-DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=${iwyu_path}” to use it.")
0055     # TODO This does not check headers that have neither a cpp
0056     #      file with the same name nor a cpp file declaring the header
0057     #      with “// IWYU pragma: associated”. It should check them however.
0058     #      At the time of writing this comment, this are: importexport.h,
0059     #      constpropagatinguniquepointer.h, and constpropagatingrawpointer.h.
0060     #      Maybe declare them by pragma within their unit tests?
0061 else()
0062     message(CHECK_FAIL "Not found.")
0063 endif()
0064 message(
0065     STATUS
0066     "CMAKE_CXX_INCLUDE_WHAT_YOU_USE: ${CMAKE_CXX_INCLUDE_WHAT_YOU_USE}")
0067 
0068 message(CHECK_START "Checking for clang-tidy")
0069 find_program(
0070     clang_tidy_path
0071     NAMES
0072         "clang-tidy")
0073 if(clang_tidy_path)
0074     message(
0075         CHECK_PASS
0076         "Found.\n"
0077             "   Run cmake again with "
0078             "“-DCMAKE_CXX_CLANG_TIDY=${clang_tidy_path}” to use it.")
0079 else()
0080     message(CHECK_FAIL "Not found.")
0081 endif()
0082 message(
0083     STATUS
0084     "CMAKE_CXX_CLANG_TIDY: ${CMAKE_CXX_CLANG_TIDY}")
0085 
0086 message(CHECK_START "Checking for cppcheck")
0087 find_program(
0088     cppcheck_path
0089     NAMES
0090         "cppcheck")
0091 if(cppcheck_path)
0092     message(
0093         CHECK_PASS
0094         "Found.\n"
0095             "   Run cmake again with "
0096             "“-DCMAKE_CXX_CPPCHECK=${cppcheck_path}” to use it.")
0097 else()
0098     message(CHECK_FAIL "Not found.")
0099 endif()
0100 message(
0101     STATUS
0102     "CMAKE_CXX_CPPCHECK: ${CMAKE_CXX_CPPCHECK}")
0103 
0104 # We set a default build type when the user did not specify a build type.
0105 # Reason: An empty build type does not provide any compiler flags at all,
0106 # thus no optimization at all, for example.
0107 if(NOT CMAKE_BUILD_TYPE)
0108     set(CMAKE_BUILD_TYPE "Release")
0109 endif()
0110 message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
0111 
0112 if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
0113     set(ON_CLANG_DERIVATE true)
0114 else()
0115     set(ON_CLANG_DERIVATE false)
0116 endif()
0117 
0118 
0119 
0120 
0121 
0122 ################# Version number #################
0123 # Provide project version
0124 # We are following “Semantic Versioning 2.0.0”.
0125 # See https://semver.org/ for details.
0126 set(MAJOR_VERSION "0")
0127 set(MINOR_VERSION "0")
0128 set(PATCH_VERSION "1")
0129 set(FULL_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}")
0130 
0131 
0132 
0133 
0134 
0135 ################# C++ standard #################
0136 # Our choice for the required C++ standard is documented via Doxygen (main
0137 # page of the documentation).
0138 set(CMAKE_CXX_STANDARD 17)
0139 set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
0140 set(CMAKE_CXX_EXTENSIONS FALSE) # Try to disable compiler-specific extensions.
0141 
0142 
0143 
0144 
0145 
0146 ################# Inter-procedural optimization #################
0147 include(CheckIPOSupported)
0148 message(
0149     CHECK_START
0150     "Checking for IPO/LTO "
0151         "(inter-procedural optimization/link-time optimization)")
0152 check_ipo_supported(
0153     RESULT has_ipo_support
0154     OUTPUT output) # The variable “output” can be ignored.
0155 if(has_ipo_support)
0156     message(CHECK_PASS "Found.")
0157 else()
0158     message(CHECK_FAIL "Not found.")
0159 endif()
0160 message(
0161     STATUS
0162     "CMAKE_INTERPROCEDURAL_OPTIMIZATION: ${CMAKE_INTERPROCEDURAL_OPTIMIZATION}")
0163 
0164 
0165 
0166 
0167 
0168 ################# Ordinary optimization #################
0169 # About optimization: We leave the decision on the optimization level
0170 # up to CMake, which provides cross-platform support.
0171 #
0172 # Anyway, here some thoughts about optimization on GCC:
0173 # GCC has quite a few optimization options like “O0” (no optimization)
0174 # or “Os” (optimize for minimal binary size with the trade-off of slower
0175 # binaries). “O2” seems to be quit the default. “O3”  optimizes further
0176 # for speed, with the trade-off having a bigger binary file.
0177 # Our image rendering is slow, so more optimization is better.  Probably
0178 # “Ofast” is not an option, as it might make problems with multithreading.
0179 # Probably ffast-mat though is not a good idea either because of its risks:
0180 # This option breaks strict IEEE compatibility of floating point to provide
0181 # a faster run-time; for example, division by 0 results in a wrong return
0182 # value instead of an exception.
0183 #
0184 # TODO Profile-guided optimization (PGO) provides by GCC can further
0185 # increase speed and shriek binary size, but requires a more complex
0186 # build system. It would be nice to have this if it does not make the build
0187 # process too complicate. For details, see also:
0188 # https://documentation.suse.com/sbp/all/pdf/SBP-GCC-10_color_en.pdf
0189 
0190 
0191 
0192 
0193 
0194 ################# Preprocessor macro definitions #################
0195 # Preprocessor macro definitions that configure Qt to be more
0196 # strict or more compatible.
0197 #
0198 # Some Qt API functions provide implicit casts. By defining the QT_NO_CAST_…
0199 # preprocessor macros, the code of our library is forced to use explicit
0200 # casts instead; this will helps to reveal bugs in our library.
0201 #
0202 # Some other preprocessor macro definitions disable potentially error-prone
0203 # Qt features. Or they make Qt more compatible, like QT_NO_KEYWORDS.
0204 add_compile_definitions(
0205     # Unlike target_compile_definitions(), which distinguishes
0206     # between PRIVATE, INTERFACE and PUBLIC definitions,
0207     # with add_compile_definitions() all definitions are always PRIVATE.
0208     QT_NO_CAST_FROM_ASCII
0209     QT_NO_CAST_FROM_BYTEARRAY
0210     QT_NO_CAST_TO_ASCII
0211     QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
0212     QT_NO_PROCESS_COMBINED_ARGUMENT_START
0213     QT_NO_URL_CAST_FROM_STRING
0214     QT_USE_QSTRINGBUILDER
0215     QT_NO_KEYWORDS
0216     QT_NO_FOREACH
0217     # DQT_DISABLE_DEPRECATED_BEFORE disables all deprecated features.
0218     # While normal deprecation warnings are NOT issued for ALL deprecated
0219     # features, THIS flag actually seems to block actually all deprecated
0220     # features:
0221     QT_DISABLE_DEPRECATED_BEFORE=0x060000
0222     # This might crash on older Qt versions on Windows,
0223     # see https://bugreports.qt.io/browse/AUTOSUITE-946.
0224     # But we do not support older Qt versions anyway:
0225     QT_STRICT_ITERATORS
0226 )
0227 
0228 
0229 
0230 
0231 
0232 ################# Symbol stripping #################
0233 # NOTE The Clang/GCC option “-s” will “Remove all symbol table
0234 # and relocation information from the executable.” This reduces
0235 # the size of the binary and the loading time. According to
0236 # https://www.technovelty.org/linux/stripping-shared-libraries.html
0237 # shared libraries do not need the symbols, so they can safely be
0238 # removed. But we have to set the option manually; there is no
0239 # build-in CMake support that helps us do this in a portable way.
0240 # Therefore, we leave it up to the packagers to strip the symbols
0241 # finally with “strip --strip-unneeded libraryname”.
0242 
0243 
0244 
0245 
0246 
0247 ################# Warnings #################
0248 # Available compiler flags for warnings might change incompatibly from
0249 # version to version, which could let the build fail. Also, newer compiler
0250 # versions might throw more warnings, which could break the build if
0251 # warnings are treated as errors by “-Werror”. Therefore, by default
0252 # we try to not use any hard-coded compiler flags. This gives us
0253 # maximum compatibility for release builds. But a higher warning level
0254 # can be requested by the user:
0255 message(
0256     STATUS
0257     "By calling CMake with the option “-DADDITIONAL_WARNINGS=ON”\n"
0258     "   (indeed ON, not TRUE!) you can:\n"
0259     "   Get more warnings, which is only useful for the developers\n"
0260     "   of this library. It might not be portable and even break the build\n"
0261     "   process, so it should never be used in production builds.")
0262 option(
0263     ADDITIONAL_WARNINGS               # Name
0264     "More warnings and errors"        # Help text
0265     FALSE)                            # Default value
0266 # TODO Starting with CMake 3.19, this option could be replaced with
0267 # a CMake preset, which might be more convenient? Anyway, currently we
0268 # require only CMake 3.16 just as Qt 6 does…
0269 message(
0270     STATUS
0271     "ADDITIONAL_WARNINGS: ${ADDITIONAL_WARNINGS}")
0272 if(ADDITIONAL_WARNINGS
0273     AND
0274     ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR ON_CLANG_DERIVATE)
0275 )
0276     add_compile_options(
0277         # Issue all the warnings demanded by strict ISO C++:
0278         -Wpedantic
0279         # Contrary to the name, "-Wall" does not activate all warnings,
0280         # but only the most important ones:
0281         -Wall
0282         # -Wextra enables some extra warning flags
0283         # that are not enabled by -Wall:
0284         -Wextra
0285         # Additional individual warning flags (in alphabetical order):
0286         -Wcast-align
0287         -Wcast-qual
0288         -Wchar-subscripts
0289         -Wcomment
0290         -Wconversion
0291         -Wdeprecated
0292         -Wdisabled-optimization
0293         # -Wfloat-equal # TODO Enable this check!
0294         -Wformat
0295         -Wformat=2 # even more checks on top of “-Wformat”
0296         -Wformat-nonliteral
0297         -Wformat-security
0298         -Wformat-y2k
0299         -Wimport
0300         -Winit-self
0301         -Winvalid-pch
0302         -Wlong-long
0303         -Wmissing-braces
0304         -Wmissing-field-initializers
0305         -Wmissing-format-attribute
0306         -Wmissing-include-dirs
0307         -Wmissing-noreturn
0308         -Wpacked
0309         -Wparentheses
0310         -Wpointer-arith
0311         -Wredundant-decls
0312         -Wreturn-type
0313         -Wsequence-point
0314         -Wshadow
0315         -Wsign-compare
0316         -Wsign-conversion
0317         -Wstack-protector
0318         -Wstrict-aliasing
0319         # It is possible to set “-Wstrict-aliasing=n”, but only after setting
0320         # “-Wstrict-aliasing” without n before! n is the level:
0321         #           ╭────────────────┬────────────────╮
0322         #           │ False positive │ False negative │
0323         # ╭─────────┼────────────────┼────────────────┤
0324         # │ Level 1 │      many      │    very few    │
0325         # ├─────────┼────────────────┼────────────────┤
0326         # │ Level 2 │   still many   │       few      │
0327         # ├─────────┼────────────────┼────────────────┤
0328         # │ Level 3 │    very few    │       few      │
0329         # ╰─────────┴────────────────┴────────────────╯
0330         -Wstrict-aliasing=1
0331         -Wswitch-enum
0332         -Wtrigraphs
0333         -Wuninitialized
0334         -Wunknown-pragmas
0335         -Wunreachable-code
0336         -Wunused
0337         -Wunused-function
0338         -Wunused-label
0339         -Wunused-parameter
0340         -Wunused-value
0341         -Wunused-variable
0342         -Wvariadic-macros
0343         -Wvla
0344         -Wvolatile-register-var
0345         -Wwrite-strings
0346         -Wzero-as-null-pointer-constant
0347     )
0348 endif()
0349 if(ADDITIONAL_WARNINGS AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU"))
0350     add_compile_options(
0351         -Wunsafe-loop-optimizations
0352     )
0353 endif()
0354 if(ADDITIONAL_WARNINGS AND ON_CLANG_DERIVATE)
0355     # Add additional flags for Clang:
0356     add_compile_options(
0357         # More warnings:
0358         -Wctad-maybe-unsupported
0359         -Winline
0360         -Wunreachable-code
0361         # Enable really all available warnings, even wired ones:
0362         -Weverything
0363         # Disable some of the warnings enabled by "-Everything"
0364         # that generate false positives…
0365         # We do know want to be compatible with C++98:
0366         -Wno-c++98-compat
0367         # We allow redundant parentheses because sometimes they
0368         # make code more readable:
0369         -Wno-redundant-parens
0370         -Wno-padded
0371         # We disable -Wextra-semi-stmt because moc-generated code
0372         # has indeed quite a few extra semicolon statements, and
0373         # we cannot change how the moc generated its code.
0374         -Wno-extra-semi-stmt
0375         # Necessary to prevent compile error when using clazy:
0376         -Wno-documentation-unknown-command
0377         # We use default sections in switch statements for reasonable
0378         # fallback code when an enum value is not handled:
0379         -Wno-covered-switch-default
0380         # We disable -Wfloat-equal because we make this kind of comparisons
0381         # in property setter functions to check if actually the property value
0382         # has to be changed or not, and this seems a reasonable use case.
0383         -Wno-float-equal
0384         # NOTE -Wnoexit-time-destructors and -Wnoglobal-constructors
0385         # are only necessary to suppress -Weverything generated
0386         # warnings on the C++ files that are produced by Qt’s
0387         # resource compiler. See also:
0388         # https://stackoverflow.com/questions/14335494
0389         # https://stackoverflow.com/questions/15708411
0390         -Wno-exit-time-destructors
0391         -Wno-global-constructors
0392         -Wno-aggregate-return
0393         # Suppress warnings for reserved identifiers, because Qt’s MOC
0394         # produces code that uses a lot of reserved identifiers and we
0395         # would get plenty of warnings for this.
0396         -Wno-reserved-identifier
0397     )
0398 endif()
0399 if(ADDITIONAL_WARNINGS AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC"))
0400     # NOTE Documentation of warning for MSVC:
0401     # docs.microsoft.com/cpp/build/reference/compiler-option-warning-level
0402     add_compile_options(
0403         # List of additional warnings for MSVC
0404 
0405         # NOTE We do not use /Wall because it pulls in also extremly confusing
0406         # messages with little practical value.
0407 
0408         # warning C4711: function selected for automatic inline expansion
0409         # MSVC issues this warning for its own std header files when /Wall is
0410         # active. /wd4711 will suppress it.
0411         /wd4711
0412     )
0413 endif()
0414 
0415 
0416 
0417 
0418 
0419 ################# General compiler options #################
0420 
0421 # Character set configuration:
0422 #
0423 # There are three character sets involved: the input character set, the
0424 # narrow execution character set, and the wide execution character set. The
0425 # wide execution character set is not utilized in this project. However, it
0426 # is essential to ensure that both the input character set and the narrow
0427 # execution character set are always set to UTF-8.
0428 #
0429 # For GCC and Clang, the input character set is set using
0430 # "-finput-charset=UTF-8". By default, with the CMake settings we have, both
0431 # the input character set and the narrow execution character set are already
0432 # set to UTF-8, so no additional configuration is required in this case.
0433 #
0434 # On MSVC, the situation is different. Although the input character set is
0435 # is expected to be recognized as UTF-8 when each source file starts with a
0436 # Byte Order Mark (BOM) — which is indeed the case in our code base — the
0437 # narrow execution character set may still default to an obscure
0438 # Windows code page. To ensure consistent behavior, we explicitly set
0439 # both the input and narrow execution character sets to UTF-8
0440 # using "/utf-8" flag in our MSVC configuration.
0441 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
0442     add_compile_options(/utf-8)
0443 endif()
0444 
0445 # Given that the "register" keyword has been deprecated in C++ since C++17,
0446 # the compiler may generate a warning when encountering its usage. It’s worth
0447 # noting that the LittleCMS header "lcms2.h," which we rely on, is a C header
0448 # and not specifically designed for C++. In this header, the "register" keyword
0449 # is extensively used. Since modifying the external header is not possible, we
0450 # opt to disable the warning.
0451 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
0452     add_compile_options(/wd5033)
0453 endif()
0454 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR ON_CLANG_DERIVATE)
0455     add_compile_options(-Wno-register)
0456 endif()
0457 
0458 
0459 
0460 
0461 
0462 ################# Setup external library dependencies #################
0463 # Use also our local FIND modules
0464 list(APPEND CMAKE_MODULE_PATH
0465     "${CMAKE_SOURCE_DIR}/cmake/Modules/")
0466 find_package( # Necessary for find_package(LCMS2)
0467     PkgConfig
0468     REQUIRED)
0469 find_package(
0470     LCMS2
0471     REQUIRED)
0472 find_package(
0473     ECM 5.82 # Version 5.82 required for QtVersionOption
0474     REQUIRED
0475     NO_MODULE)
0476 list(APPEND CMAKE_MODULE_PATH
0477     ${ECM_MODULE_PATH})
0478 include(QtVersionOption) # Provides ${QT_MAJOR_VERSION}
0479 # CheckAtomic: “Sometimes linking against libatomic is required for atomic ops,
0480 #               if the platform doesn’t support lock-free atomics.”
0481 #              “Check if the compiler supports std:atomic out of the box or if
0482 #               libatomic is needed for atomic support. If it is needed
0483 #               libatomicis added to ``CMAKE_REQUIRED_LIBRARIES``.”
0484 include(CheckAtomic)
0485 message(
0486     STATUS
0487     "Building against Qt${QT_MAJOR_VERSION}.\n"
0488     "   You can control this with “-DBUILD_WITH_QT6=ON” (build with Qt6)\n"
0489     "   or “-DBUILD_WITH_QT6=OFF” (build with Qt5).")
0490 find_package(
0491     Qt${QT_MAJOR_VERSION}
0492     # WARNING Keep in sync between src/Config.cmake.in and CMakeLists.txt!
0493     COMPONENTS Core Gui Widgets DBus Test Concurrent Svg
0494     REQUIRED)
0495 message(STATUS
0496         "Using Qt version: "
0497         "${Qt${QT_MAJOR_VERSION}_VERSION_MAJOR}."
0498         "${Qt${QT_MAJOR_VERSION}_VERSION_MINOR}."
0499         "${Qt${QT_MAJOR_VERSION}_VERSION_PATCH}")
0500 # Instruct CMake to run moc automatically when needed.
0501 set(CMAKE_AUTOMOC TRUE)
0502 # Instruct CMake to create code from Qt designer ui files
0503 set(CMAKE_AUTOUIC TRUE)
0504 
0505 
0506 
0507 
0508 
0509 ################# Build STATIC or SHARED library #################
0510 # Either a STATIC or a SHARED library is build, simply depending
0511 # on BUILD_SHARED_LIBS.
0512 #
0513 # A more sophisticated handling of STATIC vs. SHARED is possible,
0514 # but complex, and will therefore not be used here:
0515 #alexreinking.com/blog/building-a-dual-shared-and-static-library-with-cmake.html
0516 option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
0517 message(
0518     STATUS
0519     "BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}.\n"
0520     "   You can control this with “-DBUILD_SHARED_LIBS=ON” (dynamic library)\n"
0521     "   or “-DBUILD_SHARED_LIBS=OFF” (static library).")
0522 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" AND BUILD_SHARED_LIBS)
0523     set(MSVC_DLL TRUE)
0524 else()
0525     set(MSVC_DLL FALSE)
0526 endif()
0527 message(STATUS "MSVC_DLL: ${MSVC_DLL}")
0528 
0529 
0530 
0531 
0532 
0533 ################# More targets? #################
0534 # TODO https://gitlab.com/ubports/core/cmake-extras/ provides (among others)
0535 # – DoxygenBuilder: Creates Doxygen API doc generation targets. But:
0536 #   We have to make sure that the screenshots are always up-to-date. And:
0537 #   Doxygen has currently many false-positive warnings, which we are
0538 #   filtering in run-ci.sh. Is this possible in CMake, so that it can
0539 #   be used as a tool to make sure the documentation is correct?
0540 #   Or we could do like described in
0541 #   https://majewsky.wordpress.com/2010/08/14/tip-of-the-day-cmake-and-doxygen/
0542 #   and create a custom target manually…
0543 
0544 
0545 
0546 
0547 
0548 ################# Define targets #################
0549 # When calling simply “make”, the default target is build. The default
0550 # target is “all”. EXCLUDE_FROM_ALL can used when adding targets; it means
0551 # that this new target will exceptionally not be added to the “all” target.
0552 
0553 
0554 
0555 
0556 
0557 ################# Subdirectories #################
0558 set(CLANG_FORMAT_PATTERNS)
0559 
0560 add_subdirectory(src)
0561 list(APPEND CLANG_FORMAT_PATTERNS
0562     src/*.h # The .in.hpp file is intentionally missing in this pattern.
0563     src/*.cpp)
0564 
0565 # Use unit tests only when building this project itself, and
0566 # not when it is included within another project:
0567 if("${CMAKE_PROJECT_NAME}" STREQUAL "${PROJECT_NAME}")
0568     include(CTest)
0569     if(BUILD_TESTING)
0570         add_subdirectory(autotests)
0571     endif()
0572 endif()
0573 list(APPEND CLANG_FORMAT_PATTERNS
0574     autotests/*.h
0575     autotests/*.cpp)
0576 
0577 add_subdirectory(tests)
0578 list(APPEND CLANG_FORMAT_PATTERNS
0579     tests/*.h
0580     tests/*.cpp)
0581 
0582 add_subdirectory(utils)
0583 list(APPEND CLANG_FORMAT_PATTERNS
0584     utils/*.h
0585     utils/*.cpp)
0586 
0587 # Intentionally not using add_subdirectory(examples) because
0588 # it is a standalone CMakeLists example.
0589 list(APPEND CLANG_FORMAT_PATTERNS
0590     examples/*.h
0591     examples/*.cpp)
0592 
0593 
0594 
0595 
0596 
0597 ################# Generate API documentation in QCH format #################
0598 option(
0599     BUILD_QCH                                            # Name
0600     "Generate API documentation files in the QCH format" # Help text
0601     FALSE)
0602 message(
0603     STATUS
0604     "BUILD_QCH: ${BUILD_QCH}")
0605 # For the library name, we follow the KDE policy:
0606 # https://community.kde.org/Policies/New_KDE_Library_API_Policy#Library_Naming
0607 set(LIBRARY_NAME "perceptualcolor-${MAJOR_VERSION}") # as in src/CMakeLists.txt
0608 set(QCH_TARGET "${LIBRARY_NAME}_QCH")
0609 if(BUILD_QCH)
0610     include(FeatureSummary)
0611     include(ECMAddQch)
0612     ecm_add_qch(
0613         "${QCH_TARGET}" # target name
0614         NAME "${PROJECT_NAME}"
0615         VERSION "${FULL_VERSION}"
0616         ORG_DOMAIN "org.kde.perceptualcolor"
0617         SOURCE_DIRS "src"
0618         MD_MAINPAGE "README.md"
0619         IMAGE_DIRS "docs/pics"
0620         EXAMPLE_DIRS "src" "autotests" "examples"
0621         TAGFILE_INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}/share/docs/tags"
0622         QCH_INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}/share/docs/qch"
0623         COMPONENT Devel
0624         VERBOSE
0625     )
0626     ecm_install_qch_export(
0627         TARGETS "${LIBRARY_NAME}_QCH"
0628         FILE "${LIBRARY_NAME}_QCHTargets.cmake"
0629         DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${LIBRARY_NAME}"
0630         COMPONENT Devel
0631     )
0632     message(
0633         STATUS
0634         "Target “${QCH_TARGET}” creates QCH files (builds only manually).")
0635 endif()
0636 
0637 
0638 
0639 
0640 
0641 ################# Clang format #################
0642 include(KDEClangFormat)
0643 file(
0644     # TODO Is it possible to get rid of GLOB_RECURSE?
0645     GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES # Name of the output variable.
0646     LIST_DIRECTORIES FALSE
0647     # CMake will add logic to the main build system check target to
0648     # rerun the flagged GLOB commands at build time:
0649     CONFIGURE_DEPENDS
0650     # Examples of recursive globing include:
0651     # /dir/*.py  - match all python files in /dir and subdirectories(!)
0652     ${CLANG_FORMAT_PATTERNS}
0653 )
0654 # The following line makes available the target “make clang-format”.
0655 # It requires the clang-format binary (Ubuntu package “clang-format”).
0656 kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})