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