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

0001 # Checking for user explicitly defined CMAKE_INSTALL_PREFIX
0002 # It must be done before project(...)
0003 if(NOT CMAKE_INSTALL_PREFIX)
0004   set(QCA_INSTALL_IN_QT_PREFIX ON)
0005   # If CMAKE_INSTALL_PREFIX is set in cmake arguments
0006   unset(CMAKE_INSTALL_PREFIX CACHE)
0007 endif()
0008 
0009 # The cmake min. version should be set before calling project(...) too
0010 cmake_minimum_required(VERSION 3.16)
0011 
0012 project(qca)
0013 
0014 set(QCA_LIB_MAJOR_VERSION "2")
0015 set(QCA_LIB_MINOR_VERSION "3")
0016 set(QCA_LIB_PATCH_VERSION "8")
0017 
0018 if(POLICY CMP0042)
0019   cmake_policy(SET CMP0042 OLD)
0020 endif()
0021 
0022 option(BUILD_WITH_QT6 "Build with Qt 6" OFF)
0023 option(BUILD_TESTS "Create test" ON)
0024 option(BUILD_TOOLS "Compile mozcerts and qcatool" ON)
0025 set(BUILD_PLUGINS "auto" CACHE STRING "Plugins for building (also possible values: none, all and auto)")
0026 # BUILD_SHARED_LIBS is cmake variable. Need to change default value.
0027 option(BUILD_SHARED_LIBS "Build shared library" ON)
0028 option(DEVELOPER_MODE "Special developer mode" OFF)
0029 
0030 if(QT6)
0031         set(BUILD_WITH_QT6 ON)
0032 endif()
0033 
0034 if(APPLE)
0035   option(OSX_FRAMEWORK "Build a Mac OS X Framework" ON)
0036 else()
0037   set(OSX_FRAMEWORK OFF)
0038 endif()
0039 
0040 find_package(Doxygen)
0041 
0042 string(TOLOWER "${BUILD_PLUGINS}" BUILD_PLUGINS)
0043 if(NOT BUILD_PLUGINS)
0044   set(BUILD_PLUGINS "none")
0045 endif()
0046 
0047 set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" )
0048 
0049 # Do not automatically link Qt executables to qtmain target on Windows.
0050 # QCA exucatables use console mode only. Not need to link against qtmain.lib.
0051 if(BUILD_WITH_QT6)
0052   set(QT_MAJOR_VERSION 6)
0053   message(STATUS "Building Qt 6 version")
0054   find_package(Qt6 COMPONENTS Core Test Core5Compat REQUIRED)
0055 else()
0056   set(QT_MAJOR_VERSION 5)
0057   message(STATUS "Building Qt 5 version")
0058   set(Qt5_NO_LINK_QTMAIN ON)
0059   find_package(Qt5 5.14 REQUIRED Core)
0060 endif()
0061 
0062 set(CMAKE_AUTOMOC ON)
0063 
0064 include(QcaMacro)
0065 include(GNUInstallDirs)
0066 if(BUILD_WITH_QT6)
0067   set(QCA_QT_PC_VERSION "Qt6Core")
0068   set(QCA_SUFFIX "qt6")
0069 else()
0070   set(QCA_QT_PC_VERSION "Qt5Core")
0071   set(QCA_SUFFIX "qt5")
0072 endif()
0073 
0074 # QCA can be shared but plugins will be static
0075 # if Qt is static.
0076 if(NOT BUILD_SHARED_LIBS OR QT_IS_STATIC)
0077   set(STATIC_PLUGINS ON)
0078   add_definitions(-DQT_STATICPLUGIN)
0079   set(PLUGIN_TYPE "STATIC")
0080 else()
0081   set(PLUGIN_TYPE "MODULE")
0082 endif()
0083 
0084 set(QCA_SUFFIX "${QCA_SUFFIX}" CACHE STRING "QCA common suffix")
0085 if(QCA_SUFFIX)
0086   set(QCA_LIB_NAME qca-${QCA_SUFFIX})
0087   set(QCA_TOOL_NAME qcatool-${QCA_SUFFIX})
0088   set(MOZCERTS_NAME mozcerts-${QCA_SUFFIX})
0089   set(QCA_PC_NAME qca2-${QCA_SUFFIX}.pc)
0090   set(QCA_CONFIG_NAME_BASE "Qca-${QCA_SUFFIX}")
0091 else()
0092   set(QCA_LIB_NAME qca)
0093   set(QCA_TOOL_NAME qcatool)
0094   set(MOZCERTS_NAME mozcerts)
0095   set(QCA_PC_NAME qca2.pc)
0096   set(QCA_CONFIG_NAME_BASE "Qca")
0097 endif()
0098 
0099 set(QCA_LIB_VERSION_STRING "${QCA_LIB_MAJOR_VERSION}.${QCA_LIB_MINOR_VERSION}.${QCA_LIB_PATCH_VERSION}")
0100 
0101 configure_file("include/QtCrypto/qca_version.h.in" "${CMAKE_BINARY_DIR}/qca_version.h")
0102 
0103 if (WIN32)
0104  set(CMAKE_DEBUG_POSTFIX "d")
0105  add_definitions(-DWIN32_LEAN_AND_MEAN)
0106 elseif (APPLE)
0107  set(CMAKE_DEBUG_POSTFIX "_debug")
0108 endif()
0109 
0110 if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
0111    if (CMAKE_SYSTEM_NAME MATCHES Linux)
0112      add_definitions (-D_DEFAULT_SOURCE)
0113      # on arm -Wcast-align throws many internal qt warning
0114      if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
0115        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wcast-align")
0116        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wcast-align")
0117      endif()
0118 
0119      set ( CMAKE_C_FLAGS     "${CMAKE_C_FLAGS} -Wno-long-long -Wundef -Werror-implicit-function-declaration -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common")
0120      set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -Wundef -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -fno-check-new -fno-common")
0121 
0122      if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
0123        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-override -Wlogical-op" )
0124      endif()
0125    endif()
0126 endif()
0127 
0128 add_definitions(-DQT_NO_CAST_TO_ASCII
0129                 -DQT_NO_CAST_FROM_ASCII
0130                 -DQT_NO_URL_CAST_FROM_STRING
0131                 -DQT_NO_CAST_FROM_BYTEARRAY
0132                 -DQT_NO_SIGNALS_SLOTS_KEYWORDS
0133                 -DQT_USE_QSTRINGBUILDER
0134                 -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT)
0135 
0136 if (NOT WIN32)
0137     # Strict iterators can't be used on Windows, they lead to a link error
0138     # when application code iterates over a QVector<QPoint> for instance, unless
0139     # Qt itself was also built with strict iterators.
0140     # See example at https://bugreports.qt.io/browse/AUTOSUITE-946
0141     add_definitions(-DQT_STRICT_ITERATORS)
0142 endif()
0143 
0144 include_directories("include/QtCrypto/")
0145 # for generated files
0146 include_directories(${CMAKE_BINARY_DIR})
0147 
0148 if(NOT DEVELOPER_MODE)
0149   # uninstall target
0150   configure_file(
0151     "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
0152     "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
0153     IMMEDIATE @ONLY)
0154 
0155   add_custom_target(uninstall
0156     COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
0157 endif()
0158 
0159 # Always include srcdir and builddir in include path
0160 # This saves typing ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY} in about every subdir
0161 set(CMAKE_INCLUDE_CURRENT_DIR ON)
0162 
0163 # put the include dirs which are in the source or build tree
0164 # before all other include dirs, so the headers in the sources
0165 # are prefered over the already installed ones
0166 set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
0167 
0168 set(qca_INCLUDEDIR "${CMAKE_CURRENT_SOURCE_DIR}/include" )
0169 
0170 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" )
0171 # Use the same path for shared and static library
0172 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" )
0173 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" )
0174 
0175 if( QCA_INSTALL_IN_QT_PREFIX )
0176   setup_qt_dirs()
0177   set(QCA_PREFIX_INSTALL_DIR "${QT_PREFIX_DIR}" CACHE PATH "Directory where qca will install")
0178   set(QCA_PLUGINS_INSTALL_DIR "${QT_PLUGINS_DIR}" CACHE PATH "Directory where qca plugins will install")
0179   set(QCA_BINARY_INSTALL_DIR "${QT_BINARY_DIR}" CACHE PATH "Directory where qca plugins will install")
0180   set(QCA_LIBRARY_INSTALL_DIR "${QT_LIBRARY_DIR}" CACHE PATH "Directory where qca library will install")
0181   set(QCA_FEATURE_INSTALL_DIR "${QT_MKSPECS_DIR}/features" CACHE PATH "Directory where qca feature file will install")
0182   if(NOT QCA_SUFFIX)
0183     set(QCA_INCLUDE_INSTALL_DIR "${QT_HEADERS_DIR}" CACHE PATH "Directory where qca public headers will install")
0184     set(QCA_PRIVATE_INCLUDE_INSTALL_DIR "${QT_HEADERS_DIR}" CACHE PATH "Directory where qca headers will install")
0185   else()
0186     set(QCA_INCLUDE_INSTALL_DIR "${QT_HEADERS_DIR}/${QCA_CONFIG_NAME_BASE}" CACHE PATH "Directory where qca public headers will install")
0187     set(QCA_PRIVATE_INCLUDE_INSTALL_DIR "${QT_HEADERS_DIR}/${QCA_CONFIG_NAME_BASE}" CACHE PATH "Directory where qca headers will install")
0188   endif()
0189   set(QCA_DOC_INSTALL_DIR "${QT_DOC_DIR}/html/qca/" CACHE PATH "Directory where qca documentation will install")
0190   set(QCA_MAN_INSTALL_DIR "${QT_DATA_DIR}/man" CACHE PATH "Directory where qca man pages will install")
0191 else()
0192   # Cmake says nothing about LIB_SUFFIX
0193   # de facto it is a standard way to specify lib suffix on many distros
0194   set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
0195   set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE PATH "Directory where lib will install")
0196 
0197   set(QCA_PREFIX_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" CACHE PATH "Directory where qca will install")
0198   set(QCA_PLUGINS_INSTALL_DIR "${LIB_INSTALL_DIR}/${QCA_LIB_NAME}" CACHE PATH "Directory where qca plugins will install")
0199   set(QCA_BINARY_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Directory where qca plugins will install")
0200   set(QCA_LIBRARY_INSTALL_DIR "${LIB_INSTALL_DIR}" CACHE PATH "Directory where qca library will install")
0201   set(QCA_FEATURE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/mkspecs/features" CACHE PATH "Directory where qca feature file will install")
0202   if(NOT QCA_SUFFIX)
0203     set(QCA_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Directory where qca public headers will install")
0204     set(QCA_PRIVATE_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Directory where qca headers will install")
0205   else()
0206     set(QCA_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/${QCA_CONFIG_NAME_BASE}" CACHE PATH "Directory where qca public headers will install")
0207     set(QCA_PRIVATE_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/${QCA_CONFIG_NAME_BASE}" CACHE PATH "Directory where qca headers will install")
0208   endif()
0209   set(QCA_DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/${QCA_LIB_NAME}/html" CACHE PATH "Directory where qca documentation will install")
0210   set(QCA_MAN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Directory where qca man pages will install")
0211 endif()
0212 
0213 set(PKGCONFIG_INSTALL_PREFIX "${QCA_LIBRARY_INSTALL_DIR}/pkgconfig" CACHE PATH "Base directory for pkgconfig files")
0214 
0215 normalize_path(QCA_PREFIX_INSTALL_DIR)
0216 
0217 if(OSX_FRAMEWORK)
0218   set(QCA_FULL_INCLUDE_INSTALL_DIR "${QCA_LIBRARY_INSTALL_DIR}/${QCA_LIB_NAME}.framework/Headers")
0219 else()
0220   set(QCA_FULL_INCLUDE_INSTALL_DIR "${QCA_INCLUDE_INSTALL_DIR}/QtCrypto")
0221 endif()
0222 
0223 # check for oportunity to use relative paths
0224 option(USE_RELATIVE_PATHS "Try to make relocatable package")
0225 
0226 foreach(PATH QCA_PLUGINS_INSTALL_DIR
0227              QCA_BINARY_INSTALL_DIR
0228              QCA_LIBRARY_INSTALL_DIR
0229              QCA_FEATURE_INSTALL_DIR
0230              QCA_INCLUDE_INSTALL_DIR
0231              QCA_PRIVATE_INCLUDE_INSTALL_DIR
0232              QCA_DOC_INSTALL_DIR
0233              QCA_MAN_INSTALL_DIR
0234              PKGCONFIG_INSTALL_PREFIX)
0235 
0236   # Normalize path before comparsion
0237   normalize_path(${PATH})
0238 
0239   # if all paths are subdirs of CMAKE_INSTALL_PREFIX it is possible to use relative paths
0240   string(FIND "${${PATH}}" "${QCA_PREFIX_INSTALL_DIR}/" POS)
0241   if(NOT "${POS}" STREQUAL "0")
0242     set(USE_RELATIVE_PATHS OFF)
0243   endif()
0244 endforeach()
0245 
0246 if(NOT WIN32)
0247   if(OSX_FRAMEWORK)
0248     set(PKGCONFIG_CFLAGS "-F\${libdir} -I\${includedir}")
0249     set(PKGCONFIG_LIBS "-F\${libdir} -framework ${QCA_LIB_NAME}")
0250   else()
0251     set(PKGCONFIG_CFLAGS "-I\${includedir}")
0252     set(PKGCONFIG_LIBS "-L\${libdir} -l${QCA_LIB_NAME}")
0253   endif()
0254 
0255   if(NOT BUILD_WITH_QT6)
0256     # qca2.pc uses absolute paths. So it must be there. Don't rellocate this.
0257     configure_file("qca2.pc.cmake" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/pkgconfig/${QCA_PC_NAME}" @ONLY)
0258     if(NOT DEVELOPER_MODE)
0259       install(FILES "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/pkgconfig/${QCA_PC_NAME}" DESTINATION ${PKGCONFIG_INSTALL_PREFIX})
0260     endif()
0261   endif()
0262 endif()
0263 
0264 # strip CMAKE_INSTALL_PREFIX in all paths
0265 if(USE_RELATIVE_PATHS)
0266   message(STATUS "Installed package is relocatable")
0267   file(RELATIVE_PATH CRYPTO_PRF_RELATIVE_PATH "${QCA_FEATURE_INSTALL_DIR}" ${CMAKE_INSTALL_PREFIX})
0268   set(CRYPTO_PRF_RELATIVE_PATH "$$PWD/${CRYPTO_PRF_RELATIVE_PATH}")
0269   foreach(PATH QCA_PLUGINS_INSTALL_DIR
0270                QCA_BINARY_INSTALL_DIR
0271                QCA_LIBRARY_INSTALL_DIR
0272                QCA_FEATURE_INSTALL_DIR
0273                QCA_INCLUDE_INSTALL_DIR
0274                QCA_PRIVATE_INCLUDE_INSTALL_DIR
0275                QCA_DOC_INSTALL_DIR
0276                QCA_MAN_INSTALL_DIR
0277                PKGCONFIG_INSTALL_PREFIX)
0278 
0279      file(RELATIVE_PATH ${PATH} ${CMAKE_INSTALL_PREFIX} "${${PATH}}")
0280   endforeach()
0281 else()
0282   message(STATUS "Installed package is NOT relocatable")
0283   set(CRYPTO_PRF_RELATIVE_PATH "")
0284 endif()
0285 
0286 if(DEVELOPER_MODE)
0287   add_definitions(-DDEVELOPER_MODE)
0288 
0289 # To prefer plugins from build tree when run qca from build tree
0290   file(WRITE ${CMAKE_BINARY_DIR}/bin/qt.conf
0291 "[Paths]
0292 Plugins=${CMAKE_BINARY_DIR}/lib/${QCA_LIB_NAME}
0293 ")
0294 endif()
0295 
0296 if (APPLE)
0297    set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
0298 endif()
0299 
0300 message(STATUS "Checking for certstore..")
0301 # fixme add OR mac
0302 if( WIN32 )
0303     # USE BUILTIN
0304 else()
0305   if ( DEFINED ENV{QC_CERTSTORE_PATH} )
0306     if(EXISTS $ENV{QC_CERTSTORE_PATH})
0307       set( qca_CERTSTORE $ENV{QC_CERTSTORE_PATH})
0308     endif()
0309   else()
0310     set( toTry
0311       "/etc/ssl/certs/ca-certificates.crt"
0312       "/usr/share/ssl/cert.pem"
0313       "/usr/share/ssl/certs/ca-bundle.crt"
0314       "/etc/pki/tls/cert.pem"
0315       "/etc/ssl/ca-bundle.pem"
0316       "/usr/share/curl/curl-ca-bundle.crt"
0317     )
0318     foreach (_current_try ${toTry})
0319       if(EXISTS ${_current_try})
0320         set( qca_CERTSTORE ${_current_try})
0321       endif()
0322     endforeach (_current_try)
0323   endif()
0324 endif()
0325 
0326 if (qca_CERTSTORE)
0327   message(STATUS "Found system certstore")
0328 else()
0329   message(STATUS "Using built in certstore.")
0330   set( qca_CERTSTORE "${CMAKE_CURRENT_SOURCE_DIR}/certs/rootcerts.pem")
0331   # note that INSTALL_FILES targets are relative to the current installation prefix...
0332   if(NOT DEVELOPER_MODE)
0333     install(FILES "${qca_CERTSTORE}" DESTINATION "${QCA_PREFIX_INSTALL_DIR}/certs")
0334   endif()
0335 endif()
0336 message(STATUS "certstore path: " ${qca_CERTSTORE})
0337 add_definitions( -DQCA_SYSTEMSTORE_PATH="${qca_CERTSTORE}" )
0338 
0339 
0340 set( private_HEADERS ${qca_INCLUDEDIR}/QtCrypto/qca_plugin.h ${qca_INCLUDEDIR}/QtCrypto/qca_systemstore.h )
0341 
0342 set( public_HEADERS
0343   ${qca_INCLUDEDIR}/QtCrypto/qca.h
0344   ${qca_INCLUDEDIR}/QtCrypto/qcaprovider.h
0345   ${qca_INCLUDEDIR}/QtCrypto/QtCrypto
0346   ${qca_INCLUDEDIR}/QtCrypto/qca_support.h
0347   ${qca_INCLUDEDIR}/QtCrypto/qca_tools.h
0348   ${qca_INCLUDEDIR}/QtCrypto/qca_core.h
0349   ${qca_INCLUDEDIR}/QtCrypto/qca_textfilter.h
0350   ${qca_INCLUDEDIR}/QtCrypto/qca_basic.h
0351   ${qca_INCLUDEDIR}/QtCrypto/qca_publickey.h
0352   ${qca_INCLUDEDIR}/QtCrypto/qca_cert.h
0353   ${qca_INCLUDEDIR}/QtCrypto/qca_keystore.h
0354   ${qca_INCLUDEDIR}/QtCrypto/qca_securelayer.h
0355   ${qca_INCLUDEDIR}/QtCrypto/qca_securemessage.h
0356   ${CMAKE_BINARY_DIR}/qca_version.h
0357   ${qca_INCLUDEDIR}/QtCrypto/qpipe.h
0358   ${qca_INCLUDEDIR}/QtCrypto/qca_safetimer.h)
0359 
0360 set( qca_HEADERS ${private_HEADERS} ${public_HEADERS} )
0361 
0362 include_directories("${qca_INCLUDEDIR}/QtCrypto")
0363 
0364 if(NOT BUILD_WITH_QT6)
0365   configure_file("crypto.prf.cmake" "${CMAKE_BINARY_DIR}/mkspecs/features/crypto.prf" @ONLY)
0366   if(NOT DEVELOPER_MODE)
0367     install(FILES "${CMAKE_BINARY_DIR}/mkspecs/features/crypto.prf" DESTINATION "${QCA_FEATURE_INSTALL_DIR}")
0368   endif()
0369 endif()
0370 
0371 configure_file(man/qcatool.1 "${CMAKE_BINARY_DIR}/share/man/man1/${QCA_TOOL_NAME}.1" COPYONLY)
0372 if(NOT DEVELOPER_MODE)
0373   install(FILES "${CMAKE_BINARY_DIR}/share/man/man1/${QCA_TOOL_NAME}.1" DESTINATION "${QCA_MAN_INSTALL_DIR}/man1")
0374 endif()
0375 
0376 set(QCA_CRYPTO_INSTALL_DIR "${QCA_PLUGINS_INSTALL_DIR}/crypto")
0377 
0378 add_subdirectory(src)
0379 add_subdirectory(plugins)
0380 
0381 include(GenerateExportHeader)
0382 generate_export_header(${QCA_LIB_NAME} BASE_NAME qca)
0383 install(FILES
0384   ${CMAKE_CURRENT_BINARY_DIR}/qca_export.h DESTINATION ${QCA_FULL_INCLUDE_INSTALL_DIR}
0385 )
0386 
0387 if(STATIC_PLUGINS)
0388   # Generate header with static plugins list
0389   file(WRITE "${CMAKE_BINARY_DIR}/import_plugins.h" "#include <QtPlugin>\n")
0390   foreach(PLUGIN IN LISTS PLUGINS)
0391     if(WITH_${PLUGIN}_PLUGIN_INTERNAL)
0392       string(REPLACE "-" "_" IMPORT_NAME "qca-${PLUGIN}")
0393       file(APPEND "${CMAKE_BINARY_DIR}/import_plugins.h" "Q_IMPORT_PLUGIN(${IMPORT_NAME})\n")
0394     endif()
0395   endforeach(PLUGIN IN LISTS PLUGINS)
0396 endif()
0397 
0398 if(BUILD_TESTS)
0399   enable_testing()
0400   add_subdirectory(unittest)
0401   add_subdirectory(examples)
0402 endif()
0403 if(BUILD_TOOLS)
0404   add_subdirectory(tools)
0405 endif()
0406 
0407 if(DOXYGEN_FOUND)
0408   configure_file(${CMAKE_SOURCE_DIR}/Doxyfile.in ${CMAKE_BINARY_DIR}/Doxyfile @ONLY)
0409   add_custom_target(doc
0410     ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile
0411     COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/docs/pics
0412     COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/docs/pics/qca-arch.eps ${CMAKE_BINARY_DIR}/docs/pics/qca-arch.eps
0413     COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/docs/pics/qca-arch.png ${CMAKE_BINARY_DIR}/docs/pics/qca-arch.png
0414     WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
0415     COMMENT "Generating API documentation with Doxygen" VERBATIM)
0416 endif()
0417 
0418 include(CMakePackageConfigHelpers)
0419 configure_package_config_file(
0420   "${CMAKE_CURRENT_SOURCE_DIR}/QcaConfig.cmake.in"
0421   "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/${QCA_CONFIG_NAME_BASE}/${QCA_CONFIG_NAME_BASE}Config.cmake"
0422   INSTALL_DESTINATION ${QCA_LIBRARY_INSTALL_DIR}/cmake/${QCA_CONFIG_NAME_BASE}
0423 )
0424 write_basic_config_version_file("${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/${QCA_CONFIG_NAME_BASE}/${QCA_CONFIG_NAME_BASE}ConfigVersion.cmake" VERSION ${QCA_LIB_VERSION_STRING} COMPATIBILITY AnyNewerVersion)
0425 
0426 if(NOT DEVELOPER_MODE)
0427 
0428   # /usr/local is traditional path for installing apps on POSIX-systems.
0429   # I consciously break this. Qt by default looks plugins and features only in
0430   # own directory. So by default install libs in Qt prefix it is a best choice.
0431   # This can be unwanted behaviour for users who don't read INSTALL file or/and
0432   # not read cmake reports. I just try to warn their.
0433 
0434   # In really anybody who do cmake . && make && sudo make install do it for own risk.
0435 
0436   if(QCA_INSTALL_IN_QT_PREFIX)
0437     string(ASCII 27 ESCAPE)
0438     message("")
0439     message("${ESCAPE}[31m")
0440     message("!!!!!!!!!!!!!!!!!!!!!ATTENTION!!!!!!!!!!!!!!!!!!!!!!")
0441     message("!! QCA will be installed in Qt prefix             !!")
0442     message("!! If you want to install in /usr/local           !!")
0443     message("!! you MUST explicity define CMAKE_INSTALL_PREFIX !!")
0444     message("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
0445     message("${ESCAPE}[0m")
0446   endif()
0447 
0448   message("")
0449   if(USE_RELATIVE_PATHS)
0450     message("QCA prefix is " "${QCA_PREFIX_INSTALL_DIR}")
0451     message("Plugins will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_PLUGINS_INSTALL_DIR}")
0452     message("Binary will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_BINARY_INSTALL_DIR}")
0453     if(OSX_FRAMEWORK)
0454       message("Framework will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_LIBRARY_INSTALL_DIR}")
0455     else()
0456       message("Library will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_LIBRARY_INSTALL_DIR}")
0457       message("Public headers will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_INCLUDE_INSTALL_DIR}")
0458       message("Private headers will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_PRIVATE_INCLUDE_INSTALL_DIR}")
0459     endif()
0460     message("Feature file will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_FEATURE_INSTALL_DIR}")
0461     message("Documentation will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_DOC_INSTALL_DIR}")
0462     message("Man page will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_MAN_INSTALL_DIR}")
0463     message("Pkg-config file will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${PKGCONFIG_INSTALL_PREFIX}")
0464   else()
0465     message("QCA prefix is " "${QCA_PREFIX_INSTALL_DIR}")
0466     message("Plugins will be installed to " "${QCA_PLUGINS_INSTALL_DIR}")
0467     message("Binary will be installed to " "${QCA_BINARY_INSTALL_DIR}")
0468     if(OSX_FRAMEWORK)
0469       message("Framework will be installed to " "${QCA_LIBRARY_INSTALL_DIR}")
0470     else()
0471       message("Library will be installed to " "${QCA_LIBRARY_INSTALL_DIR}")
0472       message("Public headers will be installed to " "${QCA_INCLUDE_INSTALL_DIR}")
0473       message("Private headers will be installed to " "${QCA_PRIVATE_INCLUDE_INSTALL_DIR}")
0474     endif()
0475     message("Feature file will be installed to " "${QCA_FEATURE_INSTALL_DIR}")
0476     message("Documentation will be installed to " "${QCA_DOC_INSTALL_DIR}")
0477     message("Man page will be installed to " "${QCA_MAN_INSTALL_DIR}")
0478     message("Pkg-config file will be installed to " "${PKGCONFIG_INSTALL_PREFIX}")
0479   endif()
0480   message("")
0481 
0482   if(UNIX AND NOT APPLE)
0483     if(NOT QCA_SUFFIX)
0484 
0485       message("${ESCAPE}[31mYou don't have QCA_SUFFIX set. Please note that the recommended way of")
0486       if(BUILD_WITH_QT6)
0487         message("building Qt6 version of qca for Linux distributions is to set")
0488         message("QCA_SUFFIX to qt6 (-DQCA_SUFFIX=qt6).")
0489       else()
0490         message("building Qt5 version of qca for Linux distributions is to set")
0491         message("QCA_SUFFIX to qt5 (-DQCA_SUFFIX=qt5).")
0492       endif()
0493       message("${ESCAPE}[0m")
0494     endif()
0495   endif()
0496 
0497   install(EXPORT ${QCA_CONFIG_NAME_BASE}Targets DESTINATION ${QCA_LIBRARY_INSTALL_DIR}/cmake/${QCA_CONFIG_NAME_BASE} FILE ${QCA_CONFIG_NAME_BASE}Targets.cmake)
0498   install(FILES
0499     "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/${QCA_CONFIG_NAME_BASE}/${QCA_CONFIG_NAME_BASE}Config.cmake"
0500     "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/${QCA_CONFIG_NAME_BASE}/${QCA_CONFIG_NAME_BASE}ConfigVersion.cmake"
0501     DESTINATION ${QCA_LIBRARY_INSTALL_DIR}/cmake/${QCA_CONFIG_NAME_BASE}
0502     )
0503 endif()