Subversion Repositories Scribus

Rev

Rev 9680 | Rev 9712 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#Set our CMake minimum version
#Require 2.4.2 for Qt finding
#Require 2.4.3 for moc change detection and rpath updates for custom cairo install
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.5 FATAL_ERROR)

#Pretty colors
SET(CMAKE_COLOR_MAKEFILE ON)
#Dont force verbose
SET(CMAKE_VERBOSE_MAKEFILE OFF)
#Include current dir
SET(CMAKE_INCLUDE_CURRENT_DIR TRUE)
#RPATH setup
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
SET(CMAKE_SKIP_RULE_DEPENDENCY TRUE)
SET(CMAKE_SKIP_BUILD_RPATH TRUE)
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
#SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
#SET(CMAKE_SKIP_RPATH:BOOL NO)

#Set the custom CMake module directory where our include/lib finders are
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")

# SET(CMAKE_SHARED_MODULE_LINK_FLAGS "${CMAKE_SHARED_MODULE_LINK_FLAGS} -export-dynamic")
# SET(CMAKE_SHARED_MODULE_LINK_CXX_FLAGS "${CMAKE_SHARED_MODULE_LINK_CXX_FLAGS} -export-dynamic")
# SET(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} -export-dynamic")
# SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -export-dynamic")
# MESSAGE(STATUS ${CMAKE_SHARED_MODULE_LINK_FLAGS})
# MESSAGE(STATUS ${CMAKE_SHARED_MODULE_LINK_CXX_FLAGS})
# MESSAGE(STATUS ${CMAKE_SHARED_LIBRARY_C_FLAGS})
# MESSAGE(STATUS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS})
# MESSAGE(STATUS ${CMAKE_CXX_CREATE_SHARED_MODULE})
# MESSAGE(STATUS ${CMAKE_CXX_CREATE_SHARED_LIBRARY})

#IMPORT FROM COMMANDLINE
# SET with cmake -DWANT_CAIRO=1, etc
# MESSAGE(STATUS ${WANT_CAIRO})
# MESSAGE(STATUS ${WANT_LIBART})
# MESSAGE(STATUS ${WANT_DEBUG})

# SET(WANT_CAIRO 0)
# SET(WANT_LIBART 1)

#Project Setup
PROJECT(scribus)
#Set our version values
#Final version is ${VERSION} = ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${VERSION_SUFFIX}
#where VERSION_SUFFIX is of the form "", "cvs" or "Ncvs" (N being the minor patch level)
SET (VERSION_MAJOR "1")
SET (VERSION_MINOR "3")
SET (VERSION_PATCH "5")
SET (VERSION_SUFFIX "svn")
SET (VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${VERSION_SUFFIX})
MESSAGE(STATUS "Scribus ${VERSION} will be built to install into ${CMAKE_INSTALL_PREFIX}")

#Set the permissions to be used when installing plugins
SET(PLUGIN_PERMISSIONS WORLD_EXECUTE GROUP_EXECUTE OWNER_EXECUTE WORLD_READ GROUP_READ OWNER_READ OWNER_WRITE)

#Our main directory is scribus
SET(MAIN_DIR_NAME "scribus")

#On Apple, we ignore the versioning tag so all items are "scribus" not "scribus-version"
IF (NOT BUILD_OSX_BUNDLE)
  SET(BUILD_OSX_BUNDLE ${APPLE} CACHE TYPE BOOL)
ENDIF (NOT BUILD_OSX_BUNDLE)

#Simplify future conditionals for Apple
IF (APPLE AND BUILD_OSX_BUNDLE)
  SET(APPLEBUNDLE TRUE CACHE TYPE BOOL)
ENDIF (APPLE AND BUILD_OSX_BUNDLE)

#Announce we cached a version request before, overridden below for OSX
IF(TAG_VERSION)
  IF (NOT APPLEBUNDLE)
    MESSAGE(STATUS "Previously selected version tag: ${TAG_VERSION}")
  ENDIF (NOT APPLEBUNDLE)
  SET(WANT_VERSIONING 1)
  SET(CACHED_VERSIONING 1)
ENDIF(TAG_VERSION)

