Source

AncientDocumentEditor / documentImageCreator / src / gui / AncientDocumentEditor / CMakeLists.txt

cmake_minimum_required(VERSION 2.8)

PROJECT(AncientDocumentEditor)
SET( CMAKE_COLOR_MAKEFILE ON )
SET( CMAKE_VERBOSE_MAKEFILE ON )


set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")

find_package(Qt4 4.4.3  REQUIRED )


SET( QT_USE_QTXML TRUE )
SET( QT_USE_QTXMLPATTERNS TRUE )
SET( QT_USE_QTNETWORK TRUE )
  

FIND_LIBRARY(Lipsum4Qt_LIBRARIES Lipsum4Qt)

message(${Lipsum4Qt_LIBRARIES})

FIND_LIBRARY(DocumentCreator_LIBRARIES DocumentCreator REQUIRED)
include_directories(/usr/local/include/DocumentCreator REQUIRED)

INCLUDE( ${QT_USE_FILE} )


file(
GLOB_RECURSE
AncientDocumentCreator_moc
src/ancientdocumenteditor.h
src/Document/documentpropertiesview.h
src/Document/graphicsblockitem.h
src/Document/graphicscharacteritem.h
src/Document/graphicsimageblockitem.h
src/Document/graphicsmovablebutton.h
src/Document/graphicstextblockitem.h
src/Document/graphicview.h
src/Document/lipsum.h
src/Document/textview.h
src/FontEditor/chareditcursoritem.h
src/FontEditor/chareditlineitem.h
src/FontEditor/chareditscene.h
src/FontEditor/chareditview.h
src/FontEditor/fonteditorview.h
src/Utils/characterlistview.h
src/VirtualKeyboard/characterbuttonview.h
src/VirtualKeyboard/controlbuttonview.h
src/VirtualKeyboard/keyboardview.h
src/VirtualKeyboard/keyboardviewxmlbuilder.h
src/RandomDocument/RandomDocumentCreator.h
src/*.hpp
)

file(
	GLOB_RECURSE
	AncientDocumentCreator_sources
	src/*
)

file(
	GLOB_RECURSE
	AncientDocumentCreator_ui
	src/*.ui
)


set(fontfolder ../../../font)
set(backgroundfolder ../../../background)
set(xmlcheckerfolder ../../../xmlchecker)
set(formatsfolder ../../../keyboard)

CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/application.ini.in
               ${CMAKE_CURRENT_SOURCE_DIR}/src/application.ini
               @ONLY)


file(
        GLOB_RECURSE
        AncientDocumentCreator_rcs
        src/*.qrc
)




set( APP_ICON ${CMAKE_CURRENT_SOURCE_DIR}/adoc.icns )
message("ICON")
message(${APP_ICON})
IF( APPLE )
    SET( PROGNAME AncientDocumentEditor )
    SET( MACOSX_BUNDLE_ICON_FILE adoc.icns )
    SET_SOURCE_FILES_PROPERTIES(${APP_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
    SET( MACOSX_BUNDLE_SHORT_VERSION_STRING 0.1 )
    SET( MACOSX_BUNDLE_VERSION 0.7-beta2 )
    SET( MACOSX_BUNDLE_LONG_VERSION_STRING Version 0.1 )
    #SET( CMAKE_OSX_ARCHITECTURES i686 ) #Comment out if not universal binary
ELSE( APPLE )
    SET( PROGNAME AncientDocumentEditor )
ENDIF( APPLE )

  if( UNIX AND NOT APPLE )
    if( NOT DESKTOP_ENTRY )
      set( DESKTOP_ENTRY AncientDocumentEditor.desktop )
    endif( NOT DESKTOP_ENTRY )
	
	set(CMAKE_INSTALL_PREFIX /usr/local/)

    add_custom_command( OUTPUT ${DESKTOP_ENTRY}
      COMMAND touch ${DESKTOP_ENTRY}
      COMMAND sh ${CMAKE_SOURCE_DIR}/adoc-desktop.sh ${CMAKE_INSTALL_PREFIX} >${DESKTOP_ENTRY}
      DEPENDS adoc-desktop.sh
      COMMENT "Generating desktop entry file"
      )
    add_custom_target( DESKTOP_ENTRY_FILE ALL
      DEPENDS ${DESKTOP_ENTRY}
      )
  endif( UNIX AND NOT APPLE )




QT4_ADD_RESOURCES(RCS ${AncientDocumentCreator_rcs} )
QT4_WRAP_UI(UI ${AncientDocumentCreator_ui})
QT4_WRAP_CPP(MOC ${AncientDocumentCreator_moc})

INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} )
INCLUDE_DIRECTORIES( ./src )

SET(EXTRA_LIBS  ${QT_LIBRARIES} ${Lipsum4Qt_LIBRARIES} ${DocumentCreator_LIBRARIES})


 #IF( APPLE )
 #   ADD_EXECUTABLE(${PROGNAME} MACOSX_BUNDLE ${AncientDocumentCreator_sources}  ${MOC} ${RCS} ${UI})
 #   ADD_CUSTOM_COMMAND( TARGET ${PROGNAME} POST_BUILD
 #     #COMMAND mkdir ARGS ${CMAKE_CURRENT_BINARY_DIR}/${PROGNAME}.app/Contents/Resources
 #     COMMAND cp ARGS ${CMAKE_SOURCE_DIR}/${MACOSX_BUNDLE_ICON_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${PROGNAME}.app/Contents/Resources
#      #COMMAND cp -r src/images ${CMAKE_CURRENT_BINARY_DIR}/${PROGNAME}.app/Contents/Resources
#      #COMMAND cp  application.ini ${CMAKE_CURRENT_BINARY_DIR}/${PROGNAME}.app/Contents/Resources
#    )
#  ELSE( APPLE )
    #ADD_EXECUTABLE(${PROGNAME} ${AncientDocumentCreator_sources}  ${MOC} ${RCS} ${UI})
SET(ALL_SOURCES ${AncientDocumentCreator_sources}  ${MOC} ${RCS} ${UI} ${APP_ICON})
ADD_EXECUTABLE(${PROGNAME} MACOSX_BUNDLE
        ${ALL_SOURCES}
)

#    if(UNIX AND NOT APPLE)
#       INSTALL( TARGETS ${PROGNAME} DESTINATION bin )
#       install( FILES ${APP_ICON} DESTINATION share/icons )
#	INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${DESKTOP_ENTRY} DESTINATION share/applications)
 #   endif(UNIX AND NOT APPLE)
 # ENDIF( APPLE )


TARGET_LINK_LIBRARIES(${PROGNAME} ${EXTRA_LIBS})

##########################################################################################
##########################################################################################
##########################################################################################
## PACKAGING

SET(NAME ${PROGNAME})

#--------------------------------------------------------------------------------
# def des variable necesaires :
# APPS : est utilisé pour CPack
SET(plugin_dest_dir bin)
SET(qtconf_dest_dir bin)
SET(APPS "\${CMAKE_INSTALL_PREFIX}/bin/${NAME}")
IF(APPLE)
SET(plugin_dest_dir ${NAME}.app/Contents)
SET(qtconf_dest_dir ${NAME}.app/Contents/Resources)
SET(APPS "\${CMAKE_INSTALL_PREFIX}/${NAME}.app")
ENDIF(APPLE)
IF(WIN32)
SET(APPS "\${CMAKE_INSTALL_PREFIX}/bin/${NAME}.exe")
ENDIF(WIN32)


#--------------------------------------------------------------------------------
# Installation de QtTest, sure apple, le bundle se trouve à la racine,
# sur les autres plate-forme dans bin
INSTALL(TARGETS ${NAME}
BUNDLE DESTINATION . COMPONENT Runtime
RUNTIME DESTINATION bin COMPONENT Runtime
)

#--------------------------------------------------------------------------------
# On copie le dossier de plugins QT dans le bundle courant

INSTALL(DIRECTORY "${QT_PLUGINS_DIR}/imageformats" DESTINATION ${plugin_dest_dir}/plugins COMPONENT Runtime)


#if(APPLE)
#set(DoQuBook_plugins /Library/Frameworks/DoQuBook.framework/PlugIns/)
#INSTALL(DIRECTORY ${DoQuBook_plugins} DESTINATION ${plugin_dest_dir}/DoQuBook_plugins COMPONENT Runtime)
#endif(APPLE)
#message(DoQuBookPlugins_DIR = ${DoQuBook_plugins})

#--------------------------------------------------------------------------------
# installation du qt.conf
# on insert du code cmake pour écrire le fichier dans le script d'installation

INSTALL(CODE "
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"\")
" COMPONENT Runtime)

## On install les fichiers de conf dans le bundle :
MESSAGE(${Lipsum4Qt_LIBRARIES})
MESSAGE(${NAME}.app/Contents/Frameworks)

install (FILES ${Lipsum4Qt_LIBRARIES} DESTINATION ${NAME}.app/Contents/Frameworks)

#--------------------------------------------------------------------------------
# On copie le qt_menu.nib de QT dans le bundle courant
IF(APPLE)
install (DIRECTORY ${QT_LIBRARY_DIR}/QtGui.framework/Resources/qt_menu.nib DESTINATION ${NAME}.app/Contents/Resources)
#--------------------------------------------------------------------------------
# Grace a BundleUtilities on peux copier les libs nécessaire dans la partie
# Frameworks du bundle



#install (FILES ${CMAKE_CURRENT_BINARY_DIR}/application.ini DESTINATION ${NAME}.app/Contents/MacOS/)
install (DIRECTORY ${fontfolder} DESTINATION ${NAME}.app/Contents/Resources)
install (DIRECTORY ${backgroundfolder} DESTINATION ${NAME}.app/Contents/Resources)
install (DIRECTORY ${xmlcheckerfolder} DESTINATION ${NAME}.app/Contents/Resources)
install (DIRECTORY ${formatsfolder} DESTINATION ${NAME}.app/Contents/Resources)

# Répèrtoire à regarder pour les dépendance
SET(DIRS ${QT_LIBRARY_DIRS} ${EXTRA_LIBS} /usr/local/lib/)

# on insert du code cmake pour utiliser BundleUtilities dans le script d'installation
INSTALL(CODE "
file(GLOB_RECURSE QTPLUGINS
\"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/plugins/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
include(BundleUtilities)
SET(PLUGINS \${QTPLUGINS})
fixup_bundle(\"${APPS}\" \"\${PLUGINS}\" \"${DIRS}\")
" COMPONENT Runtime)

endif(APPLE)

# on utilise cpack : "cpack -G DragNDrop CPackConfig.cmake" sur mac os x
# le CPackConfig.cmake est créer par un premier cmake
# Command osx /Applications/CMake\ 2.8-1.app/Contents/bin/cpack -G DragNDrop CPackConfig.cmake
SET(CPACK_GENERATOR "DragNDrop")
#set(CPACK_BINARY_DRAGNDROP ON)
include(CPack)