]> git.lyx.org Git - lyx.git/blobdiff - CMakeLists.txt
Added doxygen target if found doxygen executable
[lyx.git] / CMakeLists.txt
index de0df1f4c174b1441fb2795733aaa61d09ea2eab..367726bb54dbdec58ecb357f3abc6d18f2b0a4c8 100644 (file)
@@ -6,6 +6,7 @@
 
 cmake_minimum_required(VERSION 2.6.4)
 
+
 set(LYX_PROJECT lyx)
 
 set(LYX_CMAKE_DIR "development/cmake")
@@ -36,6 +37,10 @@ set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
 # Supress regeneration
 set(CMAKE_SUPPRESS_REGENERATION FALSE)
 
+if(NOT help AND NOT HELP)
+       # 'project' triggers the searching for a compiler
+       project(${LYX_PROJECT})
+endif()
 
 include(LyXMacros)
 
@@ -51,12 +56,14 @@ LYX_OPTION_INIT()
 # Options for all compilers/systems
 LYX_OPTION(CPACK            "Use the CPack management (Implies LYX_INSTALL option)" OFF ALL)
 LYX_OPTION(INSTALL          "Build install projects/rules (implies a bunch of other options)" OFF ALL)
-LYX_OPTION(NLS              "Use nls" ON ALL)
+LYX_OPTION(NLS              "Enable Native Language Support (NLS)" ON ALL)
 LYX_OPTION(ASPELL           "Require aspell" OFF ALL)
 LYX_OPTION(ENCHANT          "Require Enchant" OFF ALL)
 LYX_OPTION(HUNSPELL         "Require Hunspell" OFF ALL)
 LYX_OPTION(DEVEL_VERSION    "Build developer version" OFF ALL) 
 LYX_OPTION(RELEASE          "Build release version, build debug when disabled" OFF ALL)
+LYX_OPTION(DEBUG            "Enforce debug build"  OFF ALL)
+LYX_OPTION(NO_OPTIMIZE      "Don't use any optimization/debug flags"  OFF ALL)
 LYX_OPTION(PACKAGE_SUFFIX   "Use version suffix for packaging" ON ALL)
 LYX_OPTION(PCH              "Use precompiled headers" OFF ALL)
 LYX_OPTION(MERGE_FILES      "Merge source files into one compilation unit" OFF ALL)
@@ -81,6 +88,9 @@ LYX_OPTION(WALL                  "Enable all warnings" OFF MSVC)
 LYX_OPTION(CONFIGURE_CHECKS      "Also run configure checks for MSVC" OFF MSVC)
 LYX_OPTION(DEPENDENCIES_DOWNLOAD "Download dependencies for MSVC 10" OFF MSVC)
 
+# APPLE specific
+LYX_OPTION(DMG                   "Build as Mac bundle, needed for .dmg  (experimental) " OFF MAC)
+LYX_OPTION(COCOA                 "Use Cocoa on Mac" OFF MAC)
 
 if(help OR HELP)
        message(STATUS)
@@ -90,9 +100,6 @@ if(help OR HELP)
        message(STATUS)
 else()
 
-# 'project' triggers the searching for a compiler
-project(${LYX_PROJECT})
-
 
 # Check option dependencies
 
@@ -111,6 +118,7 @@ if(LYX_INSTALL)
        set(LYX_PROFILE OFF)
 endif()
 
+
 if(LYX_MERGE_FILES)
        set(LYX_PCH OFF)
 else()
@@ -136,6 +144,7 @@ if(LYX_DEPENDENCIES_DOWNLOAD)
 endif()
 
 
+
 message(STATUS)
 
 set(EXECUTABLE_OUTPUT_PATH  ${TOP_BINARY_DIR}/bin)
@@ -203,7 +212,22 @@ foreach(_c_l ${_config_lines} )
 endforeach(_c_l)
 
 
