Warning, /graphics/digikam/core/cmake/macros/MacroUtils.cmake is written in an unsupported language. File is not indexed.

0001 # Some useful cmake macros for general purposes
0002 #
0003 # SPDX-FileCopyrightText: 2010-2024 by Gilles Caulier, <caulier dot gilles at gmail dot com>
0004 #
0005 # SPDX-License-Identifier: BSD-3-Clause
0006 #
0007 
0008 # -------------------------------------------------------------------------
0009 
0010 set(PRINT_COMPILE_LENGTH "40")
0011 
0012 macro(FILL_WITH_DOTS VAR)
0013 
0014     string(LENGTH ${${VAR}} NAME_LENGTH)
0015 
0016     math(EXPR DOT_LENGTH "${PRINT_COMPILE_LENGTH} - ${NAME_LENGTH}")
0017 
0018     if(${DOT_LENGTH} LESS 0)
0019 
0020         set(DOT_LENGTH 0)
0021 
0022     endif()
0023 
0024     foreach(COUNT RANGE ${DOT_LENGTH})
0025 
0026         set(${VAR} "${${VAR}}.")
0027 
0028     endforeach()
0029 
0030 endmacro()
0031 
0032 # -------------------------------------------------------------------------
0033 
0034 macro(PRINT_LIBRARY_STATUS NAME WEBSITE VERSIONHINT)
0035 
0036     set(LIB_MESSAGE "${NAME} found")
0037     FILL_WITH_DOTS(LIB_MESSAGE)
0038 
0039     if(${ARGN})
0040 
0041         message(STATUS " ${LIB_MESSAGE} YES")
0042 
0043     else()
0044 
0045         message(STATUS " ${LIB_MESSAGE} NO")
0046         message(SEND_ERROR " ${NAME} is needed. You need to install the ${NAME} ${VERSIONHINT} development package.")
0047         message(STATUS " ${NAME} website is at ${WEBSITE}")
0048         message(STATUS "")
0049 
0050     endif()
0051 
0052 endmacro()
0053 
0054 # -------------------------------------------------------------------------
0055 
0056 macro(PRINT_OPTIONAL_LIBRARY_STATUS NAME WEBSITE VERSIONHINT FEATUREMISSING)
0057 
0058     set(LIB_MESSAGE "${NAME} found")
0059     FILL_WITH_DOTS(LIB_MESSAGE)
0060 
0061     if(${ARGN})
0062 
0063         message(STATUS " ${LIB_MESSAGE} YES (optional)")
0064 
0065     else()
0066 
0067         message(STATUS " ${LIB_MESSAGE} NO  (optional)")
0068         message(STATUS " ${FEATUREMISSING}")
0069         message(STATUS " Please install the ${NAME} ${VERSIONHINT} development package.")
0070         if(${WEBSITE})
0071             message(STATUS " ${NAME} website is at ${WEBSITE}")
0072         endif()
0073         message(STATUS "")
0074 
0075     endif()
0076 
0077 endmacro()
0078 
0079 # -------------------------------------------------------------------------
0080 
0081 macro(PRINT_QTMODULE_STATUS NAME)
0082 
0083     set(LIB_MESSAGE "${NAME} module found")
0084     FILL_WITH_DOTS(LIB_MESSAGE)
0085 
0086     if(${ARGN})
0087 
0088         message(STATUS " ${LIB_MESSAGE} YES")
0089 
0090     else()
0091 
0092         message(STATUS " ${LIB_MESSAGE} NO")
0093         message(STATUS "")
0094         message(SEND_ERROR " ${NAME} module is needed. You need to install a package containing the ${NAME} module.")
0095         message(STATUS "")
0096 
0097     endif()
0098 
0099 endmacro()
0100 
0101 # -------------------------------------------------------------------------
0102 
0103 macro(PRINT_EXECUTABLE_STATUS NAME TECHNICAL_NAME PATH_VARIABLE)
0104 
0105     set(LIB_MESSAGE "${NAME} found")
0106     FILL_WITH_DOTS(LIB_MESSAGE)
0107 
0108     if(${ARGN})
0109 
0110         message(STATUS " ${LIB_MESSAGE} YES")
0111 
0112     else()
0113 
0114         message(STATUS " ${LIB_MESSAGE} NO")
0115         message(STATUS "")
0116         message(STATUS " ${NAME} is needed. You need to install the package containing the \"${TECHNICAL_NAME}\" executable.")
0117         message(STATUS " If you have this executable installed, please specify the folder containing it by ${PATH_VARIABLE}")
0118         message(SEND_ERROR "")
0119 
0120     endif()
0121 
0122 endmacro()
0123 
0124 # -------------------------------------------------------------------------
0125 
0126 macro(PRINT_COMPONENT_COMPILE_STATUS NAME)
0127 
0128     set(COMPILE_MESSAGE "${NAME} will be compiled")
0129     FILL_WITH_DOTS(COMPILE_MESSAGE)
0130 
0131     IF(${ARGN})
0132 
0133         message(STATUS " ${COMPILE_MESSAGE} YES (optional)")
0134 
0135     else()
0136 
0137         message(STATUS " ${COMPILE_MESSAGE} NO  (optional)")
0138 
0139     endif()
0140 
0141 endmacro()
0142 
0143 # -------------------------------------------------------------------------
0144 
0145 macro(PRINT_OPTIONAL_QTMODULE_STATUS NAME)
0146 
0147     set(LIB_MESSAGE "${NAME} module found")
0148     FILL_WITH_DOTS(LIB_MESSAGE)
0149 
0150     if(${ARGN})
0151 
0152         message(STATUS " ${LIB_MESSAGE} YES (optional)")
0153 
0154     else()
0155 
0156         message(STATUS " ${LIB_MESSAGE} NO  (optional)")
0157 
0158     endif()
0159 
0160 endmacro()
0161 
0162 # -------------------------------------------------------------------------
0163 
0164 macro(HEADER_DIRECTORIES root_path return_list)
0165 
0166     file(GLOB_RECURSE new_list ${root_path}/*.h)
0167     set(dir_list "")
0168 
0169     foreach(file_path ${new_list})
0170 
0171         get_filename_component(dir_path ${file_path} PATH)
0172         set(dir_list ${dir_list} ${dir_path})
0173 
0174     endforeach()
0175 
0176     list(REMOVE_DUPLICATES dir_list)
0177     set(${return_list} ${dir_list})
0178 
0179 endmacro()
0180 
0181 # -------------------------------------------------------------------------
0182 
0183 macro(APPLY_COMMON_POLICIES)
0184 
0185     if(POLICY CMP0063)
0186         # C++ symbols visibility policy introduced in CMake version 3.3
0187         # Details: https://cmake.org/cmake/help/git-stage/policy/CMP0063.html
0188         cmake_policy(SET CMP0063 NEW)
0189     endif()
0190 
0191     if(POLICY CMP0068)
0192         # MacOS RPATH settings policy introduced in CMake version 3.9
0193         # Details: https://cmake.org/cmake/help/git-stage/policy/CMP0068.html
0194         cmake_policy(SET CMP0068 NEW)
0195     endif()
0196 
0197     if(POLICY CMP0071)
0198         # Automoc/autouic files handling introduced in CMake version 3.10
0199         # Details: https://cmake.org/cmake/help/git-stage/policy/CMP0071.html
0200         cmake_policy(SET CMP0071 NEW)
0201     endif()
0202 
0203     if(POLICY CMP0092)
0204         # MSVC warnings flag rules introduced in CMake version 3.16
0205         # Details: https://cmake.org/cmake/help/git-stage/policy/CMP0092.html
0206         cmake_policy(SET CMP0092 NEW)
0207     endif()
0208 
0209 endmacro()
0210 
0211 # -------------------------------------------------------------------------
0212 
0213 macro(MACOS_DEBUG_POLICIES)
0214 
0215     # Cmake do not support yet the dSYM scheme.
0216     # See details from the CMake report: https://gitlab.kitware.com/cmake/cmake/-/issues/20256
0217 
0218     if(APPLE)
0219 
0220         if((CMAKE_BUILD_TYPE MATCHES Release) OR (CMAKE_BUILD_TYPE MATCHES MinSizeRel))
0221 
0222             message(STATUS "MacOS optimized build, symbol generation turned-OFF" )
0223 
0224             # on optimized builds, do NOT turn-on symbol generation.
0225 
0226         else()
0227 
0228             message(STATUS "MacOS non-optimized build, symbol generation turned-ON")
0229 
0230             # Incredibly, for both clang and g++, while a single compile-and-link
0231             # invocation will create an executable.dSYM/ dir with debug info,
0232             # with separate compilation the final link does NOT create the
0233             # dSYM dir.
0234             # The "dsymutil" program will create the dSYM dir for us.
0235             # Strangely it takes in the executable and not the object
0236             # files even though it's the latter that contain the debug info.
0237             # Thus it will only work if the object files are still sitting around.
0238 
0239             find_program(DSYMUTIL_PROGRAM dsymutil)
0240 
0241             if (DSYMUTIL_PROGRAM)
0242 
0243                 set(CMAKE_C_LINK_EXECUTABLE
0244                     "${CMAKE_C_LINK_EXECUTABLE}"
0245                     "${DSYMUTIL_PROGRAM} <TARGET>")
0246 
0247                 set(CMAKE_C_CREATE_SHARED_LIBRARY
0248                     "${CMAKE_C_CREATE_SHARED_LIBRARY}"
0249                     "${DSYMUTIL_PROGRAM} <TARGET>")
0250 
0251                 set(CMAKE_CXX_LINK_EXECUTABLE
0252                     "${CMAKE_CXX_LINK_EXECUTABLE}"
0253                     "${DSYMUTIL_PROGRAM} <TARGET>")
0254 
0255                 set(CMAKE_CXX_CREATE_SHARED_LIBRARY
0256                     "${CMAKE_CXX_CREATE_SHARED_LIBRARY}"
0257                     "${DSYMUTIL_PROGRAM} <TARGET>")
0258 
0259                 set(CMAKE_CXX_CREATE_SHARED_MODULE
0260                     "${CMAKE_CXX_CREATE_SHARED_MODULE}"
0261                     "${DSYMUTIL_PROGRAM} <TARGET>")
0262 
0263             endif()
0264 
0265         endif()
0266 
0267     endif()
0268 
0269 endmacro()
0270