]> git.lyx.org Git - lyx.git/blob - src/CMakeLists.txt
Merge branch 'master' of git.lyx.org:lyx
[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 set(_lyx "${PACKAGE_BASE}${PROGRAM_SUFFIX}")
8 project(${_lyx})
9
10 include_directories(${TOP_SRC_DIR}/src)
11
12 add_subdirectory(frontends)
13 add_subdirectory(graphics)
14 add_subdirectory(insets)
15 add_subdirectory(mathed)
16 add_subdirectory(support)
17 add_subdirectory(tex2lyx)
18 if (UNIX)
19         add_subdirectory(client)
20 endif()
21
22 file(GLOB lyx_sources ${TOP_SRC_DIR}/src/${LYX_CPP_FILES})
23 file(GLOB moc_files ${TOP_SRC_DIR}/src/${LYX_MOC_FILES})
24 list(REMOVE_ITEM  lyx_sources ${moc_files} .)
25 file(GLOB lyx_headers ${TOP_SRC_DIR}/src/${LYX_HPP_FILES})
26
27 list(REMOVE_ITEM lyx_sources
28         ${TOP_SRC_DIR}/src/Variables.cpp
29         ${TOP_SRC_DIR}/src/Section.cpp
30         ${TOP_SRC_DIR}/src/lyxcore.cpp
31         ${TOP_SRC_DIR}/src/lyxinsets.cpp
32         ${TOP_SRC_DIR}/src/lyxmathed.cpp)
33
34 list(REMOVE_ITEM lyx_headers
35         ${TOP_SRC_DIR}/src/Variables.h
36         ${TOP_SRC_DIR}/src/Section.h)
37
38 if(NOT APPLE)
39         list(REMOVE_ITEM lyx_sources ${TOP_SRC_DIR}/src/AppleSpellChecker.cpp)
40         list(REMOVE_ITEM lyx_headers ${TOP_SRC_DIR}/src/AppleSpellChecker.h)
41 endif()
42
43 if(NOT ASPELL_FOUND)
44         list(REMOVE_ITEM lyx_sources ${TOP_SRC_DIR}/src/AspellChecker.cpp)
45         list(REMOVE_ITEM lyx_headers ${TOP_SRC_DIR}/src/AspellChecker.h)
46 else()
47         set(dont_merge ${dont_merge} ${TOP_SRC_DIR}/src/AspellChecker.cpp)
48 endif()
49
50 if(NOT ENCHANT_FOUND)
51         list(REMOVE_ITEM lyx_sources ${TOP_SRC_DIR}/src/EnchantChecker.cpp)
52         list(REMOVE_ITEM lyx_headers ${TOP_SRC_DIR}/src/EnchantChecker.h)
53 else()
54         set(dont_merge ${dont_merge} ${TOP_SRC_DIR}/src/EnchantChecker.cpp)
55 endif()
56
57 if(NOT HUNSPELL_FOUND)
58         list(REMOVE_ITEM lyx_sources ${TOP_SRC_DIR}/src/HunspellChecker.cpp)
59         list(REMOVE_ITEM lyx_headers ${TOP_SRC_DIR}/src/HunspellChecker.h)
60 else()
61         set(dont_merge ${dont_merge} ${TOP_SRC_DIR}/src/HunspellChecker.cpp)
62 endif()
63
64
65 lyx_automoc(${TOP_SRC_DIR}/src/Compare.cpp)
66 if(WIN32)
67         lyx_automoc(${TOP_SRC_DIR}/src/Server.cpp)
68 endif()
69
70 include_directories(${CMAKE_CURRENT_BINARY_DIR}
71         ${ZLIB_INCLUDE_DIR} ${QT_INCLUDES})
72
73 lyx_add_msvc_pch(lyx)
74
75 if (LYX_MERGE_FILES)
76         if(dont_merge)
77                 list(REMOVE_ITEM lyx_sources ${dont_merge})
78         endif()
79         lyx_const_touched_files(_allinone lyx_sources)
80         set(lyx_sources ${_allinone_files} ${dont_merge})
81 endif()
82
83 if (LYX_VLD)
84         configure_file(${vld_path}/vld.ini ${CMAKE_CURRENT_BINARY_DIR}/vld.ini COPYONLY)
85         set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/memory_leak_report.txt PROPERTIES GENERATED TRUE)
86         set(vld_files ${CMAKE_CURRENT_BINARY_DIR}/vld.ini ${CMAKE_CURRENT_BINARY_DIR}/memory_leak_report.txt)
87         lyx_add_info_files(VLD ${vld_files})
88 endif()
89
90 if(WIN32)
91         set(FILE_RC ${TOP_CMAKE_PATH}/lyx.rc)
92         message(STATUS "Using icon defined in resource file: ${FILE_RC}")
93 endif()
94
95 lyx_find_info_files(LyXInfoFiles ${TOP_SRC_DIR}/*)
96 lyx_find_info_files(LyXCMakeFiles ${TOP_CMAKE_PATH}/*.txt)
97 lyx_find_info_files(LyXCMakeFiles ${TOP_CMAKE_PATH}/*.cmake)
98 lyx_find_info_files(LyXCMakeFiles ${TOP_CMAKE_PATH}/*.h)
99 lyx_find_info_files(LyXCMakeFiles ${TOP_CMAKE_PATH}/*.msvc)
100 lyx_find_info_files(LyXCMakeFiles ${TOP_MODULE_PATH}/*)
101 lyx_find_info_files(LyXCMakeFiles ${TOP_SCRIPT_PATH}/*)
102 lyx_find_info_files(LyXUiFiles ${TOP_SRC_DIR}/lib/ui/*)
103
104 if (APPLE AND LYX_BUNDLE)
105         include(../Install)
106 endif()
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 lyx_add_gcc_pch(${_lyx})
123
124 target_link_libraries(${_lyx}
125         mathed
126         insets
127         frontends
128         frontend_qt4
129         graphics
130         support
131         ${intl_link}
132         ${ICONV_LIBRARY}
133         ${QT_QTMAIN_LIBRARY}
134         ${vld_dll})
135
136 if(HUNSPELL_FOUND)
137         target_link_libraries(${_lyx} ${HUNSPELL_LIBRARY})
138 endif()
139 if(ASPELL_FOUND)
140         target_link_libraries(${_lyx} ${ASPELL_LIBRARY})
141 endif()
142 if(ENCHANT_FOUND)
143         target_link_libraries(${_lyx} ${ENCHANT_LIBRARY})
144 endif()
145 if(Magic_FOUND)
146         target_link_libraries(${_lyx} ${Magic_LIBRARY})
147 endif()
148
149 if(APPLE)
150         target_link_libraries(${_lyx} "-bind_at_load")
151         if(LYX_COCOA)
152                 target_link_libraries(${_lyx} "-framework Cocoa")
153         else()
154                 target_link_libraries(${_lyx} "-framework AppKit")
155         endif()
156 endif()
157
158 if(MINGW)
159         target_link_libraries(${_lyx} ole32)
160 endif()
161
162 project_source_group("${GROUP_CODE}" lyx_sources lyx_headers)
163
164
165 install(TARGETS ${_lyx}
166         RUNTIME DESTINATION bin
167         BUNDLE DESTINATION .)
168
169 if(LYX_BUNDLE)
170         if(NOT APPLE)
171                 set(installed_lyx ${CMAKE_INSTALL_PREFIX}/bin/${_lyx}${CMAKE_EXECUTABLE_SUFFIX})
172         else()
173                 set_target_properties(${_lyx} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_BINARY_DIR}/../Info.plist")
174                 set(installed_lyx ${CMAKE_INSTALL_PREFIX}/${_lyx}.app)
175                 set(LYX_BUNDLE_PROPERTY_MODE "ON")
176                 include("../Install")
177         endif()
178         install(CODE "include(BundleUtilities)
179                         fixup_bundle(\"${installed_lyx}\" \"\" \"\") " COMPONENT RUNTIME)
180 endif()
181