-if (LYX_INSTALL_PREFIX)
+if(LYX_DMG)
+    set(bundle_dir ${TOP_BINARY_DIR}/bin)
+       set(LYX_CPACK 1)
+       set(LYX_BUNDLE MACOSX_BUNDLE)
+       set(LYX_INSTALL_PREFIX LyX2.1 CACHE STRING "LyX bundle install prefix" FORCE)
+       set(LYX_DATA_SUBDIR LyX.app/Contents/Resources/ CACHE STRING "Bundle Contents dir" FORCE)
+       message(STATUS)
+       message(STATUS "Bundle creation is enabled.")
+       message(STATUS "It is experimental, to increase turn around speed use:")
+       message(STATUS "    cmake -DLYX_MERGE_FILES=1 -DLYX_NO_OPTIMIZE=1 -DLYX_INSTALL=1 -DLYX_DMG=1 ../trunk")
+       message(STATUS "or use the shell script 'developent/cmake/dmg'")
+       message(STATUS)
+endif()
+
+
+if(LYX_INSTALL_PREFIX)
        set(CMAKE_INSTALL_PREFIX ${LYX_INSTALL_PREFIX} CACHE PATH "LyX user's choice install prefix" FORCE)
        set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
 endif()
@@ -238,10 +262,12 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
        endif()
 endif()
 
-if (WIN32)
-       set(LYX_DATA_SUBDIR "Resources/" CACHE STRING "Subdirectory for all lyx-system-data" FORCE)
-else()
-       set(LYX_DATA_SUBDIR "" CACHE STRING "Subdirectory for all lyx-system-data" FORCE)
+if(NOT LYX_DATA_SUBDIR)
+       if (WIN32)
+               set(LYX_DATA_SUBDIR "Resources/" CACHE STRING "Subdirectory for all lyx-system-data" FORCE)
+       else()
+               set(LYX_DATA_SUBDIR "" CACHE STRING "Subdirectory for all lyx-system-data" FORCE)
+       endif()
 endif()
 
 set(LYX_ABS_INSTALLED_DATADIR "${CMAKE_INSTALL_PREFIX}")
@@ -250,6 +276,7 @@ set(LYX_ABS_INSTALLED_LOCALEDIR "${LYX_ABS_INSTALLED_DATADIR}/${LYX_DATA_SUBDIR}
 set(LYX_ABS_TOP_SRCDIR "${TOP_SRC_DIR}")
 
 
+
 if(NOT GROUP_CODE)
        #set(GROUP_CODE "The Golden Code")
        set(GROUP_CODE flat)
@@ -260,7 +287,6 @@ set(LYX_CPP_FILES *.cpp)
 set(LYX_HPP_FILES *.h)
 set(LYX_MOC_FILES moc_*.cpp)
 
-
 include(ProjectSourceGroup)
 
 
@@ -269,12 +295,19 @@ if(LYX_PROFILE)
        set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg" CACHE TYPE STRING FORCE)
 endif()
 
-if(LYX_RELEASE)
-       set(CMAKE_BUILD_TYPE Release CACHE STRING "Build release version" FORCE)
+
+if(LYX_NO_OPTIMIZE)
+       set(CMAKE_BUILD_TYPE None)
+       set(LYX_DEBUG OFF)
+       set(LYX_RELEASE OFF)
+elseif(LYX_RELEASE)
+       set(CMAKE_BUILD_TYPE Release)
+       set(LYX_DEBUG OFF)
 else()
-       set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build debug version" FORCE)
+       set(CMAKE_BUILD_TYPE Debug)
 endif()
 
+
 # When shared libs are supported enable this option
 #LYX_OPTION(SHARED_LIBRARIES "Build shared libraries" OFF ALL)
 if(LYX_SHARED_LIBRARIES)
@@ -306,8 +339,7 @@ endif()
 
 
 find_package(Qt4 REQUIRED)
-find_package(ICONV REQUIRED)
-find_package(ZLIB REQUIRED)
+
 
 include_directories(${TOP_BINARY_DIR} ${TOP_SRC_DIR}/src)
   
@@ -336,18 +368,23 @@ if(LYX_NLS)
        add_subdirectory(po "${TOP_BINARY_DIR}/po")
 endif()
 
-if(LYX_EXTERNAL_LIBINTL)
-       find_package(Libintl REQUIRED)
-       # find getext when configuring
-       list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBINTL_LIBRARIES})
-else()
-       if(LYX_NLS)
-               add_subdirectory(intl "${TOP_BINARY_DIR}/intl")
+if(LYX_NLS)
+       if(LYX_EXTERNAL_LIBINTL)
+               find_package(Libintl REQUIRED)  
+               if(DEFINED LIBINTL_LIBRARIES)
+                       # find getext when configuring
+                       list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBINTL_LIBRARIES})      
+                       # on mac use iconv also form ports
+                       get_filename_component(ICONV_RELATIVE_TO_LIBINTL ${LIBINTL_LIBRARIES} PATH)
+               endif()
        else()