#Remove version tags on OSX so our bundle is Scribus.app
IF (APPLEBUNDLE)
  IF (WANT_VERSIONING OR CACHED_VERSIONING)
    MESSAGE(STATUS "Ignoring version tag on OSX when building bundle")
    SET(WANT_VERSIONING 0)
    SET(CACHED_VERSIONING 0)
  ENDIF (WANT_VERSIONING OR CACHED_VERSIONING)
ENDIF (APPLEBUNDLE)

#Store our version string if require
IF (WANT_VERSIONING AND NOT CACHED_VERSIONING)
  IF (NOT CUSTOM_VERSIONTAG)
    SET(TAG_VERSION "-${VERSION}" CACHE TYPE STRING)
  ELSE (NOT CUSTOM_VERSIONTAG)
    SET(TAG_VERSION ${CUSTOM_VERSIONTAG} CACHE TYPE STRING)
  ENDIF (NOT CUSTOM_VERSIONTAG)
ENDIF (WANT_VERSIONING AND NOT CACHED_VERSIONING)

#Setp all the directories we will use
#MAN
SET(MANDIR "share/man/")
SET(SHAREDIR "share/${MAIN_DIR_NAME}${TAG_VERSION}/")
ADD_DEFINITIONS("-DSHAREDIR=\\\"${CMAKE_INSTALL_PREFIX}/${SHAREDIR}\\\"")

#SHARE - use the default on Apple as TAG_VERSION is empty
IF(TAG_VERSION OR BUILD_OSX_BUNDLE)
  SET(DOCDIR "share/doc/${MAIN_DIR_NAME}${TAG_VERSION}/")
ELSE(TAG_VERSION OR BUILD_OSX_BUNDLE)
  SET(DOCDIR "share/doc/${MAIN_DIR_NAME}-${VERSION}/")
ENDIF (TAG_VERSION OR BUILD_OSX_BUNDLE)
ADD_DEFINITIONS("-DDOCDIR=\\\"${CMAKE_INSTALL_PREFIX}/${DOCDIR}\\\"")

#ICON
SET(ICONDIR "share/${MAIN_DIR_NAME}${TAG_VERSION}/icons/")
ADD_DEFINITIONS("-DICONDIR=\\\"${CMAKE_INSTALL_PREFIX}/${ICONDIR}\\\"")

#SAMPLES
SET(SAMPLESDIR "share/${MAIN_DIR_NAME}${TAG_VERSION}/samples/")
ADD_DEFINITIONS("-DSAMPLESDIR=\\\"${CMAKE_INSTALL_PREFIX}/${SAMPLESDIR}\\\"")

#SCRIPTS
SET(SCRIPTSDIR "share/${MAIN_DIR_NAME}${TAG_VERSION}/scripts/")
ADD_DEFINITIONS("-DSCRIPTSDIR=\\\"${CMAKE_INSTALL_PREFIX}/${SCRIPTSDIR}\\\"")

#TEMPLATES
SET(TEMPLATEDIR "share/${MAIN_DIR_NAME}${TAG_VERSION}/templates/")
ADD_DEFINITIONS("-DTEMPLATEDIR=\\\"${CMAKE_INSTALL_PREFIX}/${TEMPLATEDIR}\\\"")

#DESKTOP
SET(DESKTOPDIR "share/applications/")
ADD_DEFINITIONS("-DDESKTOPDIR=\\\"${CMAKE_INSTALL_PREFIX}/${DESKTOPDIR}\\\"")

#LIB
SET(LIBDIR "lib/${MAIN_DIR_NAME}${TAG_VERSION}/")
ADD_DEFINITIONS("-DLIBDIR=\\\"${CMAKE_INSTALL_PREFIX}/${LIBDIR}\\\"")

#PLUGINS
SET(PLUGINDIR "lib/${MAIN_DIR_NAME}${TAG_VERSION}/plugins/")
ADD_DEFINITIONS("-DPLUGINDIR=\\\"${CMAKE_INSTALL_PREFIX}/${PLUGINDIR}\\\"")

#INCLUDE
SET(INCLUDEDIR "include/${MAIN_DIR_NAME}${TAG_VERSION}/")
#NO ADD DEFINITIONS, WE ONLY INSTALL WITH IT

#RPATH
set(CMAKE_INSTALL_RPATH ${PLUGINDIR})

