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

Add CMake to agg and modernize #1

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
39 changes: 39 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
cmake_minimum_required(VERSION 3.10)
project(agg VERSION 2.4.0)

include(FeatureSummary)
include(GNUInstallDirs)
include(GenerateExportHeader)

option(BUILD_SHARED_LIBS "build dynamic(ON) or static(OFF) libraries" ON)
option(USE_GPC "Use Gpc Boolean library" OFF)
option(USE_FREETYPE "Use Freetype library" OFF)
option(USE_EXPAT "Use Expat library" OFF)
option(USE_SDL "Use SDL as platform" OFF)
option(USE_AGG2D "Agg 2D graphical context" OFF)
option(USE_DEBUG "For debug version" OFF)


set(MAPNIK_DEBUG_POSTFIX "d" CACHE STRING "sets the debug library postfix")
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 14 CACHE STRING "Sets the c++ standard. c++14 is minimum.")
set(CMAKE_CXX_EXTENSIONS OFF CACHE STRING "Enables the compiler specific extensions.") # Fallsback to -std=c++<ver> if off
message(STATUS "Using c++ extensions: ${CXX_EXTENSIONS}")
message(STATUS "Using c++${CMAKE_CXX_STANDARD}")
message(STATUS "postfix for debug libraries: ${MAPNIK_DEBUG_POSTFIX}")

find_package(X11)
if(USE_EXPAT)
find_package(EXPAT REQUIRED)
endif()
if(USE_FREETYPE)
find_package(Freetype REQUIRED)
endif()
if(USE_SDL)
find_package(SDL2 CONFIG REQUIRED)
endif()

feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES)
feature_summary(FILENAME "${CMAKE_CURRENT_BINARY_DIR}/features.log" WHAT ALL)

add_subdirectory(agg)
289 changes: 45 additions & 244 deletions agg/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,244 +1,45 @@
PROJECT( antigrain )

# additional are modified Find routines
SET ( CMAKE_MODULE_PATH "${antigrain_SOURCE_DIR}/bin" )

CMAKE_MINIMUM_REQUIRED( VERSION 2.4.8 )

SET(AGG_MAJOR_VERSION 0 )
SET(AGG_MINOR_VERSION 1 )
SET(AGG_BUILD_VERSION 1 )

SET( AGG_FLAGS "" )
SET( AGG_INCLUDE_DIRS "" )
SET( AGG_LIBRARY_DIRS "" )
SET( AGG_LIBRARIES "" )

SET (LIBRARY_OUTPUT_PATH ${antigrain_BINARY_DIR}/lib/ CACHE PATH "Single output directory for building all libraries." FORCE )
SET( AGG_LIBRARY_DIRS lib )
#SET (EXECUTABLE_OUTPUT_PATH ${antigrain_BINARY_DIR}/exe/ CACHE PATH "Single output directory for building all executables.")
#MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)

LINK_DIRECTORIES( ${antigrain_BINARY_DIR}/lib )

OPTION( agg_USE_GPC "Use Gpc Boolean library" OFF)
OPTION( agg_USE_FREETYPE "Use Freetype library" OFF)
OPTION( agg_USE_EXPAT "Use Expat library" OFF)
OPTION( agg_USE_SDL_PLATFORM "Use SDL as platform" OFF)
OPTION( agg_USE_PACK "Package Agg" OFF)
OPTION( agg_USE_AGG2D "Agg 2D graphical context" OFF)
OPTION( agg_USE_DEBUG "For debug version" OFF)

IF( agg_USE_DEBUG )
#SET( PFDEBUG "d" )
SET( CMAKE_DEBUG_POSTFIX "d" )
ENDIF( agg_USE_DEBUG )

# for the moment this decides the platform code.
IF(WIN32)
ADD_DEFINITIONS( -D_MSWVC_ -D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE )
SET( WIN32GUI WIN32 )
INCLUDE_DIRECTORIES( ${antigrain_SOURCE_DIR}/font_win32_tt )
SET( AGG_INCLUDE_DIRS ${AGG_INCLUDE_DIRS} font_win32_tt )
ENDIF(WIN32)