-               # do not compile if nls disabled
+               add_subdirectory(intl "${TOP_BINARY_DIR}/intl")
        endif()
 endif()
 
+find_package(ICONV REQUIRED)
+find_package(ZLIB REQUIRED)
+
 if(LYX_EXTERNAL_BOOST)
        message(STATUS "Searching for boost")
        find_package(Boost COMPONENTS signals regex) #TODO could REQUIRED be used
@@ -528,6 +565,7 @@ if(LYX_INSTALL)
        include(../Install)
 endif()
 
+add_subdirectory(sourcedoc "${TOP_BINARY_DIR}/sourcedoc")
 
 message(STATUS)
 message(STATUS "Build options, switch LYX_* variables by -DLYX_*=1 or 0:")
@@ -535,6 +573,27 @@ message(STATUS)
 LYX_OPTION_LIST_ALL(used)
 
 
+if(LYX_NLS)
+       message(STATUS)
+       message(STATUS "Building Native Language Support (LYX_NLS is set), used libraries:")
+       message(STATUS)
+       message(STATUS "  * intl")
+       message(STATUS "     - header : ${LIBINTL_HEADER}")
+       message(STATUS "     - library: ${LIBINTL_LIBRARIES}")
+       message(STATUS "  * iconv")
+       message(STATUS "     - header : ${ICONV_HEADER}")
+       message(STATUS "     - library: ${ICONV_LIBRARY}")
+       message(STATUS "  * zlib")
+       message(STATUS "     - header : ${ZLIB_HEADER}")
+       message(STATUS "     - library: ${ZLIB_LIBRARY}")
+       message(STATUS)
+endif()
+
+
+# CPack packaging
+#
+# http://cmake.org/cmake/help/cmake-2-8-docs.html#module:CPack
+
 set(CPACK_PACKAGE_VERSION_MAJOR "${LYX_MAJOR_VERSION}")
 set(CPACK_PACKAGE_VERSION_MINOR "${LYX_MINOR_VERSION}")
 FILE(STRINGS "${TOP_SRC_DIR}/${LYX_CMAKE_DIR}/LyX_summary.txt" CPACK_PACKAGE_DESCRIPTION_SUMMARY)
@@ -592,6 +651,47 @@ endif()
 # so we do not provide infofiles for
 # CPACK_RESOURCE_FILE_README and CPACK_RESOURCE_FILE_WELCOME
 
+if(WIN32)
+       set(CPACK_GENERATOR NSIS ZIP)
+       set(CPACK_BINARY_ZIP 1)
+endif()
+
+
+set(CPACK_STRIP_FILES 1)
+
+# sources
+set(CPACK_SOURCE_INSTALLED_DIRECTORIES "${TOP_SRC_DIR};/") # http://www.mail-archive.com/cmake@cmake.org/msg33720.html
+set(CPACK_SOURCE_GENERATOR TGZ ZIP TBZ2)
+
+
+if(LYX_DMG)
+       set(CPACK_PACKAGE_NAME LyX)
+       set(CPACK_GENERATOR DragNDrop)
+       
+       # We start from bin/lyx.app, all is build into the final bundle folder
+       # On Mac the paths to required shared libraries are hardcoded in the
+       # binary/library. This is fixed by the macro 'fixup_bundle' 
+       # Hardcoded pathes to libraries are resolved automatically
+
+       
+       set(app          ${bundle_dir}/LyX.app)
+       set(contents_dir LyX.app/Contents/)
+       install(DIRECTORY "${QT_PLUGINS_DIR}/imageformats" DESTINATION ${bundle_dir}/${contents_dir}/plugins COMPONENT Runtime)
+       
+       message(STATUS "Qt Plugins: ${QT_PLUGINS_DIR}/imageformats DESTINATION ${bundle_dir}/${contents_dir}/plugins")
+       
+       install(CODE 
+               "file(GLOB qt_plugins \"${bundle_dir}/${contents_dir}/plugins/imageformats/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
+               include(BundleUtilities)
+               fixup_bundle(\"${app}\" \"\${qt_plugins}\" \"${dir}\") "
+               COMPONENT RUNTIME)
+       
+       file(WRITE ${CMAKE_BINARY_DIR}/qt.conf "")
+       install(FILES ${CMAKE_BINARY_DIR}/qt.conf DESTINATION ${contents_dir}/Resources COMPONENT Runtime)
+       
+endif()
+
+
 if(LYX_CPACK)
        include(CPack)
 endif()