Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix all blocks and samples on linux, add cairo support #2134

Closed
wants to merge 15 commits into from
Closed
17 changes: 17 additions & 0 deletions blocks/Box2D/templates/Basic Box2D/proj/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cmake_minimum_required( VERSION 2.8 FATAL_ERROR )
set( CMAKE_VERBOSE_MAKEFILE ON )

project( BasicBox2D )
set( APP_NAME "${PROJECT_NAME}App" )

get_filename_component( CINDER_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../.." ABSOLUTE )
get_filename_component( APP_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../" ABSOLUTE )

include( "${CINDER_PATH}/proj/cmake/modules/cinderMakeApp.cmake" )

ci_make_app(
APP_NAME ${APP_NAME}
SOURCES ${APP_PATH}/src/_TBOX_PREFIX_App.cpp
CINDER_PATH ${CINDER_PATH}
BLOCKS Box2D
)
5 changes: 3 additions & 2 deletions blocks/Cairo/cinderblock.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
name="Cairo"
id="org.libcinder.cairo"
author="Cinder Project"
summary="Cairo support for Mac OS X and Windows."
summary="Cairo support for Mac OS X, linux and Windows."
>
<supports os="msw" />
<supports os="macosx" />
<supports os="linux" />
<includePath>include</includePath>
<source>src/Cairo.cpp</source>
<header>include/cinder/cairo/Cairo.h</header>
Expand All @@ -24,4 +25,4 @@
<includePath>include/msw</includePath>
</platform>
</block>
</cinder>
</cinder>
41 changes: 1 addition & 40 deletions blocks/Cairo/include/cinder/cairo/Cairo.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,47 +44,8 @@
#include <vector>
#include <iomanip>

// Forward declarations used by our cairo wrappers
ppff marked this conversation as resolved.
Show resolved Hide resolved
struct _cairo_surface;
typedef struct _cairo_surface cairo_surface_t;
#include <cairo.h>

struct _cairo;
typedef struct _cairo cairo_t;

struct cairo_path;
typedef struct cairo_path cairo_path_t;

struct _cairo_pattern;
typedef struct _cairo_pattern cairo_pattern_t;

/*
struct _cairo_rectangle;
typedef struct _cairo_rectangle cairo_rectangle_t;

struct _cairo_rectangle_list;
typedef struct _cairo_rectangle_list cairo_rectangle_list_t;
*/

struct _cairo_font_options;
typedef struct _cairo_font_options cairo_font_options_t;

struct _cairo_matrix;
typedef struct _cairo_matrix cairo_matrix_t;

struct _cairo_font_face;
typedef struct _cairo_font_face cairo_font_face_t;

struct _cairo_scaled_font;
typedef struct _cairo_scaled_font cairo_scaled_font_t;

/*struct _cairo_glyph;
typedef struct _cairo_glyph cairo_glyph_t;*/

struct _cairo_text_extents;
typedef struct _cairo_text_extents cairo_text_extents_t;

struct _cairo_font_extents;
typedef struct _cairo_font_extents cairo_font_extents_t;

namespace cinder { namespace cairo {
/////////////////////////////////////////////////////////////////////////////
Expand Down
24 changes: 24 additions & 0 deletions blocks/Cairo/proj/cmake/CairoConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
if( NOT TARGET Cairo )
get_filename_component( CAIRO_SOURCE_PATH "${CMAKE_CURRENT_LIST_DIR}/../../src" ABSOLUTE )
get_filename_component( CAIRO_INCLUDE_PATH "${CMAKE_CURRENT_LIST_DIR}/../../include" ABSOLUTE )

list( APPEND CAIRO_SOURCES
${CAIRO_SOURCE_PATH}/Cairo.cpp
)

add_library( Cairo ${CAIRO_SOURCES} )

target_include_directories( Cairo PUBLIC "${CAIRO_INCLUDE_PATH}" )
target_link_libraries( Cairo PRIVATE cinder )

# sudo apt-get install libcairo2-dev
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}" )
find_package( Cairo REQUIRED )
target_include_directories( Cairo PUBLIC "${CAIRO_INCLUDE_DIRS}")
target_link_libraries( Cairo PUBLIC "${CAIRO_LIBRARIES}")

# sudo apt-get install libfreetype6-dev
find_package( Freetype REQUIRED )
target_include_directories( Cairo PRIVATE ${FREETYPE_INCLUDE_DIRS} )
target_link_libraries( Cairo PRIVATE ${FREETYPE_LIBRARIES} )
endif()
75 changes: 75 additions & 0 deletions blocks/Cairo/proj/cmake/FindCairo.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# - Try to find Cairo
# Once done, this will define
#
# CAIRO_FOUND - system has Cairo
# CAIRO_INCLUDE_DIRS - the Cairo include directories
# CAIRO_LIBRARIES - link these to use Cairo
#
# Copyright (C) 2012 Raphael Kubo da Costa <rakuco@webkit.org>
#
# 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 above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``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 COPYRIGHT HOLDER OR ITS
# CONTRIBUTORS 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_package(PkgConfig)
pkg_check_modules(PC_CAIRO QUIET cairo)

find_path(CAIRO_INCLUDE_DIRS
NAMES cairo.h
HINTS ${PC_CAIRO_INCLUDEDIR}
${PC_CAIRO_INCLUDE_DIRS}
PATH_SUFFIXES cairo
)

find_library(CAIRO_LIBRARIES
NAMES cairo
HINTS ${PC_CAIRO_LIBDIR}
${PC_CAIRO_LIBRARY_DIRS}
)

if (CAIRO_INCLUDE_DIRS)
if (EXISTS "${CAIRO_INCLUDE_DIRS}/cairo-version.h")
file(READ "${CAIRO_INCLUDE_DIRS}/cairo-version.h" CAIRO_VERSION_CONTENT)

string(REGEX MATCH "#define +CAIRO_VERSION_MAJOR +([0-9]+)" _dummy "${CAIRO_VERSION_CONTENT}")
set(CAIRO_VERSION_MAJOR "${CMAKE_MATCH_1}")

string(REGEX MATCH "#define +CAIRO_VERSION_MINOR +([0-9]+)" _dummy "${CAIRO_VERSION_CONTENT}")
set(CAIRO_VERSION_MINOR "${CMAKE_MATCH_1}")

string(REGEX MATCH "#define +CAIRO_VERSION_MICRO +([0-9]+)" _dummy "${CAIRO_VERSION_CONTENT}")
set(CAIRO_VERSION_MICRO "${CMAKE_MATCH_1}")

set(CAIRO_VERSION "${CAIRO_VERSION_MAJOR}.${CAIRO_VERSION_MINOR}.${CAIRO_VERSION_MICRO}")
endif ()
endif ()

if ("${Cairo_FIND_VERSION}" VERSION_GREATER "${CAIRO_VERSION}")
message(FATAL_ERROR "Required version (" ${Cairo_FIND_VERSION} ") is higher than found version (" ${CAIRO_VERSION} ")")
endif ()

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Cairo REQUIRED_VARS CAIRO_INCLUDE_DIRS CAIRO_LIBRARIES
VERSION_VAR CAIRO_VERSION)

mark_as_advanced(
CAIRO_INCLUDE_DIRS
CAIRO_LIBRARIES
)
10 changes: 8 additions & 2 deletions blocks/Cairo/src/Cairo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
#elif defined( CINDER_MSW )
#include "cinder/app/App.h"
#include <cairo-win32.h>
#elif defined( CINDER_LINUX )
#include "cinder/app/App.h"
#include <cairo-xlib.h>
#include <cairo-ft.h>
#endif

using std::vector;
Expand Down Expand Up @@ -344,7 +348,7 @@ SurfaceEps::SurfaceEps( const fs::path &filePath, double widthInPoints, double h
: SurfaceBase( (int32_t)widthInPoints, (int32_t)heightInPoints )
{
mCairoSurface = cairo_ps_surface_create( filePath.string().c_str(), widthInPoints, heightInPoints );
cairo_ps_surface_set_eps( mCairoSurface, TRUE );
ppff marked this conversation as resolved.
Show resolved Hide resolved
cairo_ps_surface_set_eps( mCairoSurface, true );
cairo_ps_surface_restrict_to_level( mCairoSurface, ( enableLevel3 ) ? CAIRO_PS_LEVEL_3 : CAIRO_PS_LEVEL_2 );
}

Expand Down Expand Up @@ -1743,6 +1747,8 @@ void Context::setFont( const cinder::Font &font )
cairo_font_face_t *cairoFont = cairo_quartz_font_face_create_for_cgfont( font.getCgFontRef() );
#elif defined( CINDER_MSW )
cairo_font_face_t *cairoFont = cairo_win32_font_face_create_for_logfontw( const_cast<LOGFONTW*>( (const LOGFONTW*)font.getLogfont() ) );
#elif defined( CINDER_LINUX )
cairo_font_face_t *cairoFont = cairo_ft_font_face_create_for_ft_face( font.getFreetypeFace(), 0 );
#endif
cairo_set_font_face( mCairo, cairoFont );
cairo_set_font_size( mCairo, font.getSize() );
Expand Down Expand Up @@ -2054,7 +2060,7 @@ class SvgRendererCairo : public svg::Renderer {
fontMatrix *= rotationMatrix;
mCtx.setFontMatrix( fontMatrix );
TextBox tbox = TextBox().font( *font ).text( span.getString() );
std::vector<std::pair<uint16_t,vec2> > glyphs = tbox.measureGlyphs();
ppff marked this conversation as resolved.
Show resolved Hide resolved
std::vector<std::pair<Font::Glyph,vec2> > glyphs = tbox.measureGlyphs();
vec2 curPoint = mCtx.getCurrentPoint();
for( size_t g = 0; g < glyphs.size(); ++g ) {
mCtx.save();
Expand Down
10 changes: 10 additions & 0 deletions blocks/Clipper/proj/cmake/ClipperConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
if( NOT TARGET Clipper )
get_filename_component( CLIPPER_SOURCE_PATH "${CMAKE_CURRENT_LIST_DIR}/../../src" ABSOLUTE )

add_library( CLIPPER
${CLIPPER_SOURCE_PATH}/clipper.cpp
${CLIPPER_SOURCE_PATH}/CinderClipper.cpp
)

target_include_directories( CLIPPER PUBLIC "${CLIPPER_SOURCE_PATH}"/../include )
endif()
15 changes: 15 additions & 0 deletions blocks/OSC/test/Test/proj/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required( VERSION 2.8 FATAL_ERROR )
set( CMAKE_VERBOSE_MAKEFILE ON )

project( OSC-Test )

get_filename_component( CINDER_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../.." ABSOLUTE )
get_filename_component( APP_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../" ABSOLUTE )

include( "${CINDER_PATH}/proj/cmake/modules/cinderMakeApp.cmake" )

ci_make_app(
SOURCES ${APP_PATH}/src/TestApp.cpp
CINDER_PATH ${CINDER_PATH}
BLOCKS OSC
)
23 changes: 23 additions & 0 deletions blocks/__AppTemplates/BasicApp/OpenGL/proj/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
cmake_minimum_required( VERSION 2.8 FATAL_ERROR )
set( CMAKE_VERBOSE_MAKEFILE ON )

project( Basic )

get_filename_component( CINDER_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../.." ABSOLUTE )
get_filename_component( APP_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../" ABSOLUTE )

# wildcard on resources
file (GLOB APP_RESOURCES
${APP_PATH}/resources/*
)

include( "${CINDER_PATH}/proj/cmake/modules/cinderMakeApp.cmake" )

ci_make_app(
APP_NAME ${PROJECT_NAME}App
CINDER_PATH ${CINDER_PATH}
SOURCES ${APP_PATH}/src/_TBOX_PREFIX_App.cpp
INCLUDES ${APP_PATH}/include
RESOURCES ${APP_RESOURCES}
ASSETS_PATH ${APP_PATH}/assets
)
2 changes: 1 addition & 1 deletion proj/cmake/modules/findCMakeDirs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ macro( findCMakeDirs RESULT_PATHS BASE_PATH SKIP_PATHS )
set( shouldSkip FALSE )
foreach( skip ${SKIP_PATHS} )
if( f MATCHES ".*${skip}" )
ci_log_v( "---- [findCMakeDirs] skipping path: ${f}" )
ppff marked this conversation as resolved.
Show resolved Hide resolved
message( "---- [findCMakeDirs] skipping path: ${f}" )
set( shouldSkip TRUE )
break()
endif()
Expand Down
25 changes: 25 additions & 0 deletions proj/cmake/platform_linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@ set( CMAKE_VERBOSE_MAKEFILE ON )

set( CINDER_PLATFORM "Posix" )

# Some samples are not available on Linux
list( APPEND CINDER_SKIP_SAMPLES
# Renderer2D is required for:
FontSample
perlinTest
BSpline
CairoBasic
Wisteria
Renderer2dBasic
ppff marked this conversation as resolved.
Show resolved Hide resolved
# Capture class is required for:
CaptureBasic
CaptureCube
# Apple only:
MotionBasic # (uses MotionManager block)
Compass # (uses MotionManager block)
LocationManager # (uses LocationManager block)
iosKeyboard
iosNativeControl
# Quicktime has no linux support:
QuickTimeAdvanced
QuickTimeAvfWriter
QuickTimeBasic
QuickTimeIteration
)

# When CINDER_HEADLESS is set, ${SRC_SET_GLFW} will *not* be compiled.
list( APPEND SRC_SET_GLFW
${CINDER_SRC_DIR}/glfw/src/context.c
Expand Down
1 change: 1 addition & 0 deletions samples/ArcballDemo/proj/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ ci_make_app(
SOURCES ${APP_PATH}/src/ArcballDemoApp.cpp
CINDER_PATH ${CINDER_PATH}
INCLUDES ${APP_PATH}/include
RESOURCES ${APP_PATH}/../data/earth.jpg
)
1 change: 1 addition & 0 deletions samples/CameraPersp/proj/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ ci_make_app(
SOURCES ${APP_PATH}/src/CameraPerspApp.cpp
INCLUDES ${APP_PATH}/include
CINDER_PATH ${CINDER_PATH}
RESOURCES ${APP_PATH}/../data/environment_maps/humus_sf.jpg
)
15 changes: 15 additions & 0 deletions samples/HighDensityDisplay/proj/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required( VERSION 2.8 FATAL_ERROR )
set( CMAKE_VERBOSE_MAKEFILE ON )

project( HighIntensityDisplay )

get_filename_component( CINDER_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../.." ABSOLUTE )
get_filename_component( APP_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../" ABSOLUTE )

include( "${CINDER_PATH}/proj/cmake/modules/cinderMakeApp.cmake" )

ci_make_app(
SOURCES ${APP_PATH}/src/HighDensityDisplayApp.cpp
CINDER_PATH ${CINDER_PATH}
INCLUDES ${APP_PATH}/include
)
1 change: 1 addition & 0 deletions samples/SurfaceBasic/proj/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ ci_make_app(
SOURCES ${APP_PATH}/src/SurfaceBasicApp.cpp
INCLUDES ${APP_PATH}/include
CINDER_PATH ${CINDER_PATH}
RESOURCES ${APP_PATH}/../data/cinder_logo.png
)
14 changes: 14 additions & 0 deletions samples/_opengl/LevelOfDetailBasic/proj/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cmake_minimum_required( VERSION 2.8 FATAL_ERROR )
set( CMAKE_VERBOSE_MAKEFILE ON )

project( opengl-LevelOfDetailBasic )

get_filename_component( CINDER_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../../.." ABSOLUTE )
get_filename_component( APP_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../" ABSOLUTE )

include( "${CINDER_PATH}/proj/cmake/modules/cinderMakeApp.cmake" )

ci_make_app(
SOURCES ${APP_PATH}/src/LevelOfDetailBasicApp.cpp
CINDER_PATH ${CINDER_PATH}
)
4 changes: 2 additions & 2 deletions samples/_opengl/ParticlesBasic/src/ParticlesBasicApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class BasicParticleApp : public App {
bool isOffscreen( const vec2 &v );

public:
static const int NUM_PARTICLES = 10000;
ppff marked this conversation as resolved.
Show resolved Hide resolved
static const int NUM_PARTICLES = 100;

float mConservationOfVelocity;
float mSpeed;
Expand Down Expand Up @@ -136,4 +136,4 @@ bool BasicParticleApp::isOffscreen( const vec2 &v )
return ( ( v.x < 0 ) || ( v.x > getWindowWidth() ) || ( v.y < 0 ) || ( v.y > getWindowHeight() ) );
}

CINDER_APP( BasicParticleApp, RendererGl )
CINDER_APP( BasicParticleApp, RendererGl )
2 changes: 1 addition & 1 deletion samples/_opengl/VboMesh/src/VboMeshApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "cinder/app/App.h"
#include "cinder/app/RendererGl.h"
#include "cinder/gl/gl.h"
#include "cinder/GeomIO.h"
#include "cinder/GeomIo.h"
#include "cinder/ImageIo.h"
#include "cinder/CameraUi.h"

Expand Down
1 change: 1 addition & 0 deletions samples/_svg/AnimatedReveal/proj/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ include( "${CINDER_PATH}/proj/cmake/modules/cinderMakeApp.cmake" )
ci_make_app(
SOURCES ${APP_PATH}/src/AnimatedRevealApp.cpp
CINDER_PATH ${CINDER_PATH}
BLOCKS Cairo
)
Loading