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