]> git.lyx.org Git - lyx.git/blob - src/CMakeLists.txt
style
[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 # support is the only directory containing objective-c files...
15 add_subdirectory(support)
16 # ...so we can add all the c++ specific flags after
17 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LYX_CXX_SPECIFIC_FLAGS}")
18
19 add_subdirectory(frontends)
20 add_subdirectory(graphics)
21 add_subdirectory(insets)
22 add_subdirectory(mathed)
23 add_subdirectory(tex2lyx)
24 if (UNIX)
25         add_subdirectory(client)
26 endif()
27
28 file(GLOB lyx_sources ${TOP_SRC_DIR}/src/${LYX_CPP_FILES})
29 file(GLOB moc_files ${TOP_SRC_DIR}/src/${LYX_MOC_FILES})
30 list(REMOVE_ITEM  lyx_sources ${moc_files} .)
31 file(GLOB lyx_headers ${TOP_SRC_DIR}/src/${LYX_HPP_FILES})
32
33 list(REMOVE_ITEM lyx_sources
34         ${TOP_SRC_DIR}/src/Variables.cpp
35         ${TOP_SRC_DIR}/src/Section.cpp
36         ${TOP_SRC_DIR}/src/lyxcore.cpp
37         ${TOP_SRC_DIR}/src/lyxinsets.cpp
38         ${TOP_SRC_DIR}/src/lyxmathed.cpp)
39
40 list(REMOVE_ITEM lyx_headers
41         ${TOP_SRC_DIR}/src/Variables.h
42         ${TOP_SRC_DIR}/src/Section.h)
43
44 if(NOT APPLE)
45         list(REMOVE_ITEM lyx_sources ${TOP_SRC_DIR}/src/AppleSpellChecker.cpp)
46         list(REMOVE_ITEM lyx_headers ${TOP_SRC_DIR}/src/AppleSpellChecker.h)
47 endif()
48
49 if(NOT ASPELL_FOUND)
50         list(REMOVE_ITEM lyx_sources ${TOP_SRC_DIR}/src/AspellChecker.cpp)
51         list(REMOVE_ITEM lyx_headers ${TOP_SRC_DIR}/src/AspellChecker.h)
52 else()
53         set(dont_merge ${dont_merge} ${TOP_SRC_DIR}/src/AspellChecker.cpp)
54 endif()
55
56 if(NOT ENCHANT_FOUND)
57         list(REMOVE_ITEM lyx_sources ${TOP_SRC_DIR}/src/EnchantChecker.cpp)
58         list(REMOVE_ITEM lyx_headers ${TOP_SRC_DIR}/src/EnchantChecker.h)
59 else()
60         set(dont_merge ${dont_merge} ${TOP_SRC_DIR}/src/EnchantChecker.cpp)
61 endif()
62
63 if(NOT HUNSPELL_FOUND)
64         list(REMOVE_ITEM lyx_sources ${TOP_SRC_DIR}/src/HunspellChecker.cpp)
65         list(REMOVE_ITEM lyx_headers ${TOP_SRC_DIR}/src/HunspellChecker.h)
66 else()
67         set(dont_merge ${dont_merge} ${TOP_SRC_DIR}/src/HunspellChecker.cpp)
68 endif()
69
70
71 lyx_automoc(${TOP_SRC_DIR}/src/Compare.cpp)
72 if(WIN32)
73         lyx_automoc(${TOP_SRC_DIR}/src/Server.cpp)
74 endif()
75
76 include_directories(${CMAKE_CURRENT_BINARY_DIR}
77         ${ZLIB_INCLUDE_DIR} ${QT_INCLUDES})
78
79 lyx_add_msvc_pch(lyx)
80
81 if (LYX_MERGE_FILES)
82         if(dont_merge)
83                 list(REMOVE_ITEM lyx_sources ${dont_merge})
84         endif()
85         lyx_const_touched_files(_allinone lyx_sources)
86         set(lyx_sources ${_allinone_files} ${dont_merge})
87 endif()
88
89 if (LYX_VLD)
90         configure_file(${vld_path}/vld.ini ${CMAKE_CURRENT_BINARY_DIR}/vld.ini COPYONLY)
91         set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/memory_leak_report.txt PROPERTIES GENERATED TRUE)
92         set(vld_files ${CMAKE_CURRENT_BINARY_DIR}/vld.ini ${CMAKE_CURRENT_BINARY_DIR}/memory_leak_report.txt)
93         lyx_add_info_files(VLD ${vld_files})
94 endif()
95
96 if(WIN32)
97         set(FILE_RC ${TOP_CMAKE_PATH}/lyx.rc)
98         message(STATUS "Using icon defined in resource file: ${FILE_RC}")
99 endif()
100
101 lyx_find_info_files(LyXInfoFiles ${TOP_SRC_DIR}/*)
102 lyx_find_info_files(LyXCMakeFiles ${TOP_CMAKE_PATH}/*.txt)
103 lyx_find_info_files(LyXCMakeFiles ${TOP_CMAKE_PATH}/*.cmake)
104 lyx_find_info_files(LyXCMakeFiles ${TOP_CMAKE_PATH}/*.h)
105 lyx_find_info_files(LyXCMakeFiles ${TOP_CMAKE_PATH}/*.msvc)
106 lyx_find_info_files(LyXCMakeFiles ${TOP_MODULE_PATH}/*)
107 lyx_find_info_files(LyXCMakeFiles ${TOP_SCRIPT_PATH}/*)
108 lyx_find_info_files(LyXUiFiles ${TOP_SRC_DIR}/lib/ui/*)
109
110 add_executable(${_lyx}
111         ${WIN32_CONSOLE}
112         ${LYX_BUILD_BUNDLE}
113         ${lyx_sources}
114         ${lyx_headers}
115         ${vld_files}
116         ${FILE_RC}
117         ${lyx_info_files}
118         ${lyx_cmake_files}
119         ${OSX_BUNDLE_FILES}
120 )
121
122 add_dependencies(${_lyx} lyx_version)
123
124 set_target_properties(${_lyx} PROPERTIES FOLDER "applications/LyX")
125
126 qt_use_modules(${_lyx} Core Gui)
127
128 lyx_add_gcc_pch(${_lyx})
129
130 target_link_libraries(${_lyx}
131         mathed
132         insets
133         frontends
134         frontend_qt4
135         graphics
136         support
137         ${ICONV_LIBRARY}
138         ${QT_QTMAIN_LIBRARY}
139         ${vld_dll})
140
141 if(HUNSPELL_FOUND)
142         target_link_libraries(${_lyx} ${HUNSPELL_LIBRARY})
143 endif()
144 if(ASPELL_FOUND)
145         target_link_libraries(${_lyx} ${ASPELL_LIBRARY})
146 endif()
147 if(ENCHANT_FOUND)
148         target_link_libraries(${_lyx} ${ENCHANT_LIBRARY})
149 endif()
150 if(Magic_FOUND)
151         target_link_libraries(${_lyx} ${Magic_LIBRARY})
152 endif()
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 project_source_group("${GROUP_CODE}" lyx_sources lyx_headers)
168
169 install(TARGETS ${_lyx} 
170     BUNDLE DESTINATION . COMPONENT Runtime
171     RUNTIME DESTINATION bin COMPONENT Runtime)
172
173 if(LYX_BUNDLE)
174         if(APPLE)
175                 # Now that lyx executable is defined, we can the files that should be included
176                 # directly in the bundle. Note that resources are not copied with this mechanism:
177                 # only the files necessary to run the executable are processed here (LyX.sdef, LyX.icns, etc.)
178                 list(LENGTH OSX_BUNDLE_FILES OSX_BUNDLE_LAST_INDEX)
179                 math(EXPR OSX_BUNDLE_LAST_INDEX "${OSX_BUNDLE_LAST_INDEX} - 1")
180                 foreach(_i RANGE ${OSX_BUNDLE_LAST_INDEX})
181                     list(GET OSX_BUNDLE_FILES ${_i} _file)
182                     list(GET OSX_BUNDLE_DIRS ${_i} _directory)
183                     # Sets the location of the file into the OS X bundle
184                         set_source_files_properties("${_file}" PROPERTIES MACOSX_PACKAGE_LOCATION "${_directory}")
185                 endforeach()
186
187                 set_target_properties(${_lyx} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_BINARY_DIR}/../Info.plist")
188         endif()
189 endif()
190
191 add_subdirectory(tests)