IF(UNIX)
ADD_DEFINITIONS( -D__UNIX__ )
SET( WIN32GUI "" )

FIND_PACKAGE(X11)
IF(X11_FOUND)
INCLUDE_DIRECTORIES(${X11_INCLUDE_DIRS})
LINK_LIBRARIES(${X11_LIBRARIES})
ENDIF(X11_FOUND)

ENDIF(UNIX)

# more specific set platform code part to use for different compilers/tool sets
IF ( ${CMAKE_GENERATOR} STREQUAL "MSYS Makefiles" )
SET (CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG" CACHE STRING
"Flags used by the compiler during release builds" FORCE)
SET (CMAKE_CX_FLAGS_RELEASE "-DNDEBUG" CACHE STRING
"Flags used by the compiler during release builds" FORCE)
ENDIF ( ${CMAKE_GENERATOR} STREQUAL "MSYS Makefiles" )

IF ( ${CMAKE_GENERATOR} STREQUAL "MinGW Makefiles" )

ENDIF ( ${CMAKE_GENERATOR} STREQUAL "MinGW Makefiles" )

IF ( ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles" )
IF( CYGWIN OR MINGW )
SET (CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG" CACHE STRING
"Flags used by the compiler during release builds" FORCE)
SET (CMAKE_C_FLAGS_RELEASE "-DNDEBUG" CACHE STRING
"Flags used by the compiler during release builds" FORCE)
ENDIF( CYGWIN OR MINGW )
ENDIF ( ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles" )

IF ( ${CMAKE_GENERATOR} MATCHES "Visual Studio.*" )

ENDIF ( ${CMAKE_GENERATOR} MATCHES "Visual Studio.*" )

IF ( ${CMAKE_GENERATOR} MATCHES "Borland Makefiles" )

ENDIF ( ${CMAKE_GENERATOR} MATCHES "Borland Makefiles" )

##################################################
# Set all includes, flags, libraries, related to expat
##################################################

IF( agg_USE_EXPAT )

FIND_PACKAGE( EXPAT )

IF(EXPAT_FOUND)
INCLUDE_DIRECTORIES(${EXPAT_INCLUDE_DIRS})
LINK_LIBRARIES(${EXPAT_LIBRARIES})
ELSE(EXPAT_FOUND)
MESSAGE(SEND_ERROR "expat not found")
ENDIF(EXPAT_FOUND)
ENDIF( agg_USE_EXPAT )

##################################################
# Set all includes, flags, libraries, related to freetype
##################################################

IF( agg_USE_FREETYPE )
FIND_PACKAGE( Freetype )
IF( FREETYPE_FOUND )
INCLUDE_DIRECTORIES( ${FREETYPE_INCLUDE_DIRS} )
LINK_LIBRARIES( ${FREETYPE_LIBRARIES} )
LINK_DIRECTORIES( ${FREETYPE_LINK_DIR} )
ELSE( FREETYPE_FOUND )
MESSAGE(SEND_ERROR "freetype not found")
ENDIF( FREETYPE_FOUND )
ENDIF( agg_USE_FREETYPE )

##################################################
# Set all includes, flags, libraries, related to SDL
##################################################

FIND_PACKAGE( SDL QUIET )
IF( SDL_FOUND )
IF ( agg_USE_SDL_PLATFORM )
INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR})
LINK_LIBRARIES(${SDL_LIBRARY})
ENDIF ( agg_USE_SDL_PLATFORM )
ELSE( SDL_FOUND )
IF ( agg_USE_SDL_PLATFORM )
MESSAGE( "SDL libray was not found, disable agg_USE_SDL_PLATFORM please" )
ENDIF ( agg_USE_SDL_PLATFORM )
ENDIF( SDL_FOUND )

# the main include dir of Agg
INCLUDE_DIRECTORIES( ${antigrain_SOURCE_DIR}/include )
SET( AGG_INCLUDE_DIRS ${AGG_INCLUDE_DIRS} include )

