diff options
author | Allen Winter <allen.winter@kdab.com> | 2022-06-11 11:38:24 -0400 |
---|---|---|
committer | Allen Winter <allen.winter@kdab.com> | 2022-06-11 12:59:14 -0400 |
commit | 6b74841772981be4c88dc176634bafd2e6ad7b7c (patch) | |
tree | 751d2668b557e4199dedd1d5881fd58e163b04a0 /cmake/modules/GObjectIntrospectionMacros.cmake | |
parent | 3d033a489cba309d98fb52166fbe77908f3305e7 (diff) | |
parent | a8ef3de84cc5740978a49dcf7b8eeb2cd5fc6cb8 (diff) | |
download | libical-git-flexbison.tar.gz |
Merge branch 'master' into flexbisonflexbison
Diffstat (limited to 'cmake/modules/GObjectIntrospectionMacros.cmake')
-rw-r--r-- | cmake/modules/GObjectIntrospectionMacros.cmake | 97 |
1 files changed, 63 insertions, 34 deletions
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) |