Permalink
Browse files

Added Cairo addon to CMake build system.

  • Loading branch information...
jeremytregunna committed May 10, 2010
1 parent 1baf3f8 commit 9c76c405746843087bb94e15c3ef12b9edf041af
Showing with 113 additions and 1 deletion.
  1. +1 −1 addons/CMakeLists.txt
  2. +65 −0 addons/Cairo/CMakeLists.txt
  3. +47 −0 modules/FindCairo.cmake
View
@@ -48,7 +48,7 @@ add_subdirectory(Blowfish)
#add_subdirectory(Box)
add_subdirectory(CFFI)
add_subdirectory(CGI)
-#add_subdirectory(Cairo)
+add_subdirectory(Cairo)
#add_subdirectory(Clutter)
add_subdirectory(ContinuedFraction)
add_subdirectory(Curses)
@@ -0,0 +1,65 @@
+# Base Io build system
+# Written by Jeremy Tregunna <jeremy.tregunna@me.com>
+#
+# Builds the Cairo addon
+
+# Find cairo
+find_package(Cairo)
+
+# Create the _build bundle hierarchy if needed.
+make_build_bundle(_build)
+
+# Did we find cairo? if so, set up the targets and all the support
+# variables.
+if(CAIRO_FOUND)
+ # Output our dynamic library to the top-level _build hierarchy
+ set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/_build/dll)
+
+ # Additional include directories
+ include_directories(${CAIRO_INCLUDE_DIRS})
+
+ # Generate the IoCairoInit.c file.
+ # Argument SHOULD ALWAYS be the exact name of the addon, case is
+ # important.
+ generate_ioinit(Cairo)
+
+ # Our library sources.
+ set(SRCS
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoCairo.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoCairoContext.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoCairoExtents.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoCairoFontExtents.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoCairoFontFace.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoCairoFontOptions.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoCairoGlyph.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoCairoGradient.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoCairoImageSurface.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoCairoLinearGradient.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoCairoMatrix.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoCairoPath.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoCairoPathElement.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoCairoPattern.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoCairoRadialGradient.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoCairoRectangle.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoCairoScaledFont.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoCairoSolidPattern.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoCairoSurface.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoCairoSurfacePattern.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoCairoTextExtents.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoCairo_fileSurfaces.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/_IoCairoPDFSurface.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/_IoCairoPSSurface.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/_IoCairoSVGSurface.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoCairoInit.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/tools.c"
+ )
+
+ # Now build the shared library
+ add_library(IoCairo SHARED ${SRCS})
+ add_dependencies(IoCairo iovmall)
+ target_link_libraries(IoCairo iovmall ${CAIRO_LIBRARIES})
+
+ # Install the addon to our global addons hierarchy.
+ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/io/addons)
+ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/_build DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/io/addons/Cairo)
+endif(CAIRO_FOUND)
View
@@ -0,0 +1,47 @@
+# - Try to find the cairo library
+# Once done this will define
+#
+# CAIRO_FOUND - system has cairo
+# CAIRO_INCLUDE_DIRS - the cairo include directory
+# CAIRO_LIBRARIES - Link these to use cairo
+#
+# Define CAIRO_MIN_VERSION for which version desired.
+#
+
+INCLUDE(FindPkgConfig)
+
+IF(Cairo_FIND_REQUIRED)
+ SET(_pkgconfig_REQUIRED "REQUIRED")
+ELSE(Cairo_FIND_REQUIRED)
+ SET(_pkgconfig_REQUIRED "")
+ENDIF(Cairo_FIND_REQUIRED)
+
+IF(CAIRO_MIN_VERSION)
+ PKG_SEARCH_MODULE(CAIRO ${_pkgconfig_REQUIRED} cairo>=${CAIRO_MIN_VERSION})
+ELSE(CAIRO_MIN_VERSION)
+ PKG_SEARCH_MODULE(CAIRO ${_pkgconfig_REQUIRED} cairo)
+ENDIF(CAIRO_MIN_VERSION)
+
+IF(NOT CAIRO_FOUND AND NOT PKG_CONFIG_FOUND)
+ FIND_PATH(CAIRO_INCLUDE_DIRS cairo.h)
+ FIND_LIBRARY(CAIRO_LIBRARIES cairo)
+
+ # Report results
+ IF(CAIRO_LIBRARIES AND CAIRO_INCLUDE_DIRS)
+ SET(CAIRO_FOUND 1)
+ IF(NOT Cairo_FIND_QUIETLY)
+ MESSAGE(STATUS "Found Cairo: ${CAIRO_LIBRARIES}")
+ ENDIF(NOT Cairo_FIND_QUIETLY)
+ ELSE(CAIRO_LIBRARIES AND CAIRO_INCLUDE_DIRS)
+ IF(Cairo_FIND_REQUIRED)
+ MESSAGE(SEND_ERROR "Could not find Cairo")
+ ELSE(Cairo_FIND_REQUIRED)
+ IF(NOT Cairo_FIND_QUIETLY)
+ MESSAGE(STATUS "Could not find Cairo")
+ ENDIF(NOT Cairo_FIND_QUIETLY)
+ ENDIF(Cairo_FIND_REQUIRED)
+ ENDIF(CAIRO_LIBRARIES AND CAIRO_INCLUDE_DIRS)
+ENDIF(NOT CAIRO_FOUND AND NOT PKG_CONFIG_FOUND)
+
+# Hide advanced variables from CMake GUIs
+MARK_AS_ADVANCED(CAIRO_LIBRARIES CAIRO_INCLUDE_DIRS)

0 comments on commit 9c76c40

Please sign in to comment.