# freetype specific lib of Agg
IF( agg_USE_FREETYPE )
INCLUDE_DIRECTORIES( ${antigrain_SOURCE_DIR}/font_freetype )
SET( AGG_INCLUDE_DIRS ${AGG_INCLUDE_DIRS} font_freetype )
ADD_DEFINITIONS( -DAGG_USE_FREETYPE )
SET( AGG_FLAGS ${AGG_FLAGS} -DAGG_USE_FREETYPE )
LINK_LIBRARIES( freetypefont )
SET( AGG_LIBRARIES ${AGG_LIBRARIES} aggfontfreetype${PFDEBUG} )
ENDIF( agg_USE_FREETYPE )

# GPC lib if used within Agg
IF ( agg_USE_GPC )
INCLUDE_DIRECTORIES( ${antigrain_SOURCE_DIR}/gpc )
SET( AGG_INCLUDE_DIRS ${AGG_INCLUDE_DIRS} gpc )
ADD_DEFINITIONS( -DAGG_USE_GPC )
SET( AGG_FLAGS ${AGG_FLAGS} -DAGG_USE_GPC )
LINK_LIBRARIES( gpcbool )
SET( AGG_LIBRARIES ${AGG_LIBRARIES} gpc${PFDEBUG} )
ENDIF ( agg_USE_GPC )

# agg2d lib if used within Agg
IF ( agg_USE_AGG2D )
INCLUDE_DIRECTORIES( ${antigrain_SOURCE_DIR}/agg2d )
SET( AGG_INCLUDE_DIRS ${AGG_INCLUDE_DIRS} agg2d )
ADD_DEFINITIONS( -DAGG_USE_AGG2D )
OPTION( agg_USE_AGG2D_FREETYPE "Agg 2D graphical context uses freetype" OFF)
SET( AGG_FLAGS ${AGG_FLAGS} -DAGG_USE_AGG2D )
LINK_LIBRARIES( agg2d )
SET( AGG_LIBRARIES ${AGG_LIBRARIES} agg2d${PFDEBUG} )
ENDIF ( agg_USE_AGG2D )

IF ( agg_USE_AGG2D_FREETYPE )
ADD_DEFINITIONS( -DAGG2D_USE_FREETYPE )
SET( AGG_FLAGS ${AGG_FLAGS} -DAGG2D_USE_FREETYPE )
ENDIF ( agg_USE_AGG2D_FREETYPE )

# sld as platform or os
IF( SDL_FOUND AND agg_USE_SDL_PLATFORM )
LINK_LIBRARIES( controls sdlplatform antigrain )
SET( AGG_LIBRARIES ${AGG_LIBRARIES} aggctrl${PFDEBUG} aggsdlplatform${PFDEBUG} agg${PFDEBUG} )
ELSE( SDL_FOUND AND agg_USE_SDL_PLATFORM )
LINK_LIBRARIES( controls platform antigrain )
SET( AGG_LIBRARIES ${AGG_LIBRARIES} aggctrl${PFDEBUG} aggplatform${PFDEBUG} agg${PFDEBUG} )
ENDIF( SDL_FOUND AND agg_USE_SDL_PLATFORM )

SET( AGG_FLAGS ${AGG_FLAGS} CACHE STRING "Agg package flags" FORCE )
SET( AGG_INCLUDE_DIRS ${AGG_INCLUDE_DIRS} CACHE STRING "Agg package libs include paths" FORCE )
SET( AGG_LIBRARY_DIRS ${AGG_LIBRARY_DIRS} CACHE STRING "Agg package libs directory paths" FORCE )
SET( AGG_LIBRARIES ${AGG_LIBRARIES} CACHE STRING "Agg package libraries" FORCE )

ADD_SUBDIRECTORY( src )

ADD_SUBDIRECTORY( examples )

CONFIGURE_FILE( ${antigrain_SOURCE_DIR}/bin/AggConfig.cmake.in
${antigrain_BINARY_DIR}/bin/AggConfig.cmake
@ONLY IMMEDIATE )

CONFIGURE_FILE( ${antigrain_SOURCE_DIR}/bin/AggConfigOutBuild.cmake.in
${antigrain_BINARY_DIR}/bin/AggConfigOutBuild.cmake
@ONLY IMMEDIATE )

