2019-05-13 00:59:14 +00:00
|
|
|
# Copyright (c) 2015-2019, Ivailo Monev, <xakepa10@gmail.com>
|
2015-12-10 05:06:13 +02:00
|
|
|
# Redistribution and use is allowed according to the terms of the BSD license.
|
|
|
|
|
|
|
|
macro(KATIE_RESOURCES RESOURCES)
|
|
|
|
foreach(tmpres ${RESOURCES} ${ARGN})
|
|
|
|
get_filename_component(resource ${tmpres} ABSOLUTE)
|
|
|
|
get_source_file_property(skip ${resource} SKIP_RESOURCE)
|
2015-12-16 02:59:15 +02:00
|
|
|
if(NOT skip)
|
2015-12-10 18:38:44 +02:00
|
|
|
get_filename_component(rscext ${resource} EXT)
|
|
|
|
get_filename_component(rscname ${resource} NAME_WE)
|
|
|
|
get_filename_component(rscpath ${resource} PATH)
|
|
|
|
string(REPLACE "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" rscpath "${rscpath}")
|
|
|
|
if("${rscext}" STREQUAL ".ui")
|
2019-05-13 00:59:14 +00:00
|
|
|
set(rscout "${rscpath}/ui_${rscname}.h")
|
2016-09-21 16:10:33 +00:00
|
|
|
make_directory(${rscpath})
|
2019-05-30 12:39:35 +00:00
|
|
|
include_directories(${rscpath})
|
2015-12-10 18:38:44 +02:00
|
|
|
add_custom_command(
|
|
|
|
COMMAND ${KATIE_UIC} "${resource}" -o "${rscout}"
|
2016-10-11 23:16:20 +00:00
|
|
|
OUTPUT "${rscout}"
|
2015-12-10 18:38:44 +02:00
|
|
|
MAIN_DEPENDENCY ${resource}
|
|
|
|
)
|
|
|
|
elseif("${rscext}" STREQUAL ".qrc")
|
2019-05-13 00:59:14 +00:00
|
|
|
set(rscout "${rscpath}/qrc_${rscname}.cpp")
|
2016-09-21 16:10:33 +00:00
|
|
|
make_directory(${rscpath})
|
2019-05-30 12:39:35 +00:00
|
|
|
include_directories(${rscpath})
|
2015-12-10 18:38:44 +02:00
|
|
|
add_custom_command(
|
|
|
|
COMMAND ${KATIE_RCC} "${resource}" -o "${rscout}" -name "${rscname}"
|
2016-10-11 23:16:20 +00:00
|
|
|
OUTPUT "${rscout}"
|
2015-12-10 18:38:44 +02:00
|
|
|
MAIN_DEPENDENCY ${resource}
|
|
|
|
)
|
|
|
|
set_property(SOURCE ${resource} APPEND PROPERTY OBJECT_DEPENDS ${rscout})
|
2019-05-13 00:59:14 +00:00
|
|
|
elseif("${rscext}" MATCHES "(.h|.hpp|.cc|.cpp)")
|
2016-07-12 01:54:49 +00:00
|
|
|
file(READ "${resource}" rsccontent)
|
|
|
|
# this can be simpler if continue() was supported by old CMake versions
|
|
|
|
if("${rsccontent}" MATCHES "(Q_OBJECT|Q_OBJECT_FAKE|Q_GADGET)")
|
2019-05-13 00:59:14 +00:00
|
|
|
set(rscout "${rscpath}/moc_${rscname}${rscext}")
|
2016-07-12 01:54:49 +00:00
|
|
|
get_directory_property(dirdefs COMPILE_DEFINITIONS)
|
|
|
|
get_directory_property(dirincs INCLUDE_DIRECTORIES)
|
|
|
|
set(mocargs)
|
|
|
|
foreach(ddef ${dirdefs})
|
|
|
|
# TODO: filter non -D, support -U too
|
|
|
|
set(mocargs ${mocargs} -D${ddef})
|
|
|
|
endforeach()
|
|
|
|
foreach(incdir ${dirincs})
|
|
|
|
set(mocargs ${mocargs} -I${incdir})
|
|
|
|
endforeach()
|
2016-09-21 16:10:33 +00:00
|
|
|
make_directory(${rscpath})
|
2019-05-30 12:39:35 +00:00
|
|
|
include_directories(${rscpath})
|
2016-07-12 01:54:49 +00:00
|
|
|
add_custom_command(
|
|
|
|
COMMAND ${KATIE_MOC} -nw "${resource}" -o "${rscout}" ${mocargs}
|
2016-10-11 23:16:20 +00:00
|
|
|
OUTPUT "${rscout}"
|
2016-07-12 01:54:49 +00:00
|
|
|
)
|
|
|
|
set_property(SOURCE ${resource} APPEND PROPERTY OBJECT_DEPENDS ${rscout})
|
|
|
|
endif()
|
2015-12-10 18:38:44 +02:00
|
|
|
endif()
|
2015-12-10 05:06:13 +02:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endmacro()
|
|
|
|
|
2016-02-01 15:26:26 +02:00
|
|
|
macro(KATIE_DBUS_ADAPTOR SRCDEP SRCIN OUTNAME)
|
2015-12-10 05:06:13 +02:00
|
|
|
get_filename_component(resource ${SRCIN} ABSOLUTE)
|
2019-05-13 00:59:14 +00:00
|
|
|
set(rscout "${CMAKE_CURRENT_BINARY_DIR}/${OUTNAME}.h")
|
|
|
|
set(mocout "${CMAKE_CURRENT_BINARY_DIR}/${OUTNAME}.moc")
|
2015-12-10 05:06:13 +02:00
|
|
|
add_custom_command(
|
2016-02-01 15:26:26 +02:00
|
|
|
COMMAND "${KATIE_QDBUSXML2CPP}" -m "${resource}" -a "${rscout}" -p "${OUTNAME}" ${ARGN}
|
2015-12-10 05:06:13 +02:00
|
|
|
COMMAND "${KATIE_MOC}" -nw "${rscout}" -o "${mocout}" -i
|
2016-10-12 05:11:29 +00:00
|
|
|
OUTPUT "${rscout}"
|
2015-12-10 05:06:13 +02:00
|
|
|
)
|
|
|
|
set_property(SOURCE ${SRCDEP} APPEND PROPERTY OBJECT_DEPENDS ${rscout})
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
macro(KATIE_DBUS_INTERFACE SRCIN)
|
2016-02-01 15:26:26 +02:00
|
|
|
string(REGEX MATCH ".*\\.(.*)\\.xml" ${SRCIN} OUTNAME)
|
2015-12-10 05:06:13 +02:00
|
|
|
string(TOLOWER ${SRCIN} SRCIN)
|
2019-05-13 00:59:14 +00:00
|
|
|
set(rscout "${CMAKE_CURRENT_BINARY_DIR}/${OUTNAME}interface.h")
|
2015-12-10 05:06:13 +02:00
|
|
|
add_custom_command(
|
2019-05-13 00:59:14 +00:00
|
|
|
COMMAND "${KATIE_QDBUSXML2CPP}" -m "${SRCIN}" -a "${rscout}" -p "${OUTNAME}interface" ${ARGN}
|
2016-10-12 05:11:29 +00:00
|
|
|
OUTPUT "${rscout}"
|
2015-12-10 05:06:13 +02:00
|
|
|
)
|
|
|
|
set_property(SOURCE ${SRCIN} APPEND PROPERTY OBJECT_DEPENDS ${rscout})
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
macro(KATIE_TRANSLATIONS TRANSLATIONS)
|
2016-10-07 23:43:48 +00:00
|
|
|
if(NOT KATIE_TRANSLATIONS_RELATIVE)
|
2015-12-10 05:06:13 +02:00
|
|
|
message(SEND_ERROR "Directory where the translation should be installed is not set")
|
|
|
|
endif()
|
|
|
|
foreach(translation ${TRANSLATIONS} ${ARGN})
|
|
|
|
get_filename_component(trname ${translation} NAME_WE)
|
|
|
|
get_filename_component(trdir ${translation} DIRECTORY)
|
|
|
|
string(REPLACE "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" trdir ${trdir})
|
|
|
|
make_directory(${trdir})
|
2019-05-13 00:59:14 +00:00
|
|
|
set(trout "${trdir}/${trname}.qm")
|
2015-12-10 05:06:13 +02:00
|
|
|
add_custom_target(
|
|
|
|
${trname}_translation ALL
|
|
|
|
COMMAND "${KATIE_LRELEASE}" "${translation}" -qm "${trout}"
|
|
|
|
)
|
2016-10-12 04:57:00 +00:00
|
|
|
set_source_files_properties(${trout} PROPERTIES GENERATED TRUE)
|
2016-10-07 23:43:48 +00:00
|
|
|
install(FILES ${trout} DESTINATION ${KATIE_TRANSLATIONS_RELATIVE})
|
2015-12-10 05:06:13 +02:00
|
|
|
endforeach()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
macro(KATIE_DEFINITION DEF)
|
2015-12-15 18:15:10 +02:00
|
|
|
set(KATIE_DEFINITIONS ${KATIE_DEFINITIONS} ${DEF} ${ARGN})
|
2015-12-10 05:06:13 +02:00
|
|
|
add_definitions(${DEF} ${ARGN})
|
|
|
|
endmacro()
|