Changeset View
Changeset View
Standalone View
Standalone View
KF5ConfigMacros.cmake
1 | # KCONFIG_ADD_KCFG_FILES (SRCS_VAR [GENERATE_MOC] [USE_RELATIVE_PATH] file1.kcfgc ... fileN.kcfgc) | 1 | # KCONFIG_ADD_KCFG_FILES (SRCS_VAR [GENERATE_MOC] [USE_RELATIVE_PATH] file1.kcfgc ... fileN.kcfgc) | ||
---|---|---|---|---|---|
2 | # KCONFIG_ADD_KCFG_FILES (<target> [GENERATE_MOC] [USE_RELATIVE_PATH] file1.kcfgc ... fileN.kcfgc) | ||||
2 | # Use this to add KDE config compiler files to your application/library. | 3 | # Use this to add KDE config compiler files to your application/library. | ||
3 | # Use optional GENERATE_MOC to generate moc if you use signals in your kcfg files. | 4 | # Use optional GENERATE_MOC to generate moc if you use signals in your kcfg files. | ||
4 | # Use optional USE_RELATIVE_PATH to generate the classes in the build following the given | 5 | # Use optional USE_RELATIVE_PATH to generate the classes in the build following the given | ||
5 | # relative path to the file. | 6 | # relative path to the file. | ||
6 | # | 7 | # | ||
7 | # Copyright (c) 2006-2009 Alexander Neundorf, <neundorf@kde.org> | 8 | # Copyright (c) 2006-2009 Alexander Neundorf, <neundorf@kde.org> | ||
8 | # Copyright (c) 2006, 2007, Laurent Montel, <montel@kde.org> | 9 | # Copyright (c) 2006, 2007, Laurent Montel, <montel@kde.org> | ||
9 | # Copyright (c) 2007 Matthias Kretz <kretz@kde.org> | 10 | # Copyright (c) 2007 Matthias Kretz <kretz@kde.org> | ||
Show All 17 Lines | |||||
27 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 28 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
28 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 29 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
29 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 30 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
30 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 31 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
31 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 32 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
32 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 33 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
33 | # SUCH DAMAGE. | 34 | # SUCH DAMAGE. | ||
34 | 35 | | |||
35 | function (KCONFIG_ADD_KCFG_FILES _sources ) | 36 | function (KCONFIG_ADD_KCFG_FILES _target_or_source_var) | ||
kossebau: I propose to rename `_sources` to `_target_or_source_var` to make the code less surprising. | |||||
36 | set(options GENERATE_MOC USE_RELATIVE_PATH) | 37 | set(options GENERATE_MOC USE_RELATIVE_PATH) | ||
37 | cmake_parse_arguments(ARG "${options}" "" "" ${ARGN}) | 38 | cmake_parse_arguments(ARG "${options}" "" "" ${ARGN}) | ||
38 | 39 | | |||
39 | set(sources) | 40 | set(sources) | ||
40 | foreach (_current_FILE ${ARG_UNPARSED_ARGUMENTS}) | 41 | foreach (_current_FILE ${ARG_UNPARSED_ARGUMENTS}) | ||
41 | get_filename_component(_tmp_FILE ${_current_FILE} ABSOLUTE) | 42 | get_filename_component(_tmp_FILE ${_current_FILE} ABSOLUTE) | ||
42 | get_filename_component(_abs_PATH ${_tmp_FILE} PATH) | 43 | get_filename_component(_abs_PATH ${_tmp_FILE} PATH) | ||
43 | 44 | | |||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Line(s) | 122 | if(ARG_GENERATE_MOC) | |||
122 | list(APPEND sources ${_moc_FILE}) | 123 | list(APPEND sources ${_moc_FILE}) | ||
123 | qt5_generate_moc(${_header_FILE} ${_moc_FILE}) | 124 | qt5_generate_moc(${_header_FILE} ${_moc_FILE}) | ||
124 | set_property(SOURCE ${_src_FILE} APPEND PROPERTY OBJECT_DEPENDS ${_moc_FILE} ) | 125 | set_property(SOURCE ${_src_FILE} APPEND PROPERTY OBJECT_DEPENDS ${_moc_FILE} ) | ||
125 | endif() | 126 | endif() | ||
126 | 127 | | |||
127 | list(APPEND sources ${_src_FILE} ${_header_FILE}) | 128 | list(APPEND sources ${_src_FILE} ${_header_FILE}) | ||
128 | endforeach (_current_FILE) | 129 | endforeach (_current_FILE) | ||
129 | 130 | | |||
130 | set(${_sources} ${${_sources}} ${sources} PARENT_SCOPE) | 131 | if (TARGET ${_target_or_source_var}) | ||
132 | target_sources(${_target_or_source_var} PRIVATE ${sources}) | ||||
133 | else() | ||||
134 | set(${_target_or_source_var} ${${_target_or_source_var}} ${sources} PARENT_SCOPE) | ||||
135 | endif() | ||||
131 | 136 | | |||
132 | endfunction(KCONFIG_ADD_KCFG_FILES) | 137 | endfunction(KCONFIG_ADD_KCFG_FILES) |
I propose to rename _sources to _target_or_source_var to make the code less surprising.