CONFIGURE_FILE( ${antigrain_SOURCE_DIR}/bin/FindAgg.cmake
${antigrain_BINARY_DIR}/myapp/FindAgg.cmake
@ONLY IMMEDIATE )

CONFIGURE_FILE( ${antigrain_SOURCE_DIR}/bin/UseAgg.cmake.in
${antigrain_BINARY_DIR}/bin/UseAgg.cmake
@ONLY IMMEDIATE )

ADD_SUBDIRECTORY( myapp )

INSTALL( FILES ${antigrain_BINARY_DIR}/bin/AggConfigOutBuild.cmake DESTINATION "bin" RENAME AggConfig.cmake )
INSTALL( FILES ${antigrain_BINARY_DIR}/bin/AggConfig.cmake DESTINATION "bin" )
INSTALL( FILES ${antigrain_BINARY_DIR}/bin/UseAgg.cmake DESTINATION "bin" )

#-------------------------------------------------------------------
# Build a CPack installer if CPack is available and this is a build
IF ( agg_USE_PACK )
IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Agg - Vector Graphics")
SET(CPACK_PACKAGE_VENDOR "Agg")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/copying")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/copying")
SET(CPACK_PACKAGE_VERSION_MAJOR "${AGG_MAJOR_VERSION}")
SET(CPACK_PACKAGE_VERSION_MINOR "${AGG_MINOR_VERSION}")
SET(CPACK_PACKAGE_VERSION_PATCH "${AGG_BUILD_VERSION}")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "AGG_${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "agg-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
SET(CPACK_PACKAGE_EXECUTABLES
"agg" "AGG"
)
SET(CPACK_SOURCE_STRIP_FILES "")
SET(CPACK_STRIP_FILES "bin/ccmake;bin/cmake;bin/cpack;bin/ctest")


IF(WIN32)
SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
SET(CPACK_NSIS_HELP_LINK "http://agg.sourceforge.net")
SET(CPACK_NSIS_URL_INFO_ABOUT "http://agg.sourceforge.net")
SET(CPACK_NSIS_CONTACT "http://agg.sourceforge.net")
ENDIF(WIN32)

INCLUDE(CPack)
ENDIF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
ENDIF ( agg_USE_PACK )

INCLUDE( myapp/myproject.cmake )
add_library(agg
src/agg_arc.cpp
src/agg_arrowhead.cpp
src/agg_bezier_arc.cpp
src/agg_bspline.cpp
src/agg_color_rgba.cpp
src/agg_curves.cpp
src/agg_embedded_raster_fonts.cpp
src/agg_gsv_text.cpp
src/agg_image_filters.cpp
src/agg_line_aa_basics.cpp
src/agg_line_profile_aa.cpp
src/agg_pixfmt_rgba.cpp
src/agg_rounded_rect.cpp
src/agg_sqrt_tables.cpp
src/agg_trans_affine.cpp
src/agg_trans_double_path.cpp
src/agg_trans_single_path.cpp
src/agg_trans_warp_magnifier.cpp
src/agg_vcgen_bspline.cpp
src/agg_vcgen_contour.cpp
src/agg_vcgen_dash.cpp
src/agg_vcgen_markers_term.cpp
src/agg_vcgen_smooth_poly1.cpp
src/agg_vcgen_stroke.cpp
src/agg_vpgen_clip_polygon.cpp
src/agg_vpgen_clip_polyline.cpp
src/agg_vpgen_segmentator.cpp

src/ctrl/agg_bezier_ctrl.cpp
src/ctrl/agg_cbox_ctrl.cpp
src/ctrl/agg_gamma_ctrl.cpp
src/ctrl/agg_gamma_spline.cpp
src/ctrl/agg_polygon_ctrl.cpp
src/ctrl/agg_rbox_ctrl.cpp
src/ctrl/agg_scale_ctrl.cpp
src/ctrl/agg_slider_ctrl.cpp
src/ctrl/agg_spline_ctrl.cpp
)
generate_export_header(agg EXPORT_FILE_NAME agg_export.h)
target_include_directories(agg PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:include>
)
Loading