Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 15ff5b17 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

Properly workaround xsltproc not handling spaces in filepaths on Windows

All CMake code that executes xsltproc is wrapped to functions that
ensure that arguments passed to xsltproc are all relative paths,
thus avoiding issues with spaces in the source/build dir parent
path containing spaces, which xsltproc on Windows just does not
like.

It also simplifies some of the CMake code and moves the
kcfg_generate_dbus_interface macro into KF5AkonadiMacros
so that we don't have to have a dedicated copies (that would all
need fixing) all over KDE PIM.
parent 9268afb8
cmake_minimum_required(VERSION 3.0)
set(PIM_VERSION "5.7.80")
set(PIM_VERSION "5.7.81")
project(Akonadi VERSION ${PIM_VERSION})
......
......@@ -95,3 +95,27 @@ function(add_akonadi_isolated_test_advanced source additional_sources link_libra
LINK_LIBRARIES "${link_libraries}"
)
endfunction()
function(kcfg_generate_dbus_interface _kcfg _name)
if (NOT XSLTPROC_EXECUTABLE)
message(FATAL_ERROR "xsltproc executable not found but needed by KCFG_GENERATE_DBUS_INTERFACE()")
endif()
file(RELATIVE_PATH xsl_relpath ${CMAKE_CURRENT_BINARY_DIR} ${KF5Akonadi_DATA_DIR}/kcfg2dbus.xsl)
if (IS_ABSOLUTE ${_kcfg})
file(RELATIVE_PATH kcfg_relpath ${CMAKE_CURRENT_BINARY_DIR} ${_kcfg})
else()
file(RELATIVE_PATH kcfg_relpath ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${_kcfg})
endif()
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_name}.xml
COMMAND ${XSLTPROC_EXECUTABLE}
--output ${_name}.xml
--stringparam interfaceName ${_name}
${xsl_relpath}
${kcfg_relpath}
DEPENDS
${KF5Akonadi_DATA_DIR}/kcfg2dbus.xsl
${_kcfg}
)
endfunction()
......@@ -2,29 +2,13 @@ include_directories(
${Boost_INCLUDE_DIR}
)
include(${CMAKE_SOURCE_DIR}/KF5AkonadiMacros.cmake)
kde_enable_exceptions()
remove_definitions(-DTRANSLATION_DOMAIN=\"libakonadi5\")
add_definitions(-DTRANSLATION_DOMAIN=\"akonadi_knut_resource\")
find_package(LibXslt)
set_package_properties(LibXslt PROPERTIES DESCRIPTION "xsltproc" URL "http://xmlsoft.org/XSLT/" TYPE REQUIRED PURPOSE "Needed to generate D-Bus interface specifications")
find_program(XSLTPROC_EXECUTABLE xsltproc DOC "Path to the xsltproc executable")
# generates a D-Bus interface description from a KConfigXT file
macro(kcfg_generate_dbus_interface _kcfg _name)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_name}.xml
COMMAND ${XSLTPROC_EXECUTABLE} --stringparam interfaceName ${_name}
"${Akonadi_SOURCE_DIR}/src/core/kcfg2dbus.xsl"
"${_kcfg}"
> "${CMAKE_CURRENT_BINARY_DIR}/${_name}.xml"
DEPENDS ${Akonadi_SOURCE_DIR}/src/core/kcfg2dbus.xsl
${_kcfg}
)
endmacro()
# Disabled for now, resourcetester remained in kdepim-runtime
#add_subdirectory( tests )
......
......@@ -21,30 +21,87 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Internal server macros
function(akonadi_run_xsltproc)
if (NOT XSLTPROC_EXECUTABLE)
message(FATAL_ERROR "xsltproc executable not found but needed by AKONADI_RUN_XSLTPROC()")
endif()
set(options )
set(oneValueArgs XSL XML CLASSNAME BASENAME)
set(multiValueArgs )
cmake_parse_arguments(XSLT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (NOT XSLT_XSL)
message(FATAL_ERROR "Required argument XSL missing in AKONADI_RUN_XSLTPROC() call")
endif()
if (NOT XSLT_XML)
message(FATAL_ERROR "Required argument XML missing in AKONADI_RUN_XSLTPROC() call")
endif()
if (NOT XSLT_BASENAME)
message(FATAL_ERROR "Required argument BASENAME missing in AKONADI_RUN_XSLTPROC() call")
endif()
# Workaround xsltproc struggling with spaces in filepaths on Windows
file(RELATIVE_PATH xsl_relpath ${CMAKE_CURRENT_BINARY_DIR} ${XSLT_XSL})
file(RELATIVE_PATH xml_relpath ${CMAKE_CURRENT_BINARY_DIR} ${XSLT_XML})
set(extra_params )
if (XSLT_CLASSNAME)
set(extra_params --stringparam className ${XSLT_CLASSNAME})
endif()
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${XSLT_BASENAME}.h
${CMAKE_CURRENT_BINARY_DIR}/${XSLT_BASENAME}.cpp
COMMAND ${XSLTPROC_EXECUTABLE}
--output ${XSLT_BASENAME}.h
--stringparam code header
--stringparam fileName ${XSLT_BASENAME}
${extra_params}
${xsl_relpath}
${xml_relpath}
COMMAND ${XSLTPROC_EXECUTABLE}
--output ${XSLT_BASENAME}.cpp
--stringparam code source
--stringparam fileName ${XSLT_BASENAME}
${extra_params}
${xsl_relpath}
${xml_relpath}
DEPENDS ${XSLT_XSL}
${XSLT_XML}
)
set_property(SOURCE
${CMAKE_CURRENT_BINARY_DIR}/${XSLT_BASENAME}.cpp
${CMAKE_CURRENT_BINARY_DIR}/${XSLT_BASENAME}.h
PROPERTY SKIP_AUTOMOC TRUE
)
endfunction()
macro(akonadi_generate_schema _schemaXml _className _fileBaseName)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_fileBaseName}.h
${CMAKE_CURRENT_BINARY_DIR}/${_fileBaseName}.cpp
COMMAND ${XSLTPROC_EXECUTABLE}
--output "${CMAKE_CURRENT_BINARY_DIR}/${_fileBaseName}.h"
--stringparam code header
--stringparam className ${_className}
--stringparam fileName ${_fileBaseName}
"${Akonadi_SOURCE_DIR}/src/server/storage/schema.xsl"
"${_schemaXml}"
COMMAND ${XSLTPROC_EXECUTABLE}
--output "${CMAKE_CURRENT_BINARY_DIR}/${_fileBaseName}.cpp"
--stringparam code source
--stringparam className ${_className}
--stringparam fileName ${_fileBaseName}
"${Akonadi_SOURCE_DIR}/src/server/storage/schema.xsl"
"${_schemaXml}"
DEPENDS ${Akonadi_SOURCE_DIR}/src/server/storage/schema.xsl
${Akonadi_SOURCE_DIR}/src/server/storage/schema-header.xsl
${Akonadi_SOURCE_DIR}/src/server/storage/schema-source.xsl
${_schemaXml}
)
set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/${_fileBaseName}.cpp ${CMAKE_CURRENT_BINARY_DIR}/${_fileBaseName}.h PROPERTY SKIP_AUTOMOC TRUE)
if (NOT XSLTPROC_EXECUTABLE)
message(FATAL_ERROR "xsltproc executable not found but needed by AKONADI_GENERATE_SCHEMA()")
endif()
akonadi_run_xsltproc(
XSL ${Akonadi_SOURCE_DIR}/src/server/storage/schema.xsl
XML ${_schemaXml}
CLASSNAME ${_className}
BASENAME ${_fileBaseName}
)
endmacro()
function(akonadi_add_xmllint_test)
if (NOT XMLLINT_EXECUTABLE)
message(FATAL_ERROR "xmllint executable not found but needed by AKONADI_ADD_XMLLINT_SCHEMA()")
endif()
set(options )
set(oneValueArgs XML XSD)
set(multiValueArgs )
cmake_parse_arguments(TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
file(RELATIVE_PATH xsd_relpath ${CMAKE_CURRENT_BINARY_DIR} ${TEST_XSD})
file(RELATIVE_PATH xml_relpath ${CMAKE_CURRENT_BINARY_DIR} ${TEST_XML})
add_test(${TESTL_UNPARSED_ARGUMENTS} ${XMLLINT_EXECUTABLE} --noout --schema ${xsd_relpath} ${xml_relpath})
endfunction()
# 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 copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
#
# Find xsltproc executable and provide a macro to generate D-Bus interfaces.
#
# The following variables are defined :
# XSLTPROC_EXECUTABLE - path to the xsltproc executable
# Xsltproc_FOUND - true if the program was found
#
find_program(XSLTPROC_EXECUTABLE xsltproc DOC "Path to the xsltproc executable")
mark_as_advanced(XSLTPROC_EXECUTABLE)
if(XSLTPROC_EXECUTABLE)
set(Xsltproc_FOUND TRUE)
# Macro to generate a D-Bus interface description from a KConfigXT file
macro(kcfg_generate_dbus_interface _kcfg _name)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_name}.xml
COMMAND ${XSLTPROC_EXECUTABLE} --stringparam interfaceName ${_name}
${CMAKE_SOURCE_DIR}/akonadi/kcfg2dbus.xsl
${_kcfg}
> ${CMAKE_CURRENT_BINARY_DIR}/${_name}.xml
DEPENDS ${CMAKE_SOURCE_DIR}/akonadi/kcfg2dbus.xsl
${_kcfg}
)
endmacro()
endif()
......@@ -10,34 +10,31 @@ if(POSTGRES_PATH)
endif()
########### next target ###############
set(AKONADI_DB_SCHEMA "${CMAKE_CURRENT_SOURCE_DIR}/storage/akonadidb.xml")
set(AKONADI_DB_SCHEME "${CMAKE_CURRENT_SOURCE_DIR}/storage/akonadidb.xml")
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/entities.h
${CMAKE_CURRENT_BINARY_DIR}/entities.cpp
COMMAND "${XSLTPROC_EXECUTABLE}"
--output "${CMAKE_CURRENT_BINARY_DIR}/entities.h"
--stringparam code header
"${CMAKE_CURRENT_SOURCE_DIR}/storage/entities.xsl"
"${AKONADI_DB_SCHEME}"
COMMAND "${XSLTPROC_EXECUTABLE}"
--output "${CMAKE_CURRENT_BINARY_DIR}/entities.cpp"
--stringparam code source
"${CMAKE_CURRENT_SOURCE_DIR}/storage/entities.xsl"
"${AKONADI_DB_SCHEME}"
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/storage/entities.xsl
${CMAKE_CURRENT_SOURCE_DIR}/storage/entities-header.xsl
${CMAKE_CURRENT_SOURCE_DIR}/storage/entities-source.xsl
${AKONADI_DB_SCHEME}
akonadi_run_xsltproc(
XSL ${CMAKE_CURRENT_SOURCE_DIR}/storage/entities.xsl
XML ${AKONADI_DB_SCHEMA}
BASENAME entities
)
set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/entities.cpp PROPERTY SKIP_AUTOMOC TRUE)
add_test(akonadidb-xmllint ${XMLLINT_EXECUTABLE} --noout --schema ${CMAKE_CURRENT_SOURCE_DIR}/storage/akonadidb.xsd ${CMAKE_CURRENT_SOURCE_DIR}/storage/akonadidb.xml)
add_test(akonadidbupdate-xmllint ${XMLLINT_EXECUTABLE} --noout --schema ${CMAKE_CURRENT_SOURCE_DIR}/storage/dbupdate.xsd ${CMAKE_CURRENT_SOURCE_DIR}/storage/dbupdate.xml)
akonadi_run_xsltproc(
XSL ${Akonadi_SOURCE_DIR}/src/server/storage/schema.xsl
XML ${AKONADI_DB_SCHEMA}
CLASSNAME AkonadiSchema
BASENAME akonadischema
)
akonadi_generate_schema(${AKONADI_DB_SCHEME} AkonadiSchema akonadischema)
akonadi_add_xmllint_test(
akonadidb-xmllint
XSD ${CMAKE_CURRENT_SOURCE_DIR}/storage/akonadidb.xsd
XML ${AKONADI_DB_SCHEMA}
)
akonadi_add_xmllint_test(
akonadidbupdate-xmllint
XSD ${CMAKE_CURRENT_SOURCE_DIR}/storage/akonadidb.xsd
XML ${AKONADI_DB_SCHEMA}
)
set(libakonadiserver_SRCS
akonadi.cpp
......
......@@ -23,12 +23,10 @@ find_package(KF5Config ${KF5_MIN_VERSION} CONFIG REQUIRED)
set(AKONADI_MIN_VERSION "5.2")
find_package(KF5Akonadi ${AKONADI_MIN_VERSION} CONFIG REQUIRED)
find_package(Xsltproc REQUIRED)
set_package_properties(Xsltproc PROPERTIES
DESCRIPTION "XSLT processor from libxslt"
TYPE REQUIRED
PURPOSE "Required to generate a D-Bus interface for the resource."
)
find_program(XSLTPROC_EXECUTABLE xsltproc DOC "Path to the xsltproc executable")
if (NOT XSLTPROC_EXECUTABLE)
message(FATAL_ERROR "\nThe command line XSLT processor program 'xsltproc' could not be found.\nPlease install xsltproc.\n")
endif()
add_subdirectory(src)
......
# Find xsltproc executable and provide a macro to generate D-Bus interfaces.
#
# The following variables are defined :
# XSLTPROC_EXECUTABLE - path to the xsltproc executable
# Xsltproc_FOUND - true if the program was found
find_program(XSLTPROC_EXECUTABLE xsltproc DOC "Path to the xsltproc executable")
mark_as_advanced(XSLTPROC_EXECUTABLE)
if(XSLTPROC_EXECUTABLE)
set(Xsltproc_FOUND TRUE)
# We depend on Akonadi, make sure it's found
if(NOT DEFINED KF5Akonadi_DATA_DIR)
find_package(KF5Akonadi REQUIRED)
endif()
# Macro to generate a D-Bus interface description from a KConfigXT file
macro(kcfg_generate_dbus_interface _kcfg _name)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_name}.xml
COMMAND ${XSLTPROC_EXECUTABLE}
--stringparam interfaceName ${_name}
${KF5Akonadi_DATA_DIR}/kcfg2dbus.xsl
${_kcfg}
> ${CMAKE_CURRENT_BINARY_DIR}/${_name}.xml
DEPENDS
${KF5Akonadi_DATA_DIR}/kcfg2dbus.xsl
${_kcfg}
)
endmacro()
endif()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment