Looks good. ACK.
Btw. It looks like some configure checks are missing:
../lib/libmcommon_dbus.so.0.0.1: undefined reference to
`polkit_authority_get_sync'
Has the polkit API changed recently?
Can we also have DBus support default to "try"?
Ie. only fail during configure if all the dbus pieces aren't available
_and_ it was explicitly requested.
I'll do the same for QMF.
On Mon, May 2, 2011 at 9:47 AM, Radek Novacek <rnovacek(a)redhat.com> wrote:
* MatahariDBusMacros.cmake was renamed to MatahariMacros.cmake.
* generate_dbus_interface macro added for xsl transformation from
QMF schema to DBus interface XML
* generate_qmf_schemas macro for generating QMF files using qmfgen.
Signed-off-by: Radek Novacek <rnovacek(a)redhat.com>
---
src/CMakeLists.txt | 43 +++------------
src/cmake/modules/MatahariDBusMacros.cmake | 28 ----------
src/cmake/modules/MatahariMacros.cmake | 82
++++++++++++++++++++++++++++
src/host/CMakeLists.txt | 1 -
src/network/CMakeLists.txt | 1 -
src/service/CMakeLists.txt | 1 -
6 files changed, 89 insertions(+), 67 deletions(-)
delete mode 100644 src/cmake/modules/MatahariDBusMacros.cmake
create mode 100644 src/cmake/modules/MatahariMacros.cmake
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d3b49a7..18bc6df 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -72,11 +72,14 @@ if(NOT glib_FOUND)
endif(NOT glib_FOUND)
include_directories(${glib_INCLUDE_DIRS})
+# Include QMF and DBus generation macros
+include(MatahariMacros)
+
## dbus
if(WITH-DBUS)
pkg_check_modules(dbus-glib REQUIRED dbus-glib-1)
pkg_check_modules(polkit REQUIRED polkit-gobject-1)
-
+
if(NOT dbus-glib_FOUND)
message(FATAL_ERROR "dbus-glib headers/libraries not found.")
endif(NOT dbus-glib_FOUND)
@@ -86,12 +89,7 @@ if(WITH-DBUS)
endif(NOT polkit_FOUND)
# Create src/dbus directory and generate DBus XML definition files into
it
- execute_process(COMMAND mkdir -p src/dbus)
- find_file(XSLTPROC xsltproc)
- execute_process(
- COMMAND ${XSLTPROC} ${CMAKE_CURRENT_SOURCE_DIR}/schema-to-dbus.xsl
${CMAKE_CURRENT_SOURCE_DIR}/schema.xml
- WORKING_DIRECTORY src/dbus
- )
+ generate_dbus_interface(${SCHEMAS})
endif(WITH-DBUS)
## qpid
@@ -108,34 +106,7 @@ if(WITH-QMF)
message(FATAL_ERROR "QPID library not found.")
endif(QPID-NOTFOUND)
- # string(REGEX REPLACE "\\." "" QPID_VERSION ${QPID_VERSION})
-
- # message("Building against: ${QPID_VERSION_LONG} (${QPID_VERSION} )")
- # add_definitions(-DQPID_VERSION=${QPID_VERSION})
-
- set(regen_schema OFF)
- message(STATUS "Regenerating QMF schemas: ${SCHEMAS}")
- foreach (schema_file ${SCHEMAS} ${QMFGEN})
- foreach (file ${SCHEMA_SOURCES})
- if (EXISTS ${file})
- if (${schema_file} IS_NEWER_THAN ${file})
- set(regen_schema ON)
- message("${schema_file} is newer than ${file}")
- endif (${schema_file} IS_NEWER_THAN ${file})
- else (EXISTS ${file})
- set(regen_schema ON)
- endif (EXISTS ${file})
- endforeach (file ${SCHEMA_SOURCES})
- endforeach (schema_file ${SCHEMAS})
-
- if (regen_schema)
- # Regenerate everything
- execute_process(COMMAND rm -f ${SCHEMA_SOURCES})
- execute_process(COMMAND ${QMFGEN} -2 -o ./qmf ${SCHEMAS}
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
- else (regen_schema)
- message(STATUS "No need to generate QMF schema")
- endif (regen_schema)
+ generate_qmf_schemas(${SCHEMAS} ${SCHEMA_SOURCES})
endif(WITH-QMF)
@@ -149,6 +120,7 @@ add_subdirectory(service)
install(FILES ${SCHEMAS} DESTINATION share/matahari)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/matahari.h DESTINATION
include)
install(FILES cmake/modules/FindMatahari.cmake DESTINATION
share/cmake/Modules)
+install(FILES cmake/modules/MatahariMacros.cmake DESTINATION
share/cmake/Modules)
if(WITH-QMF)
install(FILES cmake/modules/FindQPID.cmake DESTINATION
share/cmake/Modules)
@@ -159,5 +131,4 @@ if(WITH-DBUS)
install(FILES schema-to-dbus.xsl DESTINATION share/matahari)
install(FILES include/matahari/mh_dbus_common.h DESTINATION
include/matahari)
install(FILES include/matahari/mh_gobject_class.h DESTINATION
include/matahari)
- install(FILES cmake/modules/MatahariDBusMacros.cmake DESTINATION
share/cmake/Modules)
endif(WITH-DBUS)
diff --git a/src/cmake/modules/MatahariDBusMacros.cmake
b/src/cmake/modules/MatahariDBusMacros.cmake
deleted file mode 100644
index a9e16f7..0000000
--- a/src/cmake/modules/MatahariDBusMacros.cmake
+++ /dev/null
@@ -1,28 +0,0 @@
-# Generator for files specific to DBus interface
-
-# This macro takes name of the API and then creates two files
-# matahari-${API}-dbus-glue.h and matahari-${API}-dbus-properties.h
-# First one contains gobject definition generated by dbus-binding-tool
-# Second one is definition of properties of the object
-
-macro(generate_dbus_headers API XML)
- find_file(XSLTPROC xsltproc)
- find_file(BIND_TOOL dbus-binding-tool)
-
- # Convert dbus interface to glue and properties files
- add_custom_command(
- OUTPUT ${API}-dbus-glue.h
- COMMAND ${BIND_TOOL} --prefix=matahari --mode=glib-server
- --output=${API}-dbus-glue.h
- ${XML}
- COMMENT "Generating ${API}-dbus-glue.h"
- )
-
- add_custom_command(
- OUTPUT ${API}-dbus-properties.h
- COMMAND ${XSLTPROC} --output ${API}-dbus-properties.h
- ${CMAKE_CURRENT_SOURCE_DIR}/../dbus-to-c.xsl
- ${XML}
- COMMENT "Generating ${API}-dbus-properties.h"
- )
-endmacro(generate_dbus_headers)
diff --git a/src/cmake/modules/MatahariMacros.cmake
b/src/cmake/modules/MatahariMacros.cmake
new file mode 100644
index 0000000..3c5a428
--- /dev/null
+++ b/src/cmake/modules/MatahariMacros.cmake
@@ -0,0 +1,82 @@
+# Generator for files specific to DBus interface
+
+# This macro takes name of the API and then creates two files
+# matahari-${API}-dbus-glue.h and matahari-${API}-dbus-properties.h
+# First one contains gobject definition generated by dbus-binding-tool
+# Second one is definition of properties of the object
+macro(generate_dbus_headers API XML)
+ find_file(XSLTPROC xsltproc)
+ find_file(BIND_TOOL dbus-binding-tool)
+
+ # Convert dbus interface to glue and properties files
+ add_custom_command(
+ OUTPUT ${API}-dbus-glue.h
+ COMMAND ${BIND_TOOL} --prefix=matahari --mode=glib-server
+ --output=${API}-dbus-glue.h
+ ${XML}
+ COMMENT "Generating ${API}-dbus-glue.h"
+ )
+
+ add_custom_command(
+ OUTPUT ${API}-dbus-properties.h
+ COMMAND ${XSLTPROC} --output ${API}-dbus-properties.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../dbus-to-c.xsl
+ ${XML}
+ COMMENT "Generating ${API}-dbus-properties.h"
+ )
+endmacro(generate_dbus_headers)
+
+# This macro will transform QMF interface XML to DBus interface XML file
+# Arguments SCHEMAS - paths to XML schema files
+macro(generate_dbus_interface SCHEMAS)
+ find_file(SCHEMA_TO_DBUS schema-to-dbus.xsl
+ ${CMAKE_CURRENT_SOURCE_DIR} /usr/share/matahari)
+ find_file(XSLTPROC xsltproc)
+ # Create dbus subdirectory
+ execute_process(COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/dbus)
+ foreach(SCHEMA ${SCHEMAS})
+ # Generate files for each schema
+ execute_process(
+ COMMAND ${XSLTPROC} ${SCHEMA_TO_DBUS} ${SCHEMA}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/dbus
+ )
+ endforeach(SCHEMA ${SCHEMAS})
+endmacro(generate_dbus_interface)
+
+# This macro will generate QMF definition files from QMF schema
+# Argument SCHEMAS - paths to XML schema files
+# Variable SCHEMA_SOURCES - list of generated cpp files (it can be added
+# to add_executable command for proper compliation)
+macro(generate_qmf_schemas SCHEMAS SCHEMA_SOURCES)
+ message(STATUS "Regenerating QMF schemas: ${SCHEMAS}")
+ set(regen_schema OFF)
+
+ if (SCHEMA_SOURCES)
+ # There are some already generated files, check if they
+ # need to be regenerated
+ foreach (schema_file ${SCHEMAS})
+ foreach (file ${SCHEMA_SOURCES})
+ if (EXISTS ${file})
+ if (${schema_file} IS_NEWER_THAN ${file})
+ set(regen_schema ON)
+ message("${schema_file} is newer than ${file}")
+ endif (${schema_file} IS_NEWER_THAN ${file})
+ else (EXISTS ${file})
+ set(regen_schema ON)
+ endif (EXISTS ${file})
+ endforeach (file ${SCHEMA_SOURCES})
+ endforeach (schema_file ${SCHEMAS})
+ else (SCHEMA_SOURCES)
+ # No already generated files => generate them
+ set(regen_schema ON)
+ endif (SCHEMA_SOURCES)
+
+ if (regen_schema)
+ # Regenerate everything
+ execute_process(COMMAND rm -f ${SCHEMA_SOURCES})
+ execute_process(COMMAND ${QMFGEN} -2 -o ./qmf ${SCHEMAS}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+ else (regen_schema)
+ message(STATUS "No need to generate QMF schema")
+ endif (regen_schema)
+endmacro(generate_qmf_schemas)
diff --git a/src/host/CMakeLists.txt b/src/host/CMakeLists.txt
index 30c3b15..d9b5513 100644
--- a/src/host/CMakeLists.txt
+++ b/src/host/CMakeLists.txt
@@ -24,7 +24,6 @@ endif(WITH-QMF)
# DBus daemon
if(WITH-DBUS)
# Auto-generated stuff
- include(MatahariDBusMacros)
generate_dbus_headers(${BASE}
${CMAKE_BINARY_DIR}/src/dbus/org.matahariproject.Host.xml)
# Must be included to find matahari-API-dbus-properties.h
include_directories(${CMAKE_CURRENT_BINARY_DIR})
diff --git a/src/network/CMakeLists.txt b/src/network/CMakeLists.txt
index a26eac1..020358f 100644
--- a/src/network/CMakeLists.txt
+++ b/src/network/CMakeLists.txt
@@ -24,7 +24,6 @@ endif(WITH-QMF)
# DBus daemon
if(WITH-DBUS)
# Auto-generated stuff
- include(MatahariDBusMacros)
generate_dbus_headers(${BASE}
${CMAKE_BINARY_DIR}/src/dbus/org.matahariproject.Network.xml)
# Must be included to find API-dbus-properties.h
include_directories(${CMAKE_CURRENT_BINARY_DIR})
diff --git a/src/service/CMakeLists.txt b/src/service/CMakeLists.txt
index 44d70cd..c61b7c8 100644
--- a/src/service/CMakeLists.txt
+++ b/src/service/CMakeLists.txt
@@ -24,7 +24,6 @@ endif(WITH-QMF)
# DBus daemon
if(WITH-DBUS)
# Auto-generated stuff
- include(MatahariDBusMacros)
generate_dbus_headers(${BASE}
${CMAKE_BINARY_DIR}/src/dbus/org.matahariproject.Services.xml)
# Must be included to find matahari-API-dbus-properties.h
include_directories(${CMAKE_CURRENT_BINARY_DIR})
--
1.7.4.4
_______________________________________________
Matahari mailing list
Matahari(a)lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/matahari