Subversion Repositories Scribus

Rev

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

#CMAKE SETUP
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.1)
SET(CMAKE_COLOR_MAKEFILE ON)
SET(CMAKE_VERBOSE_MAKEFILE ON)
SET(CMAKE_INCLUDE_CURRENT_DIR TRUE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
SET(CMAKE_SKIP_RULE_DEPENDENCY TRUE)

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 (VERSION_MAJOR "1")
SET (VERSION_MINOR "3")
SET (VERSION_PATCH "4")
SET (VERSION_SUFFIX "cvs")
SET (VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${VERSION_SUFFIX})
MESSAGE(STATUS "Scribus ${VERSION} will be built to install into ${CMAKE_INSTALL_PREFIX}")

SET(PLUGIN_PERMISSIONS WORLD_EXECUTE GROUP_EXECUTE OWNER_EXECUTE WORLD_READ GROUP_READ OWNER_READ OWNER_WRITE)

SET(MAIN_DIR_NAME "scribus")
IF (WANT_VERSIONING)
  IF (NOT CUSTOM_VERSIONTAG)
    SET(TAG_VERSION "-${VERSION}")
  ELSE (NOT CUSTOM_VERSIONTAG)
    SET(TAG_VERSION ${CUSTOM_VERSIONTAG})
  ENDIF (NOT CUSTOM_VERSIONTAG)
ENDIF (WANT_VERSIONING)

SET(MANDIR "man/")
SET(SHAREDIR "share/${MAIN_DIR_NAME}/")
ADD_DEFINITIONS("-DSHAREDIR=\\\"${CMAKE_INSTALL_PREFIX}/${SHAREDIR}\\\"")
SET(DOCDIR "share/doc/${MAIN_DIR_NAME}${TAG_VERSION}/")
ADD_DEFINITIONS("-DDOCDIR=\\\"${CMAKE_INSTALL_PREFIX}/${DOCDIR}\\\"")
SET(ICONDIR "share/${MAIN_DIR_NAME}${TAG_VERSION}/icons/")
ADD_DEFINITIONS("-DICONDIR=\\\"${CMAKE_INSTALL_PREFIX}/${ICONDIR}\\\"")
SET(SAMPLESDIR "share/${MAIN_DIR_NAME}${TAG_VERSION}/samples/")
ADD_DEFINITIONS("-DSAMPLESDIR=\\\"${CMAKE_INSTALL_PREFIX}/${SAMPLESDIR}\\\"")
SET(SCRIPTSDIR "share/${MAIN_DIR_NAME}${TAG_VERSION}/scripts/")
ADD_DEFINITIONS("-DSCRIPTSDIR=\\\"${CMAKE_INSTALL_PREFIX}/${SCRIPTSDIR}\\\"")
SET(TEMPLATEDIR "share/${MAIN_DIR_NAME}${TAG_VERSION}/templates/")
ADD_DEFINITIONS("-DTEMPLATEDIR=\\\"${CMAKE_INSTALL_PREFIX}/${TEMPLATEDIR}\\\"")
SET(LIBDIR "lib/${MAIN_DIR_NAME}${TAG_VERSION}/")
ADD_DEFINITIONS("-DLIBDIR=\\\"${CMAKE_INSTALL_PREFIX}/${LIBDIR}\\\"")
SET(PLUGINDIR "lib/${MAIN_DIR_NAME}${TAG_VERSION}/plugins/")
ADD_DEFINITIONS("-DPLUGINDIR=\\\"${CMAKE_INSTALL_PREFIX}/${PLUGINDIR}\\\"")
set(CMAKE_INSTALL_RPATH ${PLUGINDIR})

#BUILD SETUP
#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)

SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -Wall")
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g3 -Wall")
SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -Wall")
SET(CMAKE_C_FLAGS_RELEASE "-O2 -Wall")


INCLUDE (${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
TEST_BIG_ENDIAN(WORDS_BIGENDIAN)

#FIND DEPENDENCIES
# START QT
SET (QT_MT_REQUIRED true)
SET (QT_MIN_VERSION "3.3.4")
FIND_PACKAGE(Qt3 REQUIRED)
IF (QT_FOUND)
  MESSAGE("Qt3 Found OK (${qt_version_str})")
#   MESSAGE($ENV{QTDIR})
#   MESSAGE(${QT_MOC_EXECUTABLE})
#   MESSAGE(${QT_UIC_EXECUTABLE})
#   MESSAGE(${QT_QT_LIBRARY})
#   MESSAGE(${QT_INCLUDE_DIR})
#   MESSAGE(${qt_version_str})
#   MESSAGE(${qt_version_str_lib})
ELSE(QT_FOUND)
  MESSAGE(FATAL_ERROR "No Qt3")
ENDIF(QT_FOUND)
# END QT
# START 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)
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)

# START FREETYPE
SET(FREETYPE_DIR ${CMAKE_MODULE_PATH})
FIND_PACKAGE(FREETYPE REQUIRED)
IF (FREETYPE_FOUND)
  MESSAGE("FreeType2 Library Found OK")
  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}")
# END FREETYPE

# START LIBART_LGPL
SET(RENDER_LIB "")
IF (WANT_LIBART OR NOT WANT_CAIRO)
  SET(LIBART_LGPL_DIR ${CMAKE_MODULE_PATH})
  FIND_PACKAGE(LIBART_LGPL REQUIRED)
  SET(USE_LIBART 1)
  IF(LIBART_LGPL_FOUND)
    SET(RENDER_LIB "LIBART")
    MESSAGE("Libart_LGPL Library Found OK")
  ENDIF(LIBART_LGPL_FOUND)
ELSE (WANT_LIBART OR NOT WANT_CAIRO)
  # START CAIRO
  SET(CAIRO_DIR ${CMAKE_MODULE_PATH})
  FIND_PACKAGE(CAIRO)
  IF(CAIRO_FOUND)
    MESSAGE("CAIRO Library Found OK")
    SET(HAVE_CAIRO 1)
    SET(RENDER_LIB "CAIRO")
  ELSE(CAIRO_FOUND)
    SET(USE_LIBART 0)
  ENDIF(CAIRO_FOUND)
  # END CAIRO
ENDIF (WANT_LIBART OR NOT WANT_CAIRO)
# END LIBART_LGPL

IF(NOT RENDER_LIB)
  MESSAGE(FATAL_ERROR "ERROR: Neither LibArt_LGPL nor cairo have been selected or found, please correct and restart cmake")
ENDIF(NOT RENDER_LIB)


# START CUPS
SET(CUPS_DIR ${CMAKE_MODULE_PATH})
FIND_PACKAGE(CUPS REQUIRED)
IF(CUPS_FOUND)
  SET(HAVE_CUPS 1)
  MESSAGE("CUPS Library Found OK")
ENDIF(CUPS_FOUND)
# END CUPS

# START LIBXML2
SET(LIBXML2_DIR ${CMAKE_MODULE_PATH})
FIND_PACKAGE(LIBXML2 REQUIRED)
IF(LIBXML2_FOUND)
  SET(HAVE_XML 1)
  MESSAGE("LIBXML2 Library Found OK")
ENDIF(LIBXML2_FOUND)
# END LIBXML2

# START LCMS
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")
ENDIF(LCMS_FOUND)
# END LCMS

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

ADD_DEFINITIONS(${QT_DEFINITIONS})

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)


#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")
#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")

#Load our SCRIBUSQT package which gives us filename.moc instead of moc_filename.*
SET(SCRIBUSQT_DIR ${CMAKE_MODULE_PATH})
FIND_PACKAGE(SCRIBUSQT)

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

#Set up libraries to link with all found packages
LINK_LIBRARIES (
${QT_QT_LIBRARY}
${CUPS_LIBRARIES}
${FREETYPE_LIBRARIES}
${FONTCONFIG_LIBRARIES}
${LCMS_LIBRARIES}
${LIBXML2_LIBRARIES}
${PYTHON_LIBRARIES}
${TIFF_LIBRARIES}
${JPEG_LIBRARIES}
${ZLIB_LIBRARIES}
)

#Select Libart_LGPL or Cairo
IF(RENDER_LIB STREQUAL "LIBART")
  INCLUDE_DIRECTORIES(${LIBART_LGPL_INCLUDE_DIR})
  LINK_LIBRARIES(${LIBART_LGPL_LIBRARIES})
ENDIF(RENDER_LIB STREQUAL "LIBART")
IF(RENDER_LIB STREQUAL "CAIRO")
  INCLUDE_DIRECTORIES(${CAIRO_INCLUDE_DIR})
  LINK_LIBRARIES(${CAIRO_LIBRARIES})
ENDIF(RENDER_LIB STREQUAL "CAIRO")

IF(WIN32)
  LINK_LIBRARIES(
    ${QT_QTMAIN_LIBRARY}
  )
ENDIF(WIN32)

IF(WIN32)
  ADD_DEFINITIONS(-DQT_DLL)
ENDIF(WIN32)

#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
scribus.xml
  DESTINATION ${DOCDIR}
)

# If the cmake version includes cpack, use it
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${TAG_VERSION}")
  SET(CPACK_SOURCE_GENERATOR TBZ2)

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