]> git.lyx.org Git - lyx.git/blob - src/CMakeLists.txt
Disable CheckTeX while buffer is processed
[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_CMAKE_PATH}/lyx.rc)
99         message(STATUS "Using icon defined in resource file: ${FILE_RC}")
100 endif()
101
102 lyx_find_info_files(LyXInfoFiles ${TOP_SRC_DIR}/*)
103 lyx_find_info_files(LyXCMakeFiles ${TOP_CMAKE_PATH}/*.txt)
104 lyx_find_info_files(LyXCMakeFiles ${TOP_CMAKE_PATH}/*.cmake)
105 lyx_find_info_files(LyXCMakeFiles ${TOP_CMAKE_PATH}/*.h)
106 lyx_find_info_files(LyXCMakeFiles ${TOP_CMAKE_PATH}/*.msvc)
107 lyx_find_info_files(LyXCMakeFiles ${TOP_MODULE_PATH}/*)
108 lyx_find_info_files(LyXCMakeFiles ${TOP_SCRIPT_PATH}/*)
109 lyx_find_info_files(LyXUiFiles ${TOP_SRC_DIR}/lib/ui/*)
110
111 add_executable(${_lyx}
112         ${WIN32_CONSOLE}
113         ${LYX_BUILD_BUNDLE}
114         ${lyx_sources}
115         ${lyx_headers}
116         ${vld_files}
117         ${FILE_RC}
118         ${lyx_info_files}
119         ${lyx_cmake_files}
120         ${OSX_BUNDLE_FILES}
121 )
122
123 add_dependencies(${_lyx} lyx_version)
124
125 set_target_properties(${_lyx} PROPERTIES FOLDER "applications/LyX")
126
127 lyx_add_gcc_pch(${_lyx})
128
129 target_link_libraries(${_lyx}
130         mathed
131         insets
132         frontends
133         frontend_qt
134         graphics
135         support
136         ${MYTHESLIB_LIBRARY}
137         ${ICONV_LIBRARY}
138         ${LYX_QTMAIN_LIBRARY}
139         ${vld_dll})
140
141 qt_use_modules(${_lyx} Core Gui)
142
143 if(QT_USES_X11)
144   find_package(X11 REQUIRED)
145   target_link_libraries(${_lyx} ${X11_X11_LIB}) # we need it because we use XSendEvent
146   if(HAVE_QT5_X11_EXTRAS)
147     find_library(XCB_LIBRARY NAMES xcb)
148     if (XCB_LIBRARY MATCHES "NOTFOUND")
149       message(FATAL_ERROR "Need xcb library to use with QT5_X11_EXTRAS")
150     endif()
151     target_link_libraries(${_lyx} ${LYX_QT5_X11_EXTRAS_LIBRARY} ${XCB_LIBRARY})
152   endif()
153 endif()
154
155 lyx_target_link_libraries(${_lyx} HUNSPELL ASPELL ENCHANT Magic)
156
157 if(APPLE)
158         target_link_libraries(${_lyx} "-bind_at_load")
159         if(LYX_COCOA)
160                 target_link_libraries(${_lyx} "-framework Cocoa")
161         else()
162                 target_link_libraries(${_lyx} "-framework AppKit")
163         endif()
164 endif()
165
166 if(MINGW)
167         target_link_libraries(${_lyx} ole32)
168 endif()
169
170 if(CYGWIN)
171         target_link_libraries(${_lyx} gdi32 shlwapi ole32)
172 endif()
173
174 project_source_group("${GROUP_CODE}" lyx_sources lyx_headers)
175
176 install(TARGETS ${_lyx}
177     BUNDLE DESTINATION . COMPONENT Runtime
178     RUNTIME DESTINATION ${LYX_UTILITIES_INSTALL_PATH} COMPONENT Runtime)
179
180 if(LYX_BUNDLE)
181         if(APPLE)
182                 # Now that lyx executable is defined, we can the files that should be included
183                 # directly in the bundle. Note that resources are not copied with this mechanism:
184                 # only the files necessary to run the executable are processed here (LyX.sdef, LyX.icns, etc.)
185                 list(LENGTH OSX_BUNDLE_FILES OSX_BUNDLE_LAST_INDEX)
186                 math(EXPR OSX_BUNDLE_LAST_INDEX "${OSX_BUNDLE_LAST_INDEX} - 1")
187                 foreach(_i RANGE ${OSX_BUNDLE_LAST_INDEX})
188                     list(GET OSX_BUNDLE_FILES ${_i} _file)
189                     list(GET OSX_BUNDLE_DIRS ${_i} _directory)
190                     # Sets the location of the file into the OS X bundle
191                         set_source_files_properties("${_file}" PROPERTIES MACOSX_PACKAGE_LOCATION "${_directory}")
192                 endforeach()
193
194                 set_target_properties(${_lyx} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_BINARY_DIR}/../Info.plist")
195         endif()
196 endif()
197
198 set(dowrapper ON) # create and install wrapper for external commands
199 foreach(_f ${lyxwrap_sources})
200   if(NOT EXISTS "${_f}")
201     set(dowrapper OFF)
202   endif()
203 endforeach()
204 if(dowrapper AND USE_POSIX_PACKAGING)
205   add_executable(lyxwrap${PROGRAM_SUFFIX} ${lyxwrap_sources})
206   install(TARGETS lyxwrap${PROGRAM_SUFFIX} DESTINATION ${LYX_UTILITIES_INSTALL_PATH})
207 endif()
208
209 add_subdirectory(tests)