]> git.lyx.org Git - lyx.git/blob - src/CMakeLists.txt
Avoid full metrics computation with Update:FitCursor
[lyx.git] / src / 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-2011 Peter K�mmel, <syntheticpp@gmx.net>
5 #
6
7 project(${_lyx})
8
9 include_directories(${TOP_SRC_DIR}/src)
10
11 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
12 set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMakeTargets")
13
14 add_subdirectory(frontends)
15 add_subdirectory(graphics)
16 add_subdirectory(insets)
17 add_subdirectory(mathed)
18 add_subdirectory(support)
19 add_subdirectory(tex2lyx)
20 if (APPLE)
21   add_subdirectory(convert)
22 endif()
23 if (UNIX)
24         add_subdirectory(client)
25 endif()
26
27 file(GLOB lyx_sources ${TOP_SRC_DIR}/src/${LYX_CPP_FILES})
28 file(GLOB moc_files ${TOP_SRC_DIR}/src/${LYX_MOC_FILES})
29 list(REMOVE_ITEM  lyx_sources ${moc_files} .)
30 file(GLOB lyx_headers ${TOP_SRC_DIR}/src/${LYX_HPP_FILES})
31 set(lyxwrap_sources ${TOP_SRC_DIR}/src/lyxwrap.cpp)
32
33 list(REMOVE_ITEM lyx_sources
34         ${TOP_SRC_DIR}/src/lyxwrap.cpp
35         ${TOP_SRC_DIR}/src/Variables.cpp
36         ${TOP_SRC_DIR}/src/Section.cpp
37         ${TOP_SRC_DIR}/src/lyxcore.cpp
38         ${TOP_SRC_DIR}/src/lyxinsets.cpp
39         ${TOP_SRC_DIR}/src/lyxmathed.cpp)
40
41 list(REMOVE_ITEM lyx_headers
42         ${TOP_SRC_DIR}/src/Variables.h
43         ${TOP_SRC_DIR}/src/Section.h)
44
45 if(NOT APPLE)
46         list(REMOVE_ITEM lyx_sources ${TOP_SRC_DIR}/src/AppleSpellChecker.cpp)
47         list(REMOVE_ITEM lyx_headers ${TOP_SRC_DIR}/src/AppleSpellChecker.h)
48 endif()
49
50 if(NOT ASPELL_FOUND)
51         list(REMOVE_ITEM lyx_sources ${TOP_SRC_DIR}/src/AspellChecker.cpp)
52         list(REMOVE_ITEM lyx_headers ${TOP_SRC_DIR}/src/AspellChecker.h)
53 else()
54         set(dont_merge ${dont_merge} ${TOP_SRC_DIR}/src/AspellChecker.cpp)
55 endif()
56
57 if(NOT ENCHANT_FOUND)
58         list(REMOVE_ITEM lyx_sources ${TOP_SRC_DIR}/src/EnchantChecker.cpp)
59         list(REMOVE_ITEM lyx_headers ${TOP_SRC_DIR}/src/EnchantChecker.h)
60 else()
61         set(dont_merge ${dont_merge} ${TOP_SRC_DIR}/src/EnchantChecker.cpp)
62 endif()
63
64 if(NOT HUNSPELL_FOUND)
65         list(REMOVE_ITEM lyx_sources ${TOP_SRC_DIR}/src/HunspellChecker.cpp)
66         list(REMOVE_ITEM lyx_headers ${TOP_SRC_DIR}/src/HunspellChecker.h)
67 else()
68         set(dont_merge ${dont_merge} ${TOP_SRC_DIR}/src/HunspellChecker.cpp)
69 endif()
70
71
72 lyx_automoc(${TOP_SRC_DIR}/src/Compare.cpp)
73 if(WIN32)
74         lyx_automoc(${TOP_SRC_DIR}/src/Server.cpp)
75 endif()
76
77 include_directories(${CMAKE_CURRENT_BINARY_DIR}
78         ${ZLIB_INCLUDE_DIR} ${ICONV_INCLUDE_DIR} ${QT_INCLUDES})
79
80 lyx_add_msvc_pch(lyx)
81
82 if (LYX_MERGE_FILES)
83         if(dont_merge)
84                 list(REMOVE_ITEM lyx_sources ${dont_merge})
85         endif()
86         lyx_const_touched_files(_allinone lyx_sources)
87         set(lyx_sources ${_allinone_files} ${dont_merge})
88 endif()
89
90 if (LYX_VLD)
91         configure_file(${vld_path}/vld.ini ${CMAKE_CURRENT_BINARY_DIR}/vld.ini COPYONLY)
92         set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/memory_leak_report.txt PROPERTIES GENERATED TRUE)
93         set(vld_files ${CMAKE_CURRENT_BINARY_DIR}/vld.ini ${CMAKE_CURRENT_BINARY_DIR}/memory_leak_report.txt)
94         lyx_add_info_files(VLD ${vld_files})
95 endif()
96
97 if(WIN32 AND NOT MINGW)
98   set(FILE_RC ${TOP_SRC_DIR}/src/lyxwinres.rc)
99   file(COPY ${TOP_SRC_DIR}/development/Win32/packaging/icons/lyx.ico DESTINATION ${CMAKE_BINARY_DIR})
100   file(COPY ${TOP_SRC_DIR}/development/Win32/packaging/icons/lyx_doc.ico DESTINATION ${CMAKE_BINARY_DIR})
101   message(STATUS "Using icon defined in resource file: ${FILE_RC}")
102 endif()
103
104 lyx_find_info_files(LyXInfoFiles ${TOP_SRC_DIR}/*)
105 lyx_find_info_files(LyXCMakeFiles ${TOP_CMAKE_PATH}/*.txt)
106 lyx_find_info_files(LyXCMakeFiles ${TOP_CMAKE_PATH}/*.cmake)
107 lyx_find_info_files(LyXCMakeFiles ${TOP_CMAKE_PATH}/*.h)
108 lyx_find_info_files(LyXCMakeFiles ${TOP_CMAKE_PATH}/*.msvc)
109 lyx_find_info_files(LyXCMakeFiles ${TOP_MODULE_PATH}/*)
110 lyx_find_info_files(LyXCMakeFiles ${TOP_SCRIPT_PATH}/*)
111 lyx_find_info_files(LyXUiFiles ${TOP_SRC_DIR}/lib/ui/*)
112
113 add_executable(${_lyx}
114         ${WIN32_CONSOLE}
115         ${LYX_BUILD_BUNDLE}
116         ${lyx_sources}
117         ${lyx_headers}
118         ${vld_files}
119         ${FILE_RC}
120         ${lyx_info_files}
121         ${lyx_cmake_files}
122         ${OSX_BUNDLE_FILES}
123 )
124
125 add_dependencies(${_lyx} lyx_version)
126
127 set_target_properties(${_lyx} PROPERTIES
128   QT_NO_UNICODE_DEFINES TRUE
129         FOLDER "applications/LyX"
130         INTERPROCEDURAL_OPTIMIZATION ${LYX_IPO_SUPPORTED})
131 lyx_add_gcc_pch(${_lyx})
132
133 target_link_libraries(${_lyx}
134         mathed
135         insets
136         frontends
137         frontend_qt
138         graphics
139         support
140         ${MYTHESLIB_LIBRARY}
141         ${ICONV_LIBRARY}
142         ${LYX_QTMAIN_LIBRARY}
143         ${vld_dll})
144
145 qt_use_modules(${_lyx} Core Gui ${QtCore5CompatModule})
146
147 if(QT_USES_X11)
148   find_package(X11 REQUIRED)
149   target_link_libraries(${_lyx} ${X11_X11_LIB}) # we need it because we use XSendEvent
150   if(HAVE_QT5_X11_EXTRAS)
151     find_library(XCB_LIBRARY NAMES xcb)
152     if (XCB_LIBRARY MATCHES "NOTFOUND")
153       message(FATAL_ERROR "Need xcb library to use with QT5_X11_EXTRAS")
154     endif()
155     target_link_libraries(${_lyx} ${LYX_QT5_X11_EXTRAS_LIBRARY} ${XCB_LIBRARY})
156   endif()
157 endif()
158
159 lyx_target_link_libraries(${_lyx} HUNSPELL ASPELL ENCHANT Magic)
160
161 if(APPLE)
162         target_link_libraries(${_lyx} "-bind_at_load")
163         if(LYX_COCOA)
164                 target_link_libraries(${_lyx} "-framework Cocoa")
165         else()
166                 target_link_libraries(${_lyx} "-framework AppKit")
167         endif()
168 endif()
169
170 if(MINGW)
171         target_link_libraries(${_lyx} ole32)
172 endif()
173
174 if(CYGWIN)
175         target_link_libraries(${_lyx} gdi32 shlwapi ole32)
176 endif()
177
178 project_source_group("${GROUP_CODE}" lyx_sources lyx_headers)
179
180 install(TARGETS ${_lyx}
181     BUNDLE DESTINATION . COMPONENT Runtime
182     RUNTIME DESTINATION ${LYX_UTILITIES_INSTALL_PATH} COMPONENT Runtime)
183
184 if(LYX_BUNDLE)
185         if(APPLE)
186                 # Now that lyx executable is defined, we can the files that should be included
187                 # directly in the bundle. Note that resources are not copied with this mechanism:
188                 # only the files necessary to run the executable are processed here (LyX.sdef, LyX.icns, etc.)
189                 list(LENGTH OSX_BUNDLE_FILES OSX_BUNDLE_LAST_INDEX)
190                 math(EXPR OSX_BUNDLE_LAST_INDEX "${OSX_BUNDLE_LAST_INDEX} - 1")
191                 foreach(_i RANGE ${OSX_BUNDLE_LAST_INDEX})
192                     list(GET OSX_BUNDLE_FILES ${_i} _file)
193                     list(GET OSX_BUNDLE_DIRS ${_i} _directory)
194                     # Sets the location of the file into the OS X bundle
195                         set_source_files_properties("${_file}" PROPERTIES MACOSX_PACKAGE_LOCATION "${_directory}")
196                 endforeach()
197
198                 set_target_properties(${_lyx} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_BINARY_DIR}/../Info.plist")
199         endif()
200 endif()
201
202 set(dowrapper ON) # create and install wrapper for external commands
203 foreach(_f ${lyxwrap_sources})
204   if(NOT EXISTS "${_f}")
205     set(dowrapper OFF)
206   endif()
207 endforeach()
208 if(dowrapper AND USE_POSIX_PACKAGING)
209   add_executable(lyxwrap${PROGRAM_SUFFIX} ${lyxwrap_sources})
210   install(TARGETS lyxwrap${PROGRAM_SUFFIX} DESTINATION ${LYX_UTILITIES_INSTALL_PATH})
211 endif()
212
213 add_subdirectory(tests)