# Set the XDG mime stuff
SET(MIMEDIR "share/mime/packages/")


#BUILD SETUP
#Convert our simpler command line option to the CMake style
#None, Debug, Release, .. or custom ones
# SET(WANT_DEBUG 1)
IF(WANT_DEBUG)
  SET(CMAKE_BUILD_TYPE Debug)
ELSE(WANT_DEBUG)
  SET(CMAKE_BUILD_TYPE RELEASE)
ENDIF(WANT_DEBUG)

#Based on our build type, setup our build options
IF(APPLE)
  SET( ENV{MACOSX_DEPLOYMENT_TARGET} 10.3 ) 
  SET( ENV{LD_PREBIND} 1 )
  SET( ENV{LD_PREBIND_ALLOW_OVERLAP} 1 )
  SET(CMAKE_CXX_FLAGS_DEBUG "-O2 -g3 -fno-inline-functions -Wall")
  SET(CMAKE_C_FLAGS_DEBUG "-O2 -g3 -fno-inline-functions -Wall")
ELSE(APPLE)
  SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -Wall -fstrict-aliasing")
  SET(CMAKE_C_FLAGS_DEBUG "-O0 -g3 -Wall -fstrict-aliasing")
ENDIF(APPLE)

SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -Wall")
SET(CMAKE_C_FLAGS_RELEASE "-O2 -Wall")

#Test for endianess
INCLUDE (${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
TEST_BIG_ENDIAN(WORDS_BIGENDIAN)



#FIND DEPENDENCIES

#<< Qt
SET (QT_MT_REQUIRED true)
SET (QT_MIN_VERSION "4.1.0")
SET( QT_USE_QT3SUPPORT TRUE)
SET( QT_USE_QTXML TRUE )
IF (APPLE)
  SET( QT_USE_QTSQL TRUE )
ENDIF (APPLE)
SET( QT_USE_QTNETWORK TRUE )
FIND_PACKAGE(Qt4 REQUIRED)
INCLUDE( ${QT_USE_FILE} )
IF (QT_FOUND)
  MESSAGE("Qt4 Found OK")
  #Add our Qt definitions
  ADD_DEFINITIONS(
    ${QT_DEFINITIONS}
    -DQT_CORE_LIB
    -DQT_GUI_LIB
    -DQT_THREAD_LIB
    -DQT_XML_LIB
  )
ELSE(QT_FOUND)
  MESSAGE(FATAL_ERROR "No Qt4 found")
ENDIF(QT_FOUND)
#>> Qt

#<< PNG, JPEG, TIFF
FIND_PACKAGE(PNG REQUIRED)
IF (PNG_FOUND)
  MESSAGE("PNG Library Found OK")
ENDIF(PNG_FOUND)
FIND_PACKAGE(JPEG REQUIRED)
IF (JPEG_FOUND)
  MESSAGE("JPEG Library Found OK")
ENDIF(JPEG_FOUND)
FIND_PACKAGE(TIFF REQUIRED)
IF (TIFF_FOUND)
  MESSAGE("TIFF Library Found OK")
  SET(HAVE_TIFF 1)
ELSE(TIFF_FOUND)
  MESSAGE(FATAL_ERROR "Could not find the TIFF Library")
ENDIF(TIFF_FOUND)
FIND_PACKAGE(ZLIB REQUIRED)
IF (ZLIB_FOUND)
  MESSAGE("ZLIB Library Found OK")
  SET(HAVE_LIBZ 1)
ENDIF(ZLIB_FOUND)
FIND_PACKAGE(PythonLibs REQUIRED)
IF (PYTHON_LIBRARY)
  MESSAGE("Python Library Found OK")
  SET(HAVE_PYTHON 1)
  SET(COMPILE_PYTHON 1)
ENDIF(PYTHON_LIBRARY)
#>> PNG, JPEG, TIFF

#<< FreeType2
SET(FREETYPE_DIR ${CMAKE_MODULE_PATH})
FIND_PACKAGE(FREETYPE REQUIRED)
IF (FREETYPE_FOUND)
  MESSAGE("FreeType2 Library Found OK")
  INCLUDE(CheckLibraryExists)
  CHECK_LIBRARY_EXISTS(libfreetype.so FT_Get_First_Char "" HAVE_FREETYPE_FIRST)
  CHECK_LIBRARY_EXISTS(libfreetype.so FT_Get_Next_Char "" HAVE_FREETYPE_NEXT)
ENDIF(FREETYPE_FOUND)
#FIXME: if cflags empty add, otherwise replace as now
SET(CFLAGS "${LIBFREETYPE_CFLAGS}")
#>> FreeType2

#<<Render Library
# Select our rendering library
# As of Scribus 1.3.5, we can use cairo or Qt4's Arthur
# If we have a RENDER_LIB selected from a previous cmake run, then use it
# otherwise, we should be defaulting to Libart_LGPL for 1.3.4.x
IF(RENDER_LIB)
  MESSAGE(STATUS "Previously selected rendering system: ${RENDER_LIB}")
ELSE(RENDER_LIB)
  IF (NOT WANT_CAIRO)
    SET(WANT_QTARTHUR 1)
  ENDIF (NOT WANT_CAIRO)
ENDIF(RENDER_LIB)

IF (WANT_CAIRO OR RENDER_LIB STREQUAL "CAIRO")
  SET(CAIRO_DIR ${CMAKE_MODULE_PATH})
  FIND_PACKAGE(CAIRO)
  IF(CAIRO_FOUND)
    MESSAGE("CAIRO Library Found OK")
    SET(RENDER_LIB "CAIRO" CACHE TYPE STRING)
  ELSE(CAIRO_FOUND)
    SET(OLDRENDERLIBLOST TRUE)
  ENDIF(CAIRO_FOUND)
ENDIF (WANT_CAIRO OR RENDER_LIB STREQUAL "CAIRO")

IF (OLDRENDERLIBLOST OR WANT_QTARTHUR OR RENDER_LIB STREQUAL "QTARTHUR" OR NOT RENDER_LIB)
  SET(RENDER_LIB "QTARTHUR" CACHE TYPE STRING)
  MESSAGE("Qt4's Arthur selected for renderer")
  IF (OLDRENDERLIBLOST)
    MESSAGE("CAIRO could no longer be found, replaced by Qt4's Arthur")
  ENDIF (OLDRENDERLIBLOST)
ENDIF (OLDRENDERLIBLOST OR WANT_QTARTHUR OR RENDER_LIB STREQUAL "QTARTHUR" OR NOT RENDER_LIB)
#>>Render Library

#<<CUPS
IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.5)
  SET(Cups_DIR ${CMAKE_MODULE_PATH})
ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.5)
FIND_PACKAGE(Cups REQUIRED)
IF(CUPS_FOUND)
  SET(HAVE_CUPS 1)
  MESSAGE("CUPS Library Found OK")
