-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add dtk dbus generate function
Log: steal from qt
- Loading branch information
1 parent
f790bab
commit 1dfa31c
Showing
5 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Copyright (c) <year> <owner>. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Copyright 2005-2011 Kitware, Inc. | ||
# Copyright (C) 2022 The Qt Company Ltd. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
include(MacroAddFileDependencies) | ||
include(CMakeParseArguments) | ||
|
||
function(dtk_add_dbus_interface _sources _interface _relativename) | ||
get_filename_component(_infile ${_interface} ABSOLUTE) | ||
get_filename_component(_basepath ${_relativename} DIRECTORY) | ||
get_filename_component(_basename ${_relativename} NAME) | ||
set(_header "${CMAKE_CURRENT_BINARY_DIR}/${_relativename}.h") | ||
set(_impl "${CMAKE_CURRENT_BINARY_DIR}/${_relativename}.cpp") | ||
|
||
if(${QT_VERSION_MAJOR} EQUAL "5") | ||
if(_basepath) | ||
set(_moc "${CMAKE_CURRENT_BINARY_DIR}/${_basepath}/${_basename}.moc") | ||
else() | ||
set(_moc "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc") | ||
endif() | ||
else() | ||
if(_basepath) | ||
set(_moc "${CMAKE_CURRENT_BINARY_DIR}/${_basepath}/moc_${_basename}.cpp") | ||
else() | ||
set(_moc "${CMAKE_CURRENT_BINARY_DIR}/moc_${_basename}.cpp") | ||
endif() | ||
endif() | ||
|
||
get_source_file_property(_nonamespace ${_interface} NO_NAMESPACE) | ||
if(_nonamespace) | ||
set(_params -N -m) | ||
else() | ||
set(_params -m) | ||
endif() | ||
|
||
get_source_file_property(_classname ${_interface} CLASSNAME) | ||
if(_classname) | ||
set(_params ${_params} -c ${_classname}) | ||
endif() | ||
|
||
get_source_file_property(_include ${_interface} INCLUDE) | ||
if(_include) | ||
set(_params ${_params} -i ${_include}) | ||
endif() | ||
|
||
add_custom_command(OUTPUT "${_impl}" "${_header}" | ||
COMMAND ${DTK_XML2CPP} ${_params} -p ${_relativename} ${_infile} | ||
DEPENDS ${_infile} ${DTK_XML2CPP} | ||
VERBATIM | ||
) | ||
|
||
set_source_files_properties("${_impl}" "${_header}" PROPERTIES | ||
SKIP_AUTOMOC TRUE | ||
SKIP_AUTOUIC TRUE | ||
) | ||
|
||
qt_generate_moc("${_header}" "${_moc}") | ||
|
||
list(APPEND ${_sources} "${_impl}" "${_header}") | ||
set_property(SOURCE "${_impl}" APPEND PROPERTY OBJECT_DEPENDS "${_moc}") | ||
set(${_sources} ${${_sources}} PARENT_SCOPE) | ||
endfunction() | ||
|
||
function(dtk_add_dbus_interfaces _sources) | ||
foreach(_current_FILE ${ARGN}) | ||
get_filename_component(_infile ${_current_FILE} ABSOLUTE) | ||
get_filename_component(_basename ${_current_FILE} NAME) | ||
# get the part before the ".xml" suffix | ||
string(TOLOWER ${_basename} _basename) | ||
string(REGEX REPLACE "(.*\\.)?([^\\.]+)\\.xml" "\\2" _basename ${_basename}) | ||
dtk_add_dbus_interface(${_sources} ${_infile} ${_basename}interface) | ||
endforeach() | ||
set(${_sources} ${${_sources}} PARENT_SCOPE) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,6 @@ endif () | |
|
||
include("${CMAKE_CURRENT_LIST_DIR}/Dtk@[email protected]") | ||
include("${CMAKE_CURRENT_LIST_DIR}/Dtk@[email protected]") | ||
include("${CMAKE_CURRENT_LIST_DIR}/DtkDBusMacros.cmake") | ||
|
||
get_target_property(DTK_XML2CPP Dtk@DTK_VERSION_MAJOR@::Xml2Cpp LOCATION) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters