From 6cc7e109d3975f0e01e7e9dc2764bb3c7dd2456e Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 11 Nov 2010 16:51:46 +0000 Subject: [PATCH] Moved finding of RSVG, Poppler-glib and GtkGl out into their own Find*.cmake modules to enable easier specialization. --- CMakeLists.txt | 25 ++-------------- CMakeModules/FindFLTK.cmake | 2 +- CMakeModules/FindGtkGl.cmake | 16 +++++++++++ CMakeModules/FindPoppler-glib.cmake | 41 +++++++++++++++++++++++++++ CMakeModules/FindRSVG.cmake | 16 +++++++++++ applications/present3D/CMakeLists.txt | 4 +-- src/osgPlugins/CMakeLists.txt | 4 +-- src/osgPlugins/pdf/CMakeLists.txt | 37 +++++------------------- 8 files changed, 88 insertions(+), 57 deletions(-) create mode 100644 CMakeModules/FindGtkGl.cmake create mode 100644 CMakeModules/FindPoppler-glib.cmake create mode 100644 CMakeModules/FindRSVG.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 46d29b5a3..7b42e5288 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -385,6 +385,9 @@ FIND_PACKAGE(XUL) FIND_PACKAGE(FFmpeg) FIND_PACKAGE(DirectShow) FIND_PACKAGE(SDL) +FIND_PACKAGE(Poppler-glib) +FIND_PACKAGE(RSVG) +FIND_PACKAGE(GtkGl) # Include macro utilities here INCLUDE(OsgMacroUtils) @@ -409,28 +412,6 @@ ELSE() ENDIF() -#use pkg-config to find various modues -INCLUDE(FindPkgConfig OPTIONAL) - -IF(PKG_CONFIG_FOUND) - - INCLUDE(FindPkgConfig) - - PKG_CHECK_MODULES(GTK gtk+-2.0) - - IF(WIN32) - PKG_CHECK_MODULES(GTKGL gtkglext-win32-1.0) - ELSE() - PKG_CHECK_MODULES(GTKGL gtkglext-x11-1.0) - ENDIF() - - PKG_CHECK_MODULES(RSVG librsvg-2.0) - PKG_CHECK_MODULES(CAIRO cairo) - PKG_CHECK_MODULES(POPPLER poppler-glib) - -ENDIF() - - #optional example related dependencies IF (BUILD_OSG_EXAMPLES) diff --git a/CMakeModules/FindFLTK.cmake b/CMakeModules/FindFLTK.cmake index fb6ba4cbe..e376b7896 100644 --- a/CMakeModules/FindFLTK.cmake +++ b/CMakeModules/FindFLTK.cmake @@ -1,4 +1,4 @@ -# Locate gdal +# Locate FLTK # This module defines # FLTK_LIBRARY # FLTK_FOUND, if false, do not try to link to gdal diff --git a/CMakeModules/FindGtkGl.cmake b/CMakeModules/FindGtkGl.cmake new file mode 100644 index 000000000..321cede6c --- /dev/null +++ b/CMakeModules/FindGtkGl.cmake @@ -0,0 +1,16 @@ +#use pkg-config to find various modues +INCLUDE(FindPkgConfig OPTIONAL) + +IF(PKG_CONFIG_FOUND) + + INCLUDE(FindPkgConfig) + + PKG_CHECK_MODULES(GTK gtk+-2.0) + + IF(WIN32) + PKG_CHECK_MODULES(GTKGL gtkglext-win32-1.0) + ELSE() + PKG_CHECK_MODULES(GTKGL gtkglext-x11-1.0) + ENDIF() + +ENDIF() diff --git a/CMakeModules/FindPoppler-glib.cmake b/CMakeModules/FindPoppler-glib.cmake new file mode 100644 index 000000000..d89a186f2 --- /dev/null +++ b/CMakeModules/FindPoppler-glib.cmake @@ -0,0 +1,41 @@ +#use pkg-config to find various modues +INCLUDE(FindPkgConfig OPTIONAL) + +IF(PKG_CONFIG_FOUND) + + INCLUDE(FindPkgConfig) + + PKG_CHECK_MODULES(CAIRO cairo) + PKG_CHECK_MODULES(POPPLER poppler-glib) + + IF (POPPLER_FOUND) + + INCLUDE(CheckCXXSourceRuns) + + SET(CMAKE_REQUIRED_INCLUDES ${POPPLER_INCLUDE_DIRS}) + + # Do step by step checking, + CHECK_CXX_SOURCE_RUNS(" + #include + #include + int main() + { + #ifdef POPPLER_HAS_CAIRO + return EXIT_SUCCESS; + #else + return EXIT_FAILURE + #endif + } + " POPPLER_HAS_CAIRO) + + IF (NOT POPPLER_HAS_CAIRO) + SET(POPPLER_FOUND FALSE) + ENDIF() + + ENDIF() + +# IF (POPPLER_FOUND AND (NOT POPPLER_LIBRARIES OR NOT POPPLER_INCLUDE_DIRS) ) +# SET(POPPLER_FOUND FALSE) +# ENDIF() + +ENDIF() diff --git a/CMakeModules/FindRSVG.cmake b/CMakeModules/FindRSVG.cmake new file mode 100644 index 000000000..cae658648 --- /dev/null +++ b/CMakeModules/FindRSVG.cmake @@ -0,0 +1,16 @@ +#use pkg-config to find various modues +INCLUDE(FindPkgConfig OPTIONAL) + +IF(PKG_CONFIG_FOUND) + + INCLUDE(FindPkgConfig) + + PKG_CHECK_MODULES(RSVG librsvg-2.0) + PKG_CHECK_MODULES(CAIRO cairo) + + IF (RSVG_FOUND AND NOT CAIRO_FOUND) + SET(RSVG_FOUND FALSE) + ENDIF() + + +ENDIF() diff --git a/applications/present3D/CMakeLists.txt b/applications/present3D/CMakeLists.txt index d5c16258e..dfd9869a6 100644 --- a/applications/present3D/CMakeLists.txt +++ b/applications/present3D/CMakeLists.txt @@ -93,10 +93,10 @@ IF (NOT DYNAMIC_OPENSCENEGRAPH) SET(TARGET_ADDED_LIBRARIES ${TARGET_ADDED_LIBRARIES} osgdb_freetype) ENDIF(FREETYPE_FOUND) - IF(POPPLER_FOUND AND CAIRO_FOUND) + IF(POPPLER_FOUND) ADD_DEFINITIONS(-DUSE_POPPLER_CAIRO) SET(TARGET_ADDED_LIBRARIES ${TARGET_ADDED_LIBRARIES} osgdb_pdf) - ENDIF(POPPLER_FOUND AND CAIRO_FOUND) + ENDIF(POPPLER_FOUND) ENDIF() IF (WIN32) diff --git a/src/osgPlugins/CMakeLists.txt b/src/osgPlugins/CMakeLists.txt index 5a9fce58b..7d5113ffa 100644 --- a/src/osgPlugins/CMakeLists.txt +++ b/src/osgPlugins/CMakeLists.txt @@ -234,11 +234,11 @@ IF(ZLIB_FOUND) ADD_SUBDIRECTORY(zip) ENDIF() -IF(RSVG_FOUND AND CAIRO_FOUND) +IF(RSVG_FOUND) ADD_SUBDIRECTORY(svg) ENDIF() -IF(POPPLER_FOUND AND CAIRO_FOUND) +IF(POPPLER_FOUND) ADD_SUBDIRECTORY(pdf) ENDIF() diff --git a/src/osgPlugins/pdf/CMakeLists.txt b/src/osgPlugins/pdf/CMakeLists.txt index 4d9a3a22a..c27dc345e 100644 --- a/src/osgPlugins/pdf/CMakeLists.txt +++ b/src/osgPlugins/pdf/CMakeLists.txt @@ -1,33 +1,10 @@ -INCLUDE(CheckCXXSourceRuns) +SET(TARGET_SRC ReaderWriterPDF.cpp ) -SET(CMAKE_REQUIRED_INCLUDES ${POPPLER_INCLUDE_DIRS}) +INCLUDE_DIRECTORIES( ${CAIRO_INCLUDE_DIRS} ${POPPLER_INCLUDE_DIRS} ) +LINK_DIRECTORIES(${CAIRO_LIBRARY_DIRS} ${POPPLER_LIBRARY_DIRS}) +SET(TARGET_EXTERNAL_LIBRARIES ${CAIRO_LIBRARIES} ${POPPLER_LIBRARIES} ) -# Do step by step checking, -CHECK_CXX_SOURCE_RUNS(" -#include -#include -int main() -{ -#ifdef POPPLER_HAS_CAIRO - return EXIT_SUCCESS; -#else - return EXIT_FAILURE -#endif -} -" POPPLER_HAS_CAIRO) +SET(TARGET_ADDED_LIBRARIES osgWidget) - -IF (POPPLER_HAS_CAIRO) - - SET(TARGET_SRC ReaderWriterPDF.cpp ) - - INCLUDE_DIRECTORIES( ${CAIRO_INCLUDE_DIRS} ${POPPLER_INCLUDE_DIRS} ) - LINK_DIRECTORIES(${CAIRO_LIBRARY_DIRS} ${POPPLER_LIBRARY_DIRS}) - SET(TARGET_EXTERNAL_LIBRARIES ${CAIRO_LIBRARIES} ${POPPLER_LIBRARIES} ) - - SET(TARGET_ADDED_LIBRARIES osgWidget) - - #### end var setup ### - SETUP_PLUGIN(pdf pdf) - -ENDIF() +#### end var setup ### +SETUP_PLUGIN(pdf pdf)