]> git.lyx.org Git - lyx.git/blob - development/cmake/CMakeLists.txt
add support of precompiled headers for msvc, enable with -Dpch=1, disable headers...
[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 #TODO: add command line option
19 #      enable by default because the cmake 
20 #      build is mostly used for development
21 set(ENABLE_ASSERTIONS 1)
22
23 if(WIN32)
24         set(USE_WINDOWS_PACKAGING 1)
25 else(WIN32)
26         set(USE_POSIX_PACKAGING 1)
27 endif(WIN32)
28
29 if(NOT GROUP_CODE)
30         #set(GROUP_CODE "The Golden Code")
31         set(GROUP_CODE flat)
32 endif(NOT GROUP_CODE)
33
34 include(LyXPaths)
35 include(LyXMacros)
36 include(ProjectSourceGroup)
37
38 if(release)
39         set(CMAKE_BUILD_TYPE Release)
40         set(release)
41 endif(release)  
42
43
44 set(qt_postfix qt4)
45 project(lyx-${qt_postfix})
46 find_package(Qt4 REQUIRED)
47
48 find_package(ZLIB REQUIRED)
49 find_package(ICONV REQUIRED)
50 add_definitions(-DHAVE_ICONV=1)
51
52 if(all OR aspell)
53         set(aspell TRUE CACHE TYPE STRING)
54         find_package(ASPELL REQUIRED)
55 else(all OR aspell)
56         find_package(ASPELL)
57 endif(all OR aspell)
58 set(aspell)
59
60 message("")
61 if(nls OR all)
62         set(nls TRUE CACHE TYPE STRING)
63         add_definitions(-DENABLE_NLS=1)
64         message("----- Building with ENABLE_NLS")
65 else(nls OR all)        
66         message("----- No nls, to enable use -Dnls=1")
67 endif(nls OR all)
68 set(nls)
69 if(ASPELL_FOUND)
70         add_definitions(-DUSE_ASPELL=1)
71         message("----- Building with USE_ASPELL")
72 else(ASPELL_FOUND)      
73         message("----- No aspell, to get more information use -Daspell=1")
74 endif(ASPELL_FOUND)
75 message("")
76 set(all)
77
78 # create config.h
79 include(ConfigureChecks.cmake)
80 configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h )
81
82
83 if(MSVC)
84         if(MSVC_IDE)
85                 add_definitions(-DBOOST_USER_CONFIG=&lt\;config.h&gt\;)
86         else(MSVC_IDE)
87                 add_definitions(-DBOOST_USER_CONFIG="<config.h>")
88                 SET(CMAKE_EXE_LINKER_FLAGS /MANIFEST)
89         endif(MSVC_IDE)
90
91         ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) 
92
93 else(MSVC)
94         add_definitions(-DBOOST_USER_CONFIG="<config.h>")
95 endif(MSVC)
96
97 if(pch AND MSVC)
98         set(pch TRUE CACHE TYPE STRING)
99
100         macro(lyx_add_msvc_pch _sources)
101                 SET_SOURCE_FILES_PROPERTIES(${${_sources}} PROPERTIES COMPILE_FLAGS 
102                         "/Yuconfig.h /Fp${CMAKE_BINARY_DIR}/config.pch /Fd${CMAKE_BINARY_DIR}/pchlib.pdb")
103         endmacro(lyx_add_msvc_pch)
104         
105         configure_file(config.C.cmake ${CMAKE_BINARY_DIR}/config.C)
106         SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/config.C PROPERTIES COMPILE_FLAGS  
107                 "/Ycconfig.h /Fp${CMAKE_BINARY_DIR}/config.pch /Fd${CMAKE_BINARY_DIR}/pchlib.pdb")
108                 
109         include_directories(${CMAKE_CURRENT_BINARY_DIR} ${TOP_SRC_DIR}/src/support ${ICONV_INCLUDE_DIR})
110         add_library(pchlib STATIC ${CMAKE_BINARY_DIR}/config.C)
111         
112         set(pchlibname pchlib )
113         set(PRECOMPILED_HEADERS TRUE)
114 else(pch AND MSVC)
115         macro(lyx_add_msvc_pch)
116         endmacro(lyx_add_msvc_pch)
117         set(pchlibname boost_signals) # dummy 
118 endif(pch AND MSVC)
119
120
121 #TODO: insource is not the best place
122 configure_file(${TOP_SRC_DIR}/lib/lyx2lyx/lyx2lyx_version.py.in 
123                ${TOP_SRC_DIR}/lib/lyx2lyx/lyx2lyx_version.py)
124      
125 include_directories( 
126         ${CMAKE_BINARY_DIR} 
127         ${TOP_SRC_DIR}/src 
128         ${TOP_SRC_DIR}/boost 
129         ${QT_INCLUDES} 
130 )
131
132 add_subdirectory(boost)
133 add_subdirectory(intl)
134 add_subdirectory(src)