[poppler] 4 commits - CMakeLists.txt cmake/modules glib/CMakeLists.txt Makefile.am
Pino Toscano
pino at kemper.freedesktop.org
Sat Jul 17 13:06:09 PDT 2010
CMakeLists.txt | 5 -
Makefile.am | 2
cmake/modules/FindGObjectIntrospection.cmake | 61 ++++++++++++++++
cmake/modules/GObjectIntrospectionMacros.cmake | 94 +++++++++++++++++++++++++
glib/CMakeLists.txt | 43 ++++++++++-
5 files changed, 201 insertions(+), 4 deletions(-)
New commits:
commit d1033006aae381a0f075e02d54638a1af997caf3
Author: Pino Toscano <pino at kde.org>
Date: Sat Jul 17 21:46:14 2010 +0200
add FindGObjectIntrospection.cmake and GObjectIntrospectionMacros.cmake to the dist
diff --git a/Makefile.am b/Makefile.am
index 55bdaa6..eb7cad2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -82,11 +82,13 @@ EXTRA_DIST += \
cmake/modules/FindFontconfig.cmake \
cmake/modules/FindGDK.cmake \
cmake/modules/FindGLIB.cmake \
+ cmake/modules/FindGObjectIntrospection.cmake \
cmake/modules/FindGTK.cmake \
cmake/modules/FindIconv.cmake \
cmake/modules/FindLCMS.cmake \
cmake/modules/FindQt3.cmake \
cmake/modules/FindQt4.cmake \
+ cmake/modules/GObjectIntrospectionMacros.cmake \
cmake/modules/MacroBoolTo01.cmake \
cmake/modules/MacroEnsureVersion.cmake \
cmake/modules/MacroOptionalFindPackage.cmake \
commit ce8d03950736cc35d035a44a7d88e5f2a9defa74
Author: Pino Toscano <pino at kde.org>
Date: Sat Jul 17 21:39:08 2010 +0200
[CMake/glib] add support for gobject-introspection
other than a module to find (using pkg-config) gobject-introspection, this adds a macro (gir_add_introspections) to add new introspections in a directory.
its working is much similar (even the variable names used) to the Makefile version provided by gobject-repository itself, with the notable difference of a disabled libtool in the g-ir-scanner invocation.
the only additional step needed is adding two custom targets, compiled by ALL, which have the gir and the typelib files as dependencies, to make them build with the usual `make all'.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3deab15..a11d96c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -93,7 +93,8 @@ if(CAIRO_FOUND)
if(GLIB_FOUND)
set(ENABLE_GLIB ON)
# Check for introspection
- # TODO: GOBJECT_INTROSPECTION_CHECK([0.6.7])
+ macro_optional_find_package(GObjectIntrospection 0.6.7)
+ set(HAVE_INTROSPECTION ${INTROSPECTION_FOUND})
set(GLIB_REQ "glib-2.0 >= ${GLIB_REQUIRED} gobject-2.0 >= ${GLIB_REQUIRED} cairo >= ${CAIRO_VERSION}")
set(POPPLER_GLIB_DISABLE_DEPRECATED "${POPPLER_GLIB_DISABLE_DEPRECATED} -DG_DISABLE_DEPRECATED")
set(POPPLER_GLIB_DISABLE_SINGLE_INCLUDES "${POPPLER_GLIB_DISABLE_SINGLE_INCLUDES} -DG_DISABLE_SINGLE_INCLUDES")
@@ -577,7 +578,7 @@ show_end_message_yesno("qt wrapper" QT3_FOUND)
show_end_message_yesno("qt4 wrapper" QT4_FOUND)
show_end_message_yesno("glib wrapper" ENABLE_GLIB)
show_end_message_yesno(" use GDK" POPPLER_WITH_GDK)
-show_end_message(" introspection" "not supported with this CMake build system")
+show_end_message_yesno(" introspection" INTROSPECTION_FOUND)
show_end_message_yesno("cpp wrapper" ENABLE_CPP)
show_end_message("use gtk-doc" "not supported with this CMake build system")
show_end_message_yesno("use libjpeg" ENABLE_LIBJPEG)
diff --git a/cmake/modules/FindGObjectIntrospection.cmake b/cmake/modules/FindGObjectIntrospection.cmake
new file mode 100644
index 0000000..2073c3c
--- /dev/null
+++ b/cmake/modules/FindGObjectIntrospection.cmake
@@ -0,0 +1,61 @@
+# - try to find gobject-introspection
+#
+# Once done this will define
+#
+# INTROSPECTION_FOUND - system has gobject-introspection
+# INTROSPECTION_SCANNER - the gobject-introspection scanner, g-ir-scanner
+# INTROSPECTION_COMPILER - the gobject-introspection compiler, g-ir-compiler
+# INTROSPECTION_GENERATE - the gobject-introspection generate, g-ir-generate
+# INTROSPECTION_GIRDIR
+# INTROSPECTION_TYPELIBDIR
+# INTROSPECTION_CFLAGS
+# INTROSPECTION_LIBS
+#
+# Copyright (C) 2010, Pino Toscano, <pino at kde.org>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+macro(_GIR_GET_PKGCONFIG_VAR _outvar _varname)
+ execute_process(
+ COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=${_varname} gobject-introspection-1.0
+ OUTPUT_VARIABLE _result
+ RESULT_VARIABLE _null
+ )
+
+ if (_null)
+ else()
+ string(REGEX REPLACE "[\r\n]" " " _result "${_result}")
+ string(REGEX REPLACE " +$" "" _result "${_result}")
+ separate_arguments(_result)
+ set(${_outvar} ${_result} CACHE INTERNAL "")
+ endif()
+endmacro(_GIR_GET_PKGCONFIG_VAR)
+
+find_package(PkgConfig)
+if(PKG_CONFIG_FOUND)
+ if(PACKAGE_FIND_VERSION_COUNT GREATER 0)
+ set(_gir_version_cmp ">=${PACKAGE_FIND_VERSION}")
+ endif()
+ pkg_check_modules(_pc_gir gobject-introspection-1.0${_gir_version_cmp})
+ if(_pc_gir_FOUND)
+ set(INTROSPECTION_FOUND TRUE)
+ _gir_get_pkgconfig_var(INTROSPECTION_SCANNER "g_ir_scanner")
+ _gir_get_pkgconfig_var(INTROSPECTION_COMPILER "g_ir_compiler")
+ _gir_get_pkgconfig_var(INTROSPECTION_GENERATE "g_ir_generate")
+ _gir_get_pkgconfig_var(INTROSPECTION_GIRDIR "girdir")
+ _gir_get_pkgconfig_var(INTROSPECTION_TYPELIBDIR "typelibdir")
+ set(INTROSPECTION_CFLAGS "${_pc_gir_CFLAGS}")
+ set(INTROSPECTION_LIBS "${_pc_gir_LIBS}")
+ endif()
+endif()
+
+mark_as_advanced(
+ INTROSPECTION_SCANNER
+ INTROSPECTION_COMPILER
+ INTROSPECTION_GENERATE
+ INTROSPECTION_GIRDIR
+ INTROSPECTION_TYPELIBDIR
+ INTROSPECTION_CFLAGS
+ INTROSPECTION_LIBS
+)
diff --git a/cmake/modules/GObjectIntrospectionMacros.cmake b/cmake/modules/GObjectIntrospectionMacros.cmake
new file mode 100644
index 0000000..e7d62a3
--- /dev/null
+++ b/cmake/modules/GObjectIntrospectionMacros.cmake
@@ -0,0 +1,94 @@
+# Copyright (C) 2010, Pino Toscano, <pino at kde.org>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+macro(_gir_list_prefix _outvar _listvar _prefix)
+ set(${_outvar})
+ foreach(_item IN LISTS ${_listvar})
+ list(APPEND ${_outvar} ${_prefix}${_item})
+ endforeach()
+endmacro(_gir_list_prefix)
+
+macro(gir_add_introspections introspections_girs)
+
+ set(_gir_girs)
+ set(_gir_typelibs)
+
+ foreach(gir IN LISTS ${introspections_girs})
+
+ set(_gir_name "${gir}")
+
+ ## Transform the gir filename to something which can reference through a variable
+ ## without automake/make complaining, eg Gtk-2.0.gir -> Gtk_2_0_gir
+ string(REPLACE "-" "_" _gir_name "${_gir_name}")
+ string(REPLACE "." "_" _gir_name "${_gir_name}")
+
+ # Namespace and Version is either fetched from the gir filename
+ # or the _NAMESPACE/_VERSION variable combo
+ set(_gir_namespace "${${_gir_name}_NAMESPACE}")
+ if (_gir_namespace STREQUAL "")
+ string(REGEX REPLACE "([^-]+)-.*" "\\1" _gir_namespace "${gir}")
+ endif ()
+ set(_gir_version "${${_gir_name}_VERSION}")
+ if (_gir_version STREQUAL "")
+ string(REGEX REPLACE ".*-([^-]+).gir" "\\1" _gir_version "${gir}")
+ endif ()
+
+ # _PROGRAM is an optional variable which needs it's own --program argument
+ set(_gir_program "${${_gir_name}_PROGRAM}")
+ if (NOT _gir_program STREQUAL "")
+ set(_gir_program "--program=${_gir_program}")
+ endif ()
+
+ # Variables which provides a list of things
+ _gir_list_prefix(_gir_libraries ${_gir_name}_LIBS "--library=")
+ _gir_list_prefix(_gir_packages ${_gir_name}_PACKAGES "--pkg=")
+ _gir_list_prefix(_gir_includes ${_gir_name}_INCLUDES "--include=")
+
+ # Reuse the LIBTOOL variable from by automake if it's set
+ set(_gir_libtool "--no-libtool")
+
+ add_custom_command(
+ COMMAND ${INTROSPECTION_SCANNER}
+ ${INTROSPECTION_SCANNER_ARGS}
+ --namespace=${_gir_namespace}
+ --nsversion=${_gir_version}
+ ${_gir_libtool}
+ ${_gir_program}
+ ${_gir_libraries}
+ ${_gir_packages}
+ ${_gir_includes}
+ ${${_gir_name}_SCANNERFLAGS}
+ ${${_gir_name}_CFLAGS}
+ ${${_gir_name}_FILES}
+ --output ${CMAKE_CURRENT_BINARY_DIR}/${gir}
+ DEPENDS ${${_gir_name}_FILES}
+ ${${_gir_name}_LIBS}
+ OUTPUT ${gir}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ VERBATIM
+ )
+ list(APPEND _gir_girs ${CMAKE_CURRENT_BINARY_DIR}/${gir})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${gir} DESTINATION share/gir-1.0)
+
+ string(REPLACE ".gir" ".typelib" _typelib "${gir}")
+ add_custom_command(
+ COMMAND ${INTROSPECTION_COMPILER}
+ ${INTROSPECTION_COMPILER_ARGS}
+ --includedir=.
+ ${CMAKE_CURRENT_BINARY_DIR}/${gir}
+ -o ${CMAKE_CURRENT_BINARY_DIR}/${_typelib}
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${gir}
+ OUTPUT ${_typelib}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ )
+ list(APPEND _gir_typelibs ${CMAKE_CURRENT_BINARY_DIR}/${_typelib})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_typelib} DESTINATION lib${LIB_SUFFIX}/girepository-1.0)
+
+ endforeach()
+
+ add_custom_target(gir-girs ALL DEPENDS ${_gir_girs})
+ add_custom_target(gir-typelibs ALL DEPENDS ${_gir_typelibs})
+
+endmacro(gir_add_introspections)
diff --git a/glib/CMakeLists.txt b/glib/CMakeLists.txt
index d84ff35..f3b180e 100644
--- a/glib/CMakeLists.txt
+++ b/glib/CMakeLists.txt
@@ -107,3 +107,39 @@ if (GDK_FOUND)
target_link_libraries(test-poppler-glib poppler-glib ${GDK2_LIBRARIES})
endif (GDK_FOUND)
+macro(_list_prefix _outvar _listvar _prefix)
+ set(${_outvar})
+ foreach(_item IN LISTS ${_listvar})
+ list(APPEND ${_outvar} ${_prefix}${_item})
+ endforeach()
+endmacro(_list_prefix)
+
+# GObject Introspection
+if (HAVE_INTROSPECTION)
+ include(GObjectIntrospectionMacros)
+ set(INTROSPECTION_GIRS)
+ set(INTROSPECTION_SCANNER_ARGS "--add-include-path=${CMAKE_CURRENT_SOURCE_DIR}")
+ set(INTROSPECTION_COMPILER_ARGS "--includedir=${CMAKE_CURRENT_SOURCE_DIR}")
+
+ set(introspection_files ${poppler_glib_SRCS} ${poppler_glib_public_headers} poppler-private.h)
+ set(Poppler_0_16_gir "poppler-glib")
+ set(Poppler_0_16_gir_INCLUDES GObject-2.0 cairo-1.0)
+ get_directory_property(_tmp_includes INCLUDE_DIRECTORIES)
+ _list_prefix(_includes _tmp_includes "-I")
+ set(Poppler_0_16_gir_CFLAGS ${_includes})
+ set(Poppler_0_16_gir_LIBS poppler-glib)
+ _list_prefix(_abs_introspection_files introspection_files "${CMAKE_CURRENT_SOURCE_DIR}/")
+ list(APPEND _abs_introspection_files
+ ${CMAKE_CURRENT_BINARY_DIR}/poppler-enums.c
+ ${CMAKE_CURRENT_BINARY_DIR}/poppler-enums.h
+ )
+ set(Poppler_0_16_gir_FILES ${_abs_introspection_files})
+
+ if (GDK_FOUND)
+ list(APPEND Poppler_0_16_gir_INCLUDES Gdk-2.0)
+ endif ()
+
+ list(APPEND INTROSPECTION_GIRS Poppler-0.16.gir)
+
+ gir_add_introspections(INTROSPECTION_GIRS)
+endif ()
commit 78bf43d8e11aa52db9862af118c597e117d31083
Author: Pino Toscano <pino at kde.org>
Date: Sat Jul 17 20:28:58 2010 +0200
[CMake] properly use the glib2 include dirs
properly use GLIB2_INCLUDE_DIRS (pkg-config result) for the glib include dirs,
while turn GLIB2_CFLAGS into GLIB2_CFLAGS_OTHERS to add the remaining CFLAGS as definitions
diff --git a/glib/CMakeLists.txt b/glib/CMakeLists.txt
index 905a20a..d84ff35 100644
--- a/glib/CMakeLists.txt
+++ b/glib/CMakeLists.txt
@@ -1,11 +1,12 @@
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
+ ${GLIB2_INCLUDE_DIRS}
${CAIRO_INCLUDE_DIRS}
)
add_definitions(
-DG_LOG_DOMAIN=\"Poppler\"
- ${GLIB2_CFLAGS}
+ ${GLIB2_CFLAGS_OTHERS}
${CAIRO_CFLAGS}
${POPPLER_GLIB_DISABLE_DEPRECATED}
${POPPLER_GLIB_DISABLE_SINGLE_INCLUDES}
commit 6f3082d677bc62aa3f8124132e3e337c01be2629
Author: Pino Toscano <pino at kde.org>
Date: Sat Jul 17 19:28:09 2010 +0200
[CMake] split the generated sources of poppler_glib_SRCS in an own poppler_glib_generated_SRCS
diff --git a/glib/CMakeLists.txt b/glib/CMakeLists.txt
index c308219..905a20a 100644
--- a/glib/CMakeLists.txt
+++ b/glib/CMakeLists.txt
@@ -72,12 +72,14 @@ set(poppler_glib_SRCS
poppler-movie.cc
poppler-media.cc
poppler.cc
+)
+set(poppler_glib_generated_SRCS
${CMAKE_CURRENT_BINARY_DIR}/poppler-enums.c
${CMAKE_SOURCE_DIR}/poppler/CairoFontEngine.cc
${CMAKE_SOURCE_DIR}/poppler/CairoOutputDev.cc
${CMAKE_SOURCE_DIR}/poppler/CairoRescaleBox.cc
)
-add_library(poppler-glib SHARED ${poppler_glib_SRCS})
+add_library(poppler-glib SHARED ${poppler_glib_SRCS} ${poppler_glib_generated_SRCS})
set_target_properties(poppler-glib PROPERTIES VERSION 5.0.0 SOVERSION 5)
target_link_libraries(poppler-glib poppler ${GLIB2_LIBRARIES} ${CAIRO_LIBRARIES} ${FREETYPE_LIBRARIES})
if (GDK_FOUND)
More information about the poppler
mailing list