]> git.lyx.org Git - lyx.git/blob - development/cmake/CMakeLists.txt
enable precompile headers only for the Debug and Release build
[lyx.git] / development / cmake / CMakeLists.txt
1 # This file is part of LyX, the document processor.
2 # Licence details can be found in the file COPYING.
3 #
4 # Copyright (c) 2006, Peter Kümmel, <syntheticpp@gmx.net>
5 #
6
7 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
8 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/modules")
9
10 set (EXECUTABLE_OUTPUT_PATH  ${CMAKE_BINARY_DIR}/bin)
11
12 set(PACKAGE lyx)
13 set(PACKAGE_VERSION 1.5.0svn)
14 set(LYX_DATE "not released yet")
15 #TODO
16 set(VERSION_INFO "CMake Build")
17
18 if(WIN32)
19         set(USE_WINDOWS_PACKAGING 1)
20 else(WIN32)
21         set(USE_POSIX_PACKAGING 1)
22 endif(WIN32)
23
24 if(NOT GROUP_CODE)
25         #set(GROUP_CODE "The Golden Code")
26         set(GROUP_CODE flat)
27 endif(NOT GROUP_CODE)
28
29 include(LyXPaths)
30 include(LyXMacros)
31 include(ProjectSourceGroup)
32
33 if(release)
34         set(CMAKE_BUILD_TYPE Release)
35         set(release)
36 endif(release)  
37
38
39 set(qt_postfix qt4)
40 project(lyx-${qt_postfix})
41 find_package(Qt4 REQUIRED)
42
43 find_package(ZLIB REQUIRED)
44 find_package(ICONV REQUIRED)
45 add_definitions(-DHAVE_ICONV=1)
46
47 if(all OR aspell)
48         set(aspell TRUE CACHE TYPE STRING)
49         find_package(ASPELL REQUIRED)
50 else(all OR aspell)
51         find_package(ASPELL)
52 endif(all OR aspell)
53 set(aspell)
54
55 message("")
56 if(nls OR all)
57         set(nls TRUE CACHE TYPE STRING)
58         add_definitions(-DENABLE_NLS=1)
59         message("----- Building with ENABLE_NLS")
60 else(nls OR all)        
61         message("----- No nls, to enable use -Dnls=1")
62 endif(nls OR all)
63 set(nls)
64 if(ASPELL_FOUND)
65         add_definitions(-DUSE_ASPELL=1)
66         message("----- Building with USE_ASPELL")
67 else(ASPELL_FOUND)      
68         message("----- No aspell, to get more information use -Daspell=1")
69 endif(ASPELL_FOUND)
70 message("")
71 set(all)
72
73 # create config.h
74 include(ConfigureChecks.cmake)
75 configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h )
76
77
78 if(MSVC)
79         if(MSVC_IDE)
80                 add_definitions(-DBOOST_USER_CONFIG=&lt\;config.h&gt\;)
81         else(MSVC_IDE)
82                 add_definitions(-DBOOST_USER_CONFIG="<config.h>")
83                 SET(CMAKE_EXE_LINKER_FLAGS /MANIFEST)
84         endif(MSVC_IDE)
85
86         ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) 
87         
88         # disable checked iterators for msvc release builds to get maximum speed
89         set(CMAKE_CXX_FLAGS_RELEASE  "${CMAKE_CXX_FLAGS_RELEASE} /D_SECURE_SCL=0")
90 else(MSVC)
91         add_definitions(-DBOOST_USER_CONFIG="<config.h>")
92 endif(MSVC)
93
94 if(MSVC AND NOT disable-pch)
95         configure_file(${CMAKE_SOURCE_DIR}/pcheaders.h    ${CMAKE_BINARY_DIR}/pcheaders.h)
96         configure_file(${CMAKE_SOURCE_DIR}/config.C.cmake ${CMAKE_CURRENT_BINARY_DIR}/config_pch.C)
97         macro(lyx_add_msvc_pch name_)
98                 SET_SOURCE_FILES_PROPERTIES(${${name_}_sources} PROPERTIES COMPILE_FLAGS "/Yuconfig.h /Fp\$(IntDir)/config.pch")
99                 SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/config_pch.C PROPERTIES COMPILE_FLAGS "/Ycconfig.h /Fp\$(IntDir)/config.pch")
100                 set(${name_}_sources ${${name_}_sources} ${CMAKE_BINARY_DIR}/config_pch.C ${CMAKE_BINARY_DIR}/pcheaders.h)
101         endmacro(lyx_add_msvc_pch)
102         set(CMAKE_CXX_FLAGS_DEBUG    "${CMAKE_CXX_FLAGS_DEBUG}   /DLYX_PCH_STL /DLYX_PCH_BOOST /DLYX_PCH_QT4")
103         set(CMAKE_CXX_FLAGS_RELEASE  "${CMAKE_CXX_FLAGS_RELEASE} /DLYX_PCH_STL /DLYX_PCH_BOOST /DLYX_PCH_QT4")
104         
105 else(MSVC AND NOT disable-pch)
106         set(disable-pch TRUE CACHE TYPE STRING)
107         macro(lyx_add_msvc_pch)
108         endmacro(lyx_add_msvc_pch)
109 endif(MSVC AND NOT disable-pch)
110
111
112 #TODO: insource is not the best place
113 configure_file(${TOP_SRC_DIR}/lib/lyx2lyx/lyx2lyx_version.py.in 
114                ${TOP_SRC_DIR}/lib/lyx2lyx/lyx2lyx_version.py)
115      
116 include_directories( 
117         ${CMAKE_BINARY_DIR} 
118         ${TOP_SRC_DIR}/src 
119         ${TOP_SRC_DIR}/boost 
120         ${QT_INCLUDES} 
121 )
122
123 add_subdirectory(boost)
124 add_subdirectory(intl)
125 add_subdirectory(src)