ENDIF(CUPS_FOUND)
#>>CUPS

#<<LibXML2
IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.5)
  SET(LibXml2_DIR ${CMAKE_MODULE_PATH})
ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.5)
FIND_PACKAGE(LibXml2 REQUIRED)
IF(LIBXML2_FOUND)
  SET(HAVE_XML 1)
  MESSAGE("LIBXML2 Library Found OK")
ENDIF(LIBXML2_FOUND)
#>>LibXML2

#<<LittleCMS
SET(LCMS_DIR ${CMAKE_MODULE_PATH})
FIND_PACKAGE(LCMS REQUIRED)
IF(LCMS_FOUND)
  SET(HAVE_CMS 1)
  SET(CMS_INC "lcms.h")
  MESSAGE("LittleCMS Library Found OK")
ELSE(LCMS_FOUND)
  MESSAGE(FATAL_ERROR "Could not find the LittleCMS Library")
ENDIF(LCMS_FOUND)
#>>LittleCMS

#<<FontConfig
SET(FONTCONFIG_DIR ${CMAKE_MODULE_PATH})
FIND_PACKAGE(FONTCONFIG)
IF(FONTCONFIG_FOUND)
        MESSAGE("FontConfig Found OK")
        SET(HAVE_FONTCONFIG 1)
ENDIF(FONTCONFIG_FOUND)
#>>FontConfig

#<<Test for existing include files
INCLUDE(CheckIncludeFile)

CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DLFCN_H)
IF(HAVE_DLFCN_H)
  ADD_DEFINITIONS(-DHAVE_DLFCN_H)
ENDIF(HAVE_DLFCN_H)

CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
IF(HAVE_UNISTD_H)
  ADD_DEFINITIONS(-DHAVE_UNISTD_H)
ENDIF(HAVE_UNISTD_H)

CHECK_INCLUDE_FILE("sys/types.h" HAVE_SYS_TYPES_H)
# IF(HAVE_SYS_TYPES_H)
#   ADD_DEFINITIONS(-DHAVE_SYS_TYPES_H)
# ENDIF(HAVE_SYS_TYPES_H)

CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H)
# IF(HAVE_SYS_STAT_H)
#   ADD_DEFINITIONS(-DHAVE_SYS_STAT_H)
# ENDIF(HAVE_SYS_STAT_H)
#>>Test for existing include files


#Create configure files.. config.h and uninstall
#config.h
INCLUDE (ConfigureChecks.cmake)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
ADD_DEFINITIONS("-DHAVE_CONFIG_H")

#Set up uninstall
CONFIGURE_FILE(
  "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  IMMEDIATE @ONLY
)

ADD_CUSTOM_TARGET(uninstall
  "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")

#Set up include dirs with all found packages
INCLUDE_DIRECTORIES(
  ${CMAKE_BINARY_DIR}
  ${CMAKE_BINARY_DIR}/scribus
  ${QT_INCLUDES}
  ${CUPS_INCLUDE_DIR}
  ${FREETYPE_INCLUDE_DIR}
  ${FONTCONFIG_INCLUDE_DIR}
  ${LCMS_INCLUDE_DIR}
  ${LIBXML2_INCLUDE_DIR}
  ${PYTHON_INCLUDE_PATH}
  ${TIFF_INCLUDE_DIR}
  ${ZLIB_INCLUDE_DIR}
)

#Add our source subdirs
ADD_SUBDIRECTORY(scribus)

#Install our READMEs etc.
INSTALL(FILES
  AUTHORS
  BUILDING
  ChangeLog
  ChangeLogCVS
  COPYING
  INSTALL
  NEWS
  PACKAGING
  README
  README.MacOSX
  TODO
  DESTINATION ${DOCDIR}
)

#Install our MIME data
INSTALL(FILES
  scribus.xml
  DESTINATION ${MIMEDIR}
)

#Install the desktop file
INSTALL(FILES
  scribus.desktop
  DESTINATION ${DESKTOPDIR}
)

#If building an Apple bundle, install these specific files
IF(APPLEBUNDLE)
  INSTALL(FILES
    Scribus.app/Contents/Info.plist
    DESTINATION ${CMAKE_INSTALL_PREFIX}
  )
  INSTALL(FILES
    Scribus.app/Contents/Resources/Scribus.icns
    Scribus.app/Contents/Resources/Scribus-doc.icns
    DESTINATION ${CMAKE_INSTALL_PREFIX}/Resources
  )
ENDIF(APPLEBUNDLE)

# If the cmake version includes cpack, use it for tarball building
IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
  SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Scribus is an open source publishing application for Linux, Mac OSX and Windows")
  SET(CPACK_PACKAGE_VENDOR "Scribus Team")
  SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
  SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/README")
  SET(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
  SET(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
  SET(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}")
  SET(CPACK_PACKAGE_INSTALL_DIRECTORY "Scribus ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
  SET(CPACK_PACKAGE_EXECUTABLES "scribus${TAG_VERSION}")
  SET(CPACK_SOURCE_PACKAGE_FILE_NAME "scribus-${VERSION}")
  SET(CPACK_SOURCE_GENERATOR TBZ2)

  SET(CPACK_SOURCE_IGNORE_FILES
    CMakeCache.txt
    scribus-1.3.5cvs.tar.bz2
    scribus-1.3.5cvs.tar.Z
    scribus-1.3.5cvs.tar.gz
    "~$"
    "\\\\.cvsignore$"
    "\\\\.o$"
    "^${PROJECT_SOURCE_DIR}.*/CVS/"
    "^${PROJECT_SOURCE_DIR}/debian/"
    "^${PROJECT_SOURCE_DIR}/old/"
    "^${PROJECT_SOURCE_DIR}.*/CVSROOT/"
    "^${PROJECT_SOURCE_DIR}/admin/"
  )
  INCLUDE(CPack)
ENDIF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")