diff options
Diffstat (limited to 'cmake/modules')
-rw-r--r-- | cmake/modules/FindBDB.cmake | 4 | ||||
-rw-r--r-- | cmake/modules/FindBerkeleyDB.cmake | 168 | ||||
-rw-r--r-- | cmake/modules/FindGLib.cmake | 5 | ||||
-rw-r--r-- | cmake/modules/FindGObjectIntrospection.cmake | 8 | ||||
-rw-r--r-- | cmake/modules/FindLibXML.cmake | 5 | ||||
-rw-r--r-- | cmake/modules/FindWcecompat.cmake | 6 | ||||
-rw-r--r-- | cmake/modules/GObjectIntrospectionMacros.cmake | 97 | ||||
-rw-r--r-- | cmake/modules/GtkDoc.cmake | 62 | ||||
-rw-r--r-- | cmake/modules/LibIcalMacrosInternal.cmake | 17 |
9 files changed, 312 insertions, 60 deletions
diff --git a/cmake/modules/FindBDB.cmake b/cmake/modules/FindBDB.cmake index 8c9616eb..312901c0 100644 --- a/cmake/modules/FindBDB.cmake +++ b/cmake/modules/FindBDB.cmake @@ -1,3 +1,7 @@ +# +# SPDX-FileCopyrightText: Allen Winter <winter@kde.org> +# SPDX-License-Identifier: BSD-3-Clause +# # Finds the Berkeley DB Library # # BDB_FOUND - True if Berkeley DB found. diff --git a/cmake/modules/FindBerkeleyDB.cmake b/cmake/modules/FindBerkeleyDB.cmake new file mode 100644 index 00000000..63ffe9dc --- /dev/null +++ b/cmake/modules/FindBerkeleyDB.cmake @@ -0,0 +1,168 @@ + +# SPDX-FileCopyrightText: sum01 <sum01@protonmail.com> +# SPDX-License-Identifier: Unlicense + +# Git: https://github.com/sum01/FindBerkeleyDB + +# NOTE: If Berkeley DB ever gets a Pkg-config ".pc" file, add pkg_check_modules() here + +# Checks if environment paths are empty, set them if they aren't +set(_BERKELEYDB_PATHS "") +if(NOT _BERKELEYDB_PATHS AND DEFINED BERKELEYDB_ROOT) + if($ENV{BERKELEYDB_ROOT} AND NOT "$ENV{BERKELEYDB_ROOT}" STREQUAL "") + set(_BERKELEYDB_PATHS "$ENV{BERKELEYDB_ROOT}") + endif() +endif() +if(NOT _BERKELEYDB_PATHS AND DEFINED Berkeleydb_ROOT) + if($ENV{Berkeleydb_ROOT} AND NOT "$ENV{Berkeleydb_ROOT}" STREQUAL "") + set(_BERKELEYDB_PATHS "$ENV{Berkeleydb_ROOT}") + endif() +endif() +if(NOT _BERKELEYDB_PATHS AND DEFINED BERKELEYDBROOT) + if($ENV{BERKELEYDBROOT} AND NOT "$ENV{BERKELEYDBROOT}" STREQUAL "") + set(_BERKELEYDB_PATHS "$ENV{BERKELEYDBROOT}") + endif() +endif() + +# Allow user to pass a path instead of guessing +if(BerkeleyDB_ROOT_DIR) + set(_BERKELEYDB_PATHS "${BerkeleyDB_ROOT_DIR}") +elseif(CMAKE_SYSTEM_NAME MATCHES ".*[wW]indows.*") + # MATCHES is used to work on any devies with windows in the name + # Shameless copy-paste from FindOpenSSL.cmake v3.8 + file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles) + list(APPEND _BERKELEYDB_PATHS "${_programfiles}") + + # There's actually production release and version numbers in the file path. + # For example, if they're on v6.2.32: C:/Program Files/Oracle/Berkeley DB 12cR1 6.2.32/ + # But this still works to find it, so I'm guessing it can accept partial path matches. + + foreach(_target_berkeleydb_path "Oracle/Berkeley DB" "Berkeley DB") + list(APPEND _BERKELEYDB_PATHS + "${_programfiles}/${_target_berkeleydb_path}" + "C:/Program Files (x86)/${_target_berkeleydb_path}" + "C:/Program Files/${_target_berkeleydb_path}" + "C:/${_target_berkeleydb_path}" + ) + endforeach() +else() + # Paths for anything other than Windows + # Cellar/berkeley-db is for macOS from homebrew installation + list(APPEND _BERKELEYDB_PATHS + "/usr" + "/usr/local" + "/usr/local/Cellar/berkeley-db" + "/opt" + "/opt/local" + ) +endif() + +# Find includes path +find_path(BerkeleyDB_INCLUDE_DIRS + NAMES "db.h" + HINTS ${_BERKELEYDB_PATHS} + PATH_SUFFIXES "include" "includes" +) + +# Checks if the version file exists, save the version file to a var, and fail if there's no version file +if(BerkeleyDB_INCLUDE_DIRS) + # Read the version file db.h into a variable + file(READ "${BerkeleyDB_INCLUDE_DIRS}/db.h" _BERKELEYDB_DB_HEADER) + # Parse the DB version into variables to be used in the lib names + string(REGEX REPLACE ".*DB_VERSION_MAJOR ([0-9]+).*" "\\1" BerkeleyDB_VERSION_MAJOR "${_BERKELEYDB_DB_HEADER}") + string(REGEX REPLACE ".*DB_VERSION_MINOR ([0-9]+).*" "\\1" BerkeleyDB_VERSION_MINOR "${_BERKELEYDB_DB_HEADER}") + # Patch version example on non-crypto installs: x.x.xNC + string(REGEX REPLACE ".*DB_VERSION_PATCH ([0-9]+(NC)?).*" "\\1" BerkeleyDB_VERSION_PATCH "${_BERKELEYDB_DB_HEADER}") +else() + if(BerkeleyDB_FIND_REQUIRED) + # If the find_package(BerkeleyDB REQUIRED) was used, fail since we couldn't find the header + message(FATAL_ERROR + "Failed to find Berkeley DB's header file \"db.h\"! Try setting \"BerkeleyDB_ROOT_DIR\" when initiating Cmake.") + endif() + # Set some garbage values to the versions since we didn't find a file to read + set(BerkeleyDB_VERSION_MAJOR "0") + set(BerkeleyDB_VERSION_MINOR "0") + set(BerkeleyDB_VERSION_PATCH "0") +endif() + +# The actual returned/output version variable (the others can be used if needed) +set(BerkeleyDB_VERSION "${BerkeleyDB_VERSION_MAJOR}.${BerkeleyDB_VERSION_MINOR}.${BerkeleyDB_VERSION_PATCH}") + +set(BerkeleyDB_LIBRARIES "") +# Finds the target library for berkeley db, since they all follow the same naming conventions +macro(findpackage_berkeleydb_get_lib _berkeleydb_output_varname _target_berkeleydb_lib) + # Different systems sometimes have a version in the lib name... + # and some have a dash or underscore before the versions. + # CMake recommends to put unversioned names before versioned names + find_library(${_berkeleydb_output_varname} + NAMES + "${_target_berkeleydb_lib}" + "lib${_target_berkeleydb_lib}" + "lib${_target_berkeleydb_lib}${BerkeleyDB_VERSION_MAJOR}.${BerkeleyDB_VERSION_MINOR}" + "lib${_target_berkeleydb_lib}-${BerkeleyDB_VERSION_MAJOR}.${BerkeleyDB_VERSION_MINOR}" + "lib${_target_berkeleydb_lib}_${BerkeleyDB_VERSION_MAJOR}.${BerkeleyDB_VERSION_MINOR}" + "lib${_target_berkeleydb_lib}${BerkeleyDB_VERSION_MAJOR}${BerkeleyDB_VERSION_MINOR}" + "lib${_target_berkeleydb_lib}-${BerkeleyDB_VERSION_MAJOR}${BerkeleyDB_VERSION_MINOR}" + "lib${_target_berkeleydb_lib}_${BerkeleyDB_VERSION_MAJOR}${BerkeleyDB_VERSION_MINOR}" + "lib${_target_berkeleydb_lib}${BerkeleyDB_VERSION_MAJOR}" + "lib${_target_berkeleydb_lib}-${BerkeleyDB_VERSION_MAJOR}" + "lib${_target_berkeleydb_lib}_${BerkeleyDB_VERSION_MAJOR}" + HINTS ${_BERKELEYDB_PATHS} + PATH_SUFFIXES "lib" "lib64" "libs" "libs64" + ) + # If the library was found, add it to our list of libraries + if(${_berkeleydb_output_varname}) + # If found, append to our libraries variable + # The ${{}} is because the first expands to target the real variable, the second expands + # the variable's contents... and the real variable's contents is the path to the lib. Thus, + # it appends the path of the lib to BerkeleyDB_LIBRARIES. + list(APPEND BerkeleyDB_LIBRARIES "${${_berkeleydb_output_varname}}") + endif() +endmacro() + +# Find and set the paths of the specific library to the variable +findpackage_berkeleydb_get_lib(BerkeleyDB_LIBRARY "db") +# NOTE: Windows doesn't have a db_cxx lib, but instead compiles the cxx code into the "db" lib +findpackage_berkeleydb_get_lib(BerkeleyDB_Cxx_LIBRARY "db_cxx") +# NOTE: I don't think Linux/Unix gets an SQL lib +findpackage_berkeleydb_get_lib(BerkeleyDB_Sql_LIBRARY "db_sql") +findpackage_berkeleydb_get_lib(BerkeleyDB_Stl_LIBRARY "db_stl") + +# Needed for find_package_handle_standard_args() +include(FindPackageHandleStandardArgs) +# Fails if required vars aren't found, or if the version doesn't meet specifications. +find_package_handle_standard_args(BerkeleyDB + FOUND_VAR BerkeleyDB_FOUND + REQUIRED_VARS + BerkeleyDB_INCLUDE_DIRS + BerkeleyDB_LIBRARY + VERSION_VAR BerkeleyDB_VERSION +) + +# Create an imported lib for easy linking by external projects +if(BerkeleyDB_FOUND AND BerkeleyDB_LIBRARIES AND NOT TARGET Oracle::BerkeleyDB) + add_library(Oracle::BerkeleyDB UNKNOWN IMPORTED) + set_target_properties(Oracle::BerkeleyDB PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${BerkeleyDB_INCLUDE_DIRS}" + IMPORTED_LOCATION "${BerkeleyDB_LIBRARY}" + INTERFACE_LINK_LIBRARIES "${BerkeleyDB_LIBRARIES}" + ) +endif() + +# Only show the includes path and libraries in the GUI if they click "advanced". +# Does nothing when using the CLI +mark_as_advanced(FORCE + BerkeleyDB_INCLUDE_DIRS + BerkeleyDB_LIBRARIES + BerkeleyDB_LIBRARY + BerkeleyDB_Cxx_LIBRARY + BerkeleyDB_Sql_LIBRARY + BerkeleyDB_Stl_LIBRARY +) + +include(FindPackageMessage) +# A message that tells the user what includes/libs were found, and obeys the QUIET command. +find_package_message(BerkeleyDB + "Found BerkeleyDB libraries: ${BerkeleyDB_LIBRARIES}" + "[${BerkeleyDB_LIBRARIES}[${BerkeleyDB_INCLUDE_DIRS}]]" +) diff --git a/cmake/modules/FindGLib.cmake b/cmake/modules/FindGLib.cmake index 1092dc14..9dabe310 100644 --- a/cmake/modules/FindGLib.cmake +++ b/cmake/modules/FindGLib.cmake @@ -1,5 +1,8 @@ -# - try to find glib # +# SPDX-FileCopyrightText: Milan Crha <mcrha@redhat.com> +# SPDX-License-Identifier: BSD-3-Clause +# +# - try to find glib # Once done this will define # # GLIB_FOUND - system has GLib 2.0 diff --git a/cmake/modules/FindGObjectIntrospection.cmake b/cmake/modules/FindGObjectIntrospection.cmake index 02841f4f..2eb289a9 100644 --- a/cmake/modules/FindGObjectIntrospection.cmake +++ b/cmake/modules/FindGObjectIntrospection.cmake @@ -11,11 +11,11 @@ # GObjectIntrospection_CFLAGS # GObjectIntrospection_LIBS # -# Copyright (C) 2010, Pino Toscano, <pino@kde.org> +# SPDX-FileCopyrightText: 2010, Pino Toscano, <pino@kde.org> +# SPDX-License-Identifier: BSD-3-Clause # -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# Get gobject-introspection's specified pkg-config variable macro(_GIR_GET_PKGCONFIG_VAR _outvar _varname) execute_process( COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=${_varname} gobject-introspection-1.0 @@ -27,7 +27,7 @@ macro(_GIR_GET_PKGCONFIG_VAR _outvar _varname) else() string(REGEX REPLACE "[\r\n]" " " _result "${_result}") string(REGEX REPLACE " +$" "" _result "${_result}") - separate_arguments(_result) + separate_arguments(_result UNIX_COMMAND ${_result}) set(${_outvar} ${_result} CACHE INTERNAL "") endif() endmacro(_GIR_GET_PKGCONFIG_VAR) diff --git a/cmake/modules/FindLibXML.cmake b/cmake/modules/FindLibXML.cmake index 3c418b67..891a8004 100644 --- a/cmake/modules/FindLibXML.cmake +++ b/cmake/modules/FindLibXML.cmake @@ -1,5 +1,8 @@ -# - try to find libxml # +# SPDX-FileCopyrightText: Milan Crha <mcrha@redhat.com> +# SPDX-License-Identifier: BSD-3-Clause +# +# - try to find libxml # Once done this will define # # LIBXML_FOUND - system has libxml 2.0 diff --git a/cmake/modules/FindWcecompat.cmake b/cmake/modules/FindWcecompat.cmake index 4af53aa5..c054dc4d 100644 --- a/cmake/modules/FindWcecompat.cmake +++ b/cmake/modules/FindWcecompat.cmake @@ -5,9 +5,11 @@ # WCECOMPAT_INCLUDE_DIR - Wcecompat include directory # WCECOMPAT_LIBRARIES - Libraries needed to use Wcecompat # -# Copyright (c) 2010, Andreas Holzammer, <andy@kdab.com> +# SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com> +# Author: Andreas Holzammer, <andy@kdab.com> +# +# SPDX-License-Identifier: BSD-3-Clause # -# Redistribution and use is allowed according to the terms of the BSD license. if(WCECOMPAT_INCLUDE_DIR AND WCECOMPAT_LIB_FOUND) set(Wcecompat_FIND_QUIETLY TRUE) diff --git a/cmake/modules/GObjectIntrospectionMacros.cmake b/cmake/modules/GObjectIntrospectionMacros.cmake index 83aff931..3af08ee8 100644 --- a/cmake/modules/GObjectIntrospectionMacros.cmake +++ b/cmake/modules/GObjectIntrospectionMacros.cmake @@ -1,8 +1,7 @@ -# Copyright (C) 2010, Pino Toscano, <pino at kde.org> -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# SPDX-FileCopyrightText: 2010, Pino Toscano, <pino at kde.org> +# SPDX-License-Identifier: BSD-3-Clause +# Generate list from another list, but with each item prepended with a prefix macro(_gir_list_prefix _outvar _listvar _prefix) set(${_outvar}) foreach(_item IN LISTS ${_listvar}) @@ -10,13 +9,12 @@ macro(_gir_list_prefix _outvar _listvar _prefix) endforeach() endmacro(_gir_list_prefix) +# cmake-lint: disable=R0915 macro(gir_add_introspections introspections_girs) - set(_gir_girs) set(_gir_typelibs) foreach(gir IN LISTS ${introspections_girs}) - set(_gir_name "${gir}") ## Transform the gir filename to something which can reference through a variable @@ -26,20 +24,44 @@ macro(gir_add_introspections introspections_girs) # Namespace and Version is either fetched from the gir filename # or the _NAMESPACE/_VERSION variable combo - set(_gir_namespace "${${_gir_name}_NAMESPACE}") + set(_gir_namespace "") + if(DEFINED ${_gir_name}_NAMESPACE) + set(_gir_namespace "${${_gir_name}_NAMESPACE}") + endif() if (_gir_namespace STREQUAL "") string(REGEX REPLACE "([^-]+)-.*" "\\1" _gir_namespace "${gir}") endif () - set(_gir_version "${${_gir_name}_VERSION}") + + set(_gir_version "") + if(DEFINED ${_gir_name}_VERSION) + set(_gir_version "${${_gir_name}_VERSION}") + endif() if (_gir_version STREQUAL "") string(REGEX REPLACE ".*-([^-]+).gir" "\\1" _gir_version "${gir}") endif () # _PROGRAM is an optional variable which needs its own --program argument - set(_gir_program "${${_gir_name}_PROGRAM}") + set(_gir_program "") + if(DEFINED ${_gir_name}_PROGRAM) + set(_gir_program "${${_gir_name}_PROGRAM}") + endif() if (NOT _gir_program STREQUAL "") set(_gir_program "--program=${_gir_program}") - endif () + endif() + + # _SCANNERFLAGS is optional + set(_gir_scannerflags "") + if(DEFINED ${_gir_name}_SCANNERFLAGS) + set(_gir_scannerflags "${${_gir_name}_SCANNERFLAGS}") + endif() + + # _FILES + set(_gir_files "") + if(DEFINED ${_gir_name}_FILES) + set(_gir_files "${${_gir_name}_FILES}") + else() + message(ERROR "Unspecified or empty ${_gir_name}_FILES variable") + endif() # Variables which provides a list of things _gir_list_prefix(_gir_libraries ${_gir_name}_LIBS "--library=") @@ -50,47 +72,54 @@ macro(gir_add_introspections introspections_girs) set(_gir_libtool "--no-libtool") add_custom_command( - COMMAND ${CMAKE_COMMAND} -E env "CC='${CMAKE_C_COMPILER}'" - ${GObjectIntrospection_SCANNER} - ${GObjectIntrospection_SCANNER_ARGS} - --namespace=${_gir_namespace} - --nsversion=${_gir_version} - ${_gir_libtool} - ${_gir_program} - ${_gir_libraries} - ${_gir_packages} - ${_gir_includes} - ${${_gir_name}_SCANNERFLAGS} - ${${_gir_name}_CFLAGS} - ${${_gir_name}_FILES} - --output ${CMAKE_CURRENT_BINARY_DIR}/${gir} - --accept-unprefixed - DEPENDS ${${_gir_name}_FILES} - ${${_gir_name}_LIBS} OUTPUT ${gir} + COMMAND ${GObjectIntrospection_SCANNER} + ${GObjectIntrospection_SCANNER_ARGS} + --namespace=${_gir_namespace} + --nsversion=${_gir_version} + ${_gir_libtool} + ${_gir_program} + ${_gir_libraries} + ${_gir_packages} + ${_gir_includes} + ${_gir_scannerflags} + ${${_gir_name}_CFLAGS} + ${_gir_files} + --output ${CMAKE_CURRENT_BINARY_DIR}/${gir} + --accept-unprefixed + DEPENDS ${_gir_files} ${${_gir_name}_LIBS} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} VERBATIM + COMMENT "Run the gobject introspection scanner" ) list(APPEND _gir_girs ${CMAKE_CURRENT_BINARY_DIR}/${gir}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${gir} DESTINATION ${SHARE_INSTALL_DIR}/gir-1.0) string(REPLACE ".gir" ".typelib" _typelib "${gir}") add_custom_command( + OUTPUT ${_typelib} COMMAND ${GObjectIntrospection_COMPILER} - ${GObjectIntrospection_COMPILER_ARGS} - --includedir=. - ${CMAKE_CURRENT_BINARY_DIR}/${gir} - -o ${CMAKE_CURRENT_BINARY_DIR}/${_typelib} + --includedir=. + ${CMAKE_CURRENT_BINARY_DIR}/${gir} + -o ${CMAKE_CURRENT_BINARY_DIR}/${_typelib} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${gir} - OUTPUT ${_typelib} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Run the gobject introspection compiler" ) list(APPEND _gir_typelibs ${CMAKE_CURRENT_BINARY_DIR}/${_typelib}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_typelib} DESTINATION ${LIB_INSTALL_DIR}/girepository-1.0) endforeach() - add_custom_target(gir-girs-${_gir_name} ALL DEPENDS ${_gir_girs}) - add_custom_target(gir-typelibs-${_gir_name} ALL DEPENDS ${_gir_typelibs}) + add_custom_target(gir-girs-${_gir_name} + ALL + DEPENDS ${_gir_girs} + COMMENT "Target for the gobject introspection compiler" + ) + add_custom_target(gir-typelibs-${_gir_name} + ALL + DEPENDS ${_gir_typelibs} + COMMENT "Target for the gobject introspection typelibs" + ) endmacro(gir_add_introspections) diff --git a/cmake/modules/GtkDoc.cmake b/cmake/modules/GtkDoc.cmake index 6090cb85..f81a33b8 100644 --- a/cmake/modules/GtkDoc.cmake +++ b/cmake/modules/GtkDoc.cmake @@ -1,5 +1,8 @@ # GtkDoc.cmake # +# SPDX-FileCopyrightText: Milan Crha <mcrha@redhat.com> +# SPDX-License-Identifier: BSD-3-Clause +# # Macros to support develper documentation build from sources with gtk-doc. # # Note that every target and dependency should be defined before the macro is @@ -18,12 +21,6 @@ # It also adds custom target gtkdoc-rebuild-${_module}-sgml to rebuild the sgml.in # file based on the current sources. -libical_option(ENABLE_GTK_DOC "Use gtk-doc to build documentation" True) - -if(NOT ENABLE_GTK_DOC) - return() -endif() - find_program(GTKDOC_SCAN gtkdoc-scan) find_program(GTKDOC_SCANGOBJ gtkdoc-scangobj) find_program(GTKDOC_MKDB gtkdoc-mkdb) @@ -36,13 +33,14 @@ if(NOT (GTKDOC_SCAN AND GTKDOC_MKDB AND GTKDOC_MKHTML AND GTKDOC_FIXXREF)) endif() if(NOT TARGET gtkdocs) - add_custom_target(gtkdocs ALL) + add_custom_target(gtkdocs ALL COMMENT "Target to run gtkdoc for all modules") endif() if(NOT TARGET gtkdoc-rebuild-sgmls) - add_custom_target(gtkdoc-rebuild-sgmls) + add_custom_target(gtkdoc-rebuild-sgmls COMMENT "Target to rebuild sgml for all modules") endif() +# cmake-lint: disable=R0912,R0915 macro(add_gtkdoc _module _namespace _deprecated_guards _srcdirsvar _depsvar _ignoreheadersvar) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/${_module}-docs.sgml.in @@ -61,7 +59,10 @@ macro(add_gtkdoc _module _namespace _deprecated_guards _srcdirsvar _depsvar _ign if(APPLE) if(NOT DEFINED ENV{XML_CATALOG_FILES}) - message(FATAL_ERROR "On OSX, please run \'export XML_CATALOG_FILES=/usr/local/etc/xml/catalog\' first; else the gtk entities cannot be located.") + message(FATAL_ERROR + "On OSX, please run \'export XML_CATALOG_FILES=/usr/local/etc/xml/catalog\' first; " + "else the gtk entities cannot be located." + ) endif() endif() @@ -75,7 +76,9 @@ macro(add_gtkdoc _module _namespace _deprecated_guards _srcdirsvar _depsvar _ign if(TARGET ${opt}) set(_target_type) get_target_property(_target_type ${opt} TYPE) - if((_target_type STREQUAL "STATIC_LIBRARY") OR (_target_type STREQUAL "SHARED_LIBRARY") OR (_target_type STREQUAL "MODULE_LIBRARY")) + if((_target_type STREQUAL "STATIC_LIBRARY") OR + (_target_type STREQUAL "SHARED_LIBRARY") OR + (_target_type STREQUAL "MODULE_LIBRARY")) set(_compile_options) set(_link_libraries) @@ -113,7 +116,9 @@ macro(add_gtkdoc _module _namespace _deprecated_guards _srcdirsvar _depsvar _ign if(TARGET ${opt}) set(_target_type) get_target_property(_target_type ${opt} TYPE) - if((_target_type STREQUAL "STATIC_LIBRARY") OR (_target_type STREQUAL "SHARED_LIBRARY") OR (_target_type STREQUAL "MODULE_LIBRARY")) + if((_target_type STREQUAL "STATIC_LIBRARY") OR + (_target_type STREQUAL "SHARED_LIBRARY") OR + (_target_type STREQUAL "MODULE_LIBRARY")) set(_output_name "") get_target_property(_output_name ${opt} OUTPUT_NAME) if(NOT _output_name) @@ -142,7 +147,18 @@ macro(add_gtkdoc _module _namespace _deprecated_guards _srcdirsvar _depsvar _ign # Add it as the last, thus in-tree libs have precedence set(_scangobj_ldflags "${_scangobj_ldflags} -L${LIB_INSTALL_DIR}") - set(_scangobj_prefix ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH="${_scangobj_ld_lib_dirs}:${LIB_INSTALL_DIR}:$ENV{LD_LIBRARY_PATH}") + if(APPLE) + set(ld_lib_path "DYLD_LIBRARY_PATH=${_scangobj_ld_lib_dirs}:${LIB_INSTALL_DIR}") + if(DEFINED DYLD_LIBRARY_PATH) + set(ld_lib_path "${ld_lib_path}:$ENV{DYLD_LIBRARY_PATH}") + endif() + elseif(NOT WIN32 AND NOT WINCE) #ie. unix-like + set(ld_lib_path "LD_LIBRARY_PATH=${_scangobj_ld_lib_dirs}:${LIB_INSTALL_DIR}") + if(DEFINED LD_LIBRARY_PATH) + set(ld_lib_path "${ld_lib_path}:$ENV{LD_LIBRARY_PATH}") + endif() + endif() + set(_scangobj_prefix ${CMAKE_COMMAND} -E env "${ld_lib_path}") # if(NOT (_scangobj_cflags STREQUAL "")) # set(_scangobj_cflags --cflags "${_scangobj_cflags}") @@ -176,7 +192,11 @@ macro(add_gtkdoc _module _namespace _deprecated_guards _srcdirsvar _depsvar _ign COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/html" - COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_CURRENT_BINARY_DIR}/html" ${GTKDOC_MKHTML} --path=.. ${_module} ../${_module}-docs.sgml + COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_CURRENT_BINARY_DIR}/html" + ${GTKDOC_MKHTML} + --path=.. + ${_module} + ../${_module}-docs.sgml COMMAND ${GTKDOC_FIXXREF} --module=${_module} @@ -192,6 +212,7 @@ macro(add_gtkdoc _module _namespace _deprecated_guards _srcdirsvar _depsvar _ign add_custom_target(gtkdoc-${_module} DEPENDS html/index.html + COMMENT "Target for running gtkdoc for module" ) if(${_depsvar}) @@ -216,12 +237,14 @@ macro(add_gtkdoc _module _namespace _deprecated_guards _srcdirsvar _depsvar _ign ${GTKDOC_SCAN} --module=${_module} --deprecated-guards="${_deprecated_guards}" - --ignore-headers="${_ignore_headers}" + --ignore-headers="${${_ignoreheadersvar}}" --rebuild-sections --rebuild-types ${_srcdirs} - COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_CURRENT_BINARY_DIR}" ${_scangobj_prefix} ${GTKDOC_SCANGOBJ} + COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_CURRENT_BINARY_DIR}" + ${_scangobj_prefix} + ${GTKDOC_SCANGOBJ} --module=${_module} ${_scangobj_cflags} ${_scangobj_ldflags} @@ -235,9 +258,14 @@ macro(add_gtkdoc _module _namespace _deprecated_guards _srcdirsvar _depsvar _ign --output-format=xml ${_srcdirs} - COMMAND ${CMAKE_COMMAND} -E rename ${CMAKE_CURRENT_BINARY_DIR}/tmp/${_module}-docs.sgml ${CMAKE_CURRENT_SOURCE_DIR}/${_module}-docs.sgml.in + COMMAND ${CMAKE_COMMAND} -E rename + ${CMAKE_CURRENT_BINARY_DIR}/tmp/${_module}-docs.sgml + ${CMAKE_CURRENT_SOURCE_DIR}/${_module}-docs.sgml.in - COMMAND ${CMAKE_COMMAND} -E echo "File '${CMAKE_CURRENT_SOURCE_DIR}/${_module}-docs.sgml.in' overwritten, make sure you replace generated strings with proper content before committing." + COMMAND ${CMAKE_COMMAND} -E echo + "File '${CMAKE_CURRENT_SOURCE_DIR}/${_module}-docs.sgml.in' overwritten, " + "make sure to replace generated strings with proper content before committing." + COMMENT "Target to rebuild the sgml for the specified module" ) add_dependencies(gtkdoc-rebuild-sgmls gtkdoc-rebuild-${_module}-sgml) diff --git a/cmake/modules/LibIcalMacrosInternal.cmake b/cmake/modules/LibIcalMacrosInternal.cmake index cbea8155..acf020eb 100644 --- a/cmake/modules/LibIcalMacrosInternal.cmake +++ b/cmake/modules/LibIcalMacrosInternal.cmake @@ -1,20 +1,29 @@ # CMake support macros and functions for the libical project +# SPDX-FileCopyrightText: Allen Winter <winter@kde.org> +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 + include(CheckCCompilerFlag) include(CheckCXXCompilerFlag) +# Call option() and then add_feature_info() function(libical_option option description) set(extra_option_arguments ${ARGN}) option(${option} "${description}" ${extra_option_arguments}) add_feature_info("Option ${option}" ${option} "${description}") endfunction() +# Warn about deprecated cmake options then call libical_option function(libical_deprecated_option deprecated_option option description) set(extra_option_arguments ${ARGN}) - message(STATUS "WARNING: ${deprecated_option} is deprecated. Use ${option} instead") + if(${deprecated_option}) + message(WARNING "${deprecated_option} is deprecated. Use ${option} instead") + set(${option} ${deprecated_option} CACHE BOOL "${description}") + endif() libical_option(${option} "${description}" ${extra_option_arguments}) endfunction() +# If condition is True, append the specified value to each ARGN function(libical_append_if condition value) if(${condition}) foreach(variable ${ARGN}) @@ -23,11 +32,17 @@ function(libical_append_if condition value) endif() endfunction() +# Create a variable C_SUPPORTS_<flag> with a boolean denoting +# if the C compiler supports that flag; if so, append the flag +# to the global CMAKE_C_FLAGS variable. macro(libical_add_cflag flag name) check_c_compiler_flag("${flag}" "C_SUPPORTS_${name}") libical_append_if("C_SUPPORTS_${name}" "${flag}" CMAKE_C_FLAGS) endmacro() +# Create a variable CXX_SUPPORTS_<flag> with a boolean denoting +# if the C++ compiler supports that flag; if so, append the flag +# to the global CMAKE_CXX_FLAGS variable. macro(libical_add_cxxflag flag name) check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${name}") libical_append_if("CXX_SUPPORTS_${name}" "${flag}" CMAKE_CXX_FLAGS) |