Warning, /frameworks/solid/cmake/SolidBackendsMacros.cmake is written in an unsupported language. File is not indexed.
0001 # Helper macros for dealing with device backends. 0002 0003 # SPDX-FileCopyrightText: 2019 Pino Toscano <pino@kde.org> 0004 # 0005 # SPDX-License-Identifier: BSD-3-Clause 0006 0007 # "Begin" the device backends addition, to be called *before* all the order 0008 # add_device_backend* macros 0009 macro(add_device_backends_begin) 0010 set(ENABLED_DEVICE_BACKENDS) 0011 endmacro() 0012 0013 # Macro to add a new device backend; a new cmake option is automatically added 0014 # to disable the build of that backend, available as 0015 # BUILD_DEVICE_BACKEND_$name. 0016 macro(add_device_backend backend) 0017 _add_device_backend(${backend} "${CMAKE_CURRENT_SOURCE_DIR}") 0018 endmacro() 0019 0020 # Internal implementation of add_device_backend, mostly to pass the right 0021 # source directory (in case of a function is the file containing that 0022 # function). 0023 function(_add_device_backend backend source_dir) 0024 set(cmakelists_path "${source_dir}/src/solid/devices/backends/${backend}/CMakeLists.txt") 0025 if(NOT (EXISTS "${cmakelists_path}")) 0026 message(FATAL_ERROR "Missing CMakeLists.txt for backend ${backend}") 0027 endif() 0028 0029 option(BUILD_DEVICE_BACKEND_${backend} "Build the backend ${backend}" ON) 0030 if(NOT BUILD_DEVICE_BACKEND_${backend}) 0031 return() 0032 endif() 0033 0034 set(backends ${ENABLED_DEVICE_BACKENDS}) 0035 list(APPEND backends ${backend}) 0036 set(ENABLED_DEVICE_BACKENDS ${backends} PARENT_SCOPE) 0037 endfunction() 0038 0039 # After all the add_device_backend()s are called, create all the cmake 0040 # material: 0041 # - the BUILD_DEVICE_BACKEND_$name cmake variables, used to conditionally 0042 # add stuff depending whether a backend is built 0043 # - a feature info, to show that that backend was enabled 0044 macro(add_device_backends_cmake) 0045 foreach(backend ${ENABLED_DEVICE_BACKENDS}) 0046 set(BUILD_DEVICE_BACKEND_${backend} TRUE) 0047 add_feature_info(${backend} TRUE "Solid device '${backend}' backend.") 0048 endforeach() 0049 endmacro() 0050 0051 # After all the add_device_backend()s are called, create/collect all the 0052 # material used for the build: 0053 # - create a config-backends.h file in the current binary directory, with 0054 # BUILD_DEVICE_BACKEND_$name defines for all the built backends 0055 # - fill the sources_var, and libs_var variables resp. with the sources, 0056 # and the libraries needed for all the built backends 0057 macro(add_device_backends_build base_backends_dir sources_var libs_var) 0058 foreach(backend ${ENABLED_DEVICE_BACKENDS}) 0059 string(APPEND config_backends_output "#define BUILD_DEVICE_BACKEND_${backend} 1\n") 0060 unset(backend_sources) 0061 unset(backend_libs) 0062 include("${base_backends_dir}/${backend}/CMakeLists.txt") 0063 foreach(source ${backend_sources}) 0064 if(NOT (IS_ABSOLUTE ${source})) 0065 set(source "${base_backends_dir}/${backend}/${source}") 0066 endif() 0067 list(APPEND ${sources_var} "${source}") 0068 endforeach() 0069 list(APPEND ${libs_var} ${backend_libs}) 0070 endforeach() 0071 file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/config-backends-tmp.h" "${config_backends_output}") 0072 configure_file("${CMAKE_CURRENT_BINARY_DIR}/config-backends-tmp.h" 0073 "${CMAKE_CURRENT_BINARY_DIR}/config-backends.h" COPYONLY) 0074 set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/config-backends-tmp.h" 0075 "${CMAKE_CURRENT_BINARY_DIR}/config-backends.h" 0076 PROPERTIES SKIP_AUTOGEN TRUE) 0077 endmacro()