X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=CMakeLists.txt;h=a98df1a2506f3e4c201970e469de014f56ac047e;hb=a80188fec4ff4cb1ff78e012c5a964cddeebc078;hp=a59282f51b7f2b64215dda912728513b40dac2c7;hpb=ce4cdf225884606e845513e2047ff4251f626908;p=lyx.git diff --git a/CMakeLists.txt b/CMakeLists.txt index a59282f51b..a98df1a250 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,8 +6,8 @@ cmake_minimum_required(VERSION 2.6.4) + set(LYX_PROJECT lyx) -project(${LYX_PROJECT}) set(LYX_CMAKE_DIR "development/cmake") set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/${LYX_CMAKE_DIR}/modules") @@ -17,13 +17,13 @@ get_filename_component(TOP_SRC_DIR ${lyx_dir_readme} PATH) set(CMAKE_PROJECT_NAME ${LYX_PROJECT}) +message(STATUS) if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) message(STATUS "Building in-source") set(TOP_BINARY_DIR "${CMAKE_BINARY_DIR}/build") else() message(STATUS "Building out-of-source") set(TOP_BINARY_DIR "${CMAKE_BINARY_DIR}") - #cmake_policy(SET CMP0013 OLD) endif() @@ -37,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) @@ -50,47 +54,71 @@ include(LyXMacros) 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" OFF 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" ON 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) -LYX_OPTION(MERGE_REBUILD "Rebuild generated files from merged files build" OFF ALL) -LYX_OPTION(QUIET "Don't generate verbose makefiles" OFF ALL) -LYX_OPTION(INSTALL_PREFIX "Install path for LyX" OFF ALL) +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 "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) +LYX_OPTION(MERGE_REBUILD "Rebuild generated files from merged files build" OFF ALL) +LYX_OPTION(QUIET "Don't generate verbose makefiles" OFF ALL) +LYX_OPTION(INSTALL_PREFIX "Install path for LyX" OFF ALL) LYX_OPTION(EXTERNAL_LIBINTL "Use external libintl" ON ALL) +LYX_OPTION(BUNDLE "Build bundle (experimental) " OFF ALL) # GCC specific -LYX_OPTION(PROFILE "Build profile version" OFF GCC) -LYX_OPTION(EXTERNAL_BOOST "Use external boost" OFF GCC) -LYX_OPTION(PROGRAM_SUFFIX "Append version suffix to binaries" ON GCC) -LYX_OPTION(DEBUG_GLIBC "Enable libstdc++ debug mode" OFF GCC) +LYX_OPTION(PROFILE "Build profile version" OFF GCC) +LYX_OPTION(EXTERNAL_BOOST "Use external boost" OFF GCC) +LYX_OPTION(PROGRAM_SUFFIX "Append version suffix to binaries" ON GCC) +LYX_OPTION(DEBUG_GLIBC "Enable libstdc++ debug mode" OFF GCC) LYX_OPTION(DEBUG_GLIBC_PEDANTIC "Enable libstdc++pedantic debug mode" OFF GCC) -LYX_OPTION(STDLIB_DEBUG "Use debug stdlib" OFF GCC) -LYX_OPTION(CONCEPT_CHECKS "Enable concept-checks" OFF GCC) +LYX_OPTION(STDLIB_DEBUG "Use debug stdlib" OFF GCC) +LYX_OPTION(CONCEPT_CHECKS "Enable concept-checks" OFF GCC) # MSVC specific -LYX_OPTION(CONSOLE "Show console on Windows" ON MSVC) -LYX_OPTION(VLD "Use VLD with MSVC" OFF MSVC) -LYX_OPTION(WALL "Enable all warnings" OFF MSVC) -LYX_OPTION(CONFIGURE_CHECKS "Also run configure checks for MSVC" OFF MSVC) +LYX_OPTION(CONSOLE "Show console on Windows" ON MSVC) +LYX_OPTION(VLD "Use VLD with MSVC" OFF MSVC) +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) + message(STATUS "Available options: (dis/enable with -D=0/1)") + message(STATUS) + LYX_OPTION_LIST_ALL(help) + message(STATUS) +else() + + # Check option dependencies + if(LYX_CPACK) set(LYX_INSTALL ON) endif() +if(LYX_DMG) + set(LYX_BUNDLE 1) + set(LYX_CPACK 1) +endif() + if(LYX_INSTALL) set(LYX_NLS ON) if (WIN32) set(LYX_HUNSPELL ON) + set(LYX_BUNDLE ON) endif() set(LYX_CONSOLE OFF) set(LYX_PACKAGE_SUFFIX ON) @@ -98,6 +126,7 @@ if(LYX_INSTALL) set(LYX_PROFILE OFF) endif() + if(LYX_MERGE_FILES) set(LYX_PCH OFF) else() @@ -123,6 +152,7 @@ if(LYX_DEPENDENCIES_DOWNLOAD) endif() + message(STATUS) set(EXECUTABLE_OUTPUT_PATH ${TOP_BINARY_DIR}/bin) @@ -151,7 +181,7 @@ set(VERSION_INFO "CMake Build") # Try to get some informations from configure.ac -include(LyXPaths) #called here to define the needed TOP_SRC_DIR-variable +include(LyXPaths) file(STRINGS "${TOP_SRC_DIR}/configure.ac" _config_lines) if(WIN32) @@ -179,6 +209,7 @@ foreach(_c_l ${_config_lines} ) if(PACKAGE_VERSION MATCHES "^\([0-9]+\)\\.\([0-9]+\).*$") set(LYX_MAJOR_VERSION ${CMAKE_MATCH_1}) set(LYX_MINOR_VERSION ${CMAKE_MATCH_2}) + set(LYX_PATCH_VERSION 0) # TODO 2.1.0svn, LYX_PATCH_VERSION == 0 set(LYX_DIR_VER "LYX_DIR_${CMAKE_MATCH_1}${CMAKE_MATCH_2}x") set(LYX_USERDIR_VER "LYX_USERDIR_${CMAKE_MATCH_1}${CMAKE_MATCH_2}x") set(LYX_INSTALL_SUFFIX "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}") @@ -190,7 +221,37 @@ foreach(_c_l ${_config_lines} ) endforeach(_c_l) -if (LYX_INSTALL_PREFIX) +if(LYX_PROGRAM_SUFFIX) + set(PROGRAM_SUFFIX "${LYX_INSTALL_SUFFIX}") +else() + set(PROGRAM_SUFFIX "") +endif() + + +if(LYX_BUNDLE) + if(APPLE) + set(LYX_BUILD_BUNDLE MACOSX_BUNDLE) + set(LYX_DATA_SUBDIR ${PACKAGE_BASE}${PROGRAM_SUFFIX}.app/Contents/Resources/ CACHE STRING "Bundle Contents dir" FORCE) + set(MACOSX_BUNDLE_STARTUP_COMMAND ${PACKAGE_BASE}${PROGRAM_SUFFIX}.app) + if(NOT LYX_INSTALL_PREFIX) + set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/LyX CACHE PATH "Mac bundle dir" FORCE) + set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + endif() + endif() + + message(STATUS) + message(STATUS "Bundle creation is enabled (experimental):") + message(STATUS " make") + message(STATUS " make install/strip") + message(STATUS " make package") + message(STATUS "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 'development/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() @@ -202,11 +263,6 @@ else() set(PACKAGE ${PACKAGE_BASE}) endif() -if(LYX_PROGRAM_SUFFIX) - set(PROGRAM_SUFFIX "${LYX_INSTALL_SUFFIX}") -else() - set(PROGRAM_SUFFIX "") -endif() if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) @@ -224,11 +280,20 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX LYX_INSTALLED CACHE PATH "LyX default install prefix" FORCE) endif() endif() - -if (WIN32) - set(LYX_DATA_SUBDIR "Resources/" CACHE STRING "Subdirectory for all lyx-system-data" FORCE) +if(IS_ABSOLUTE) + set(CMAKE_INSTALL_PREFIX_ABSOLUTE ${CMAKE_INSTALL_PREFIX}) else() - set(LYX_DATA_SUBDIR "" CACHE STRING "Subdirectory for all lyx-system-data" FORCE) + set(CMAKE_INSTALL_PREFIX_ABSOLUTE ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_PREFIX}) +endif() + + + +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}") @@ -237,6 +302,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) @@ -247,7 +313,6 @@ set(LYX_CPP_FILES *.cpp) set(LYX_HPP_FILES *.h) set(LYX_MOC_FILES moc_*.cpp) - include(ProjectSourceGroup) @@ -256,12 +321,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) @@ -293,8 +365,7 @@ endif() find_package(Qt4 REQUIRED) -find_package(ICONV REQUIRED) -find_package(ZLIB REQUIRED) + include_directories(${TOP_BINARY_DIR} ${TOP_SRC_DIR}/src) @@ -323,17 +394,23 @@ if(LYX_NLS) add_subdirectory(po "${TOP_BINARY_DIR}/po") endif() -if(LYX_EXTERNAL_LIBINTL) - find_package(Libintl REQUIRED) - add_definitions(-DHAVE_GETTEXT) #TODO move to config.h -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 @@ -505,22 +582,45 @@ add_subdirectory(lib/scripts "${TOP_BINARY_DIR}/scripts") if(LYX_INSTALL) - FIND_PROGRAM(LYX_PERL_EXECUTABLE perl) - if(${LYX_PERL_EXECUTABLE} MATCHES "-NOTFOUND") - message(FATAL_ERROR "Perl required!") + #FIND_PROGRAM(LYX_PERL_EXECUTABLE perl) + if(${LYX_PYTHON_EXECUTABLE} MATCHES "-NOTFOUND") + message(STATUS "Python required to create doc!") + else() + add_subdirectory(${LYX_CMAKE_DIR}/man "${TOP_BINARY_DIR}/man") + add_subdirectory(${LYX_CMAKE_DIR}/doc "${TOP_BINARY_DIR}/doc") endif() - add_subdirectory(${LYX_CMAKE_DIR}/man "${TOP_BINARY_DIR}/man") - add_subdirectory(${LYX_CMAKE_DIR}/doc "${TOP_BINARY_DIR}/doc") include(../Install) endif() +add_subdirectory(sourcedoc "${TOP_BINARY_DIR}/sourcedoc") message(STATUS) message(STATUS "Build options, switch LYX_* variables by -DLYX_*=1 or 0:") message(STATUS) -LYX_OPTION_LIST_ALL() +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) @@ -566,22 +666,57 @@ set(CPACK_RESOURCE_FILE_LICENSE "${TOP_SRC_DIR}/${LYX_CMAKE_DIR}/LyX_license.txt # installing from that rpm package. FIND_PROGRAM(LYX_SVNVERSION svnversion) #message(STATUS "svnversion = ${LYX_SVNVERSION}") -if(NOT ${LYX_SVNVERSION} MATCHES "-NOTFOUND") +if(LYX_SVNVERSION) EXECUTE_PROCESS(COMMAND ${LYX_SVNVERSION} WORKING_DIRECTORY "${TOP_SRC_DIR}" OUTPUT_VARIABLE CPACK_RPM_PACKAGE_RELEASE OUTPUT_STRIP_TRAILING_WHITESPACE) # We use this value also to set the package-patch-value if(CPACK_RPM_PACKAGE_RELEASE MATCHES "^\([0-9]+\)") - set(CPACK_PACKAGE_VERSION_PATCH ${CMAKE_MATCH_1}) + set(CPACK_PACKAGE_VERSION_PATCH ${CMAKE_MATCH_1}) # TODO this is not the patch level + set(LYX_REVISION_VERSION ${CMAKE_MATCH_1}) endif() +else() + set(LYX_REVISION_VERSION svn) #TODO use date endif() + # we do not have a readme or welcome data, # 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_CPACK) + + set(CPACK_PACKAGE_NAME LyX) + if(APPLE) + set(CPACK_GENERATOR DragNDrop) + elseif(WIN32) + message(STATUS "Configuring NSIS files") + configure_file(development/Win32/packaging/installer/lyx.nsi.cmake ${CMAKE_BINARY_DIR}/installer/lyx.nsi @ONLY) + configure_file(development/Win32/packaging/installer/settings.nsh.cmake ${CMAKE_BINARY_DIR}/installer/settings-cmake.nsh @ONLY) + configure_file(development/Win32/packaging/installer/include/declarations.nsh.cmake ${CMAKE_BINARY_DIR}/installer/declarations-cmake.nsh @ONLY) + set(CPACK_GENERATOR ZIP) + message(STATUS "NSIS files are created in ${CMAKE_BINARY_DIR}/installer") + message(STATUS "A zipped only release could be created by building the 'PACKAGE' project") + elseif() + # .sh on linux? + endif() + + include(CPack) endif() + #Now it is possible to create some packages # cd # make package @@ -604,4 +739,5 @@ endif() # message(STATUS) +endif() #help