]> git.lyx.org Git - features.git/blob - development/cmake/Install.cmake
Cmake build: Set new installation paths
[features.git] / development / cmake / Install.cmake
1
2 # TODO: set correct path in call to cmake
3 # e.g. cmake /usr/src/lyx/lyx-devel/development/cmake -DCMAKE_INSTALL_PREFIX=/usr/local -Dnls=1
4
5 if(NOT(LYX_BUNDLE) AND APPLE)
6         message(STATUS "Installing to ${CMAKE_INSTALL_PREFIX}, defined by CMAKE_INSTALL_PREFIX")
7 endif()
8
9 # the macro scans the directories "_parent_src_dir/_dir/_current_dir" for *._file_type files
10 # and installs the files in CMAKE_INSTALL_PREFIX/_current_dir
11 # dir_item is on item of the remaining arguments
12 #
13 # Special handling for ${_file_type} == "*"
14 #     Here we try to exclude files which we do not want to install
15 # Depending on _what, installation goes to
16 # data -> ${LYX_DATA_SUBDIR}
17 # font -> fonts/truetype/${_lyx}/
18 # bin -> bin
19 # tex -> texmf/tex/latex/${_lyx}/
20 macro(lyx_install _what _parent_src_dir _gl_dir _file_type)
21   #message("checking parents ${_parent_src_dir}")
22   file(GLOB _dirs RELATIVE "${_parent_src_dir}" ${_parent_src_dir}/${_gl_dir})
23   #cmake bug on Windows: if _gl_dir==. _dirs is empty but on linux _dirs==.
24   if(NOT _dirs)
25     set(_dirs .)
26   endif()
27   # Select installation dir
28   if ("${_what}" STREQUAL "data")
29     set(_dest_subdir "${LYX_DATA_SUBDIR}")
30   elseif ("${_what}" STREQUAL "font")
31     set(_dest_subdir "fonts/truetype/${_lyx}/")
32   elseif ("${_what}" STREQUAL "bin")
33     set(_dest_subdir "bin/")
34   elseif ("${_what}" STREQUAL "tex")
35     set(_dest_subdir "texmf/tex/latex/${_lyx}/")
36   else()
37     message(FATAL_ERROR "Undefined parameter _what = ${_what} in call to lyx_install")
38   endif()
39   #message(STATUS "_dest_subdir = ${_dest_subdir}")
40   foreach(_dir ${_dirs})
41     foreach(_glob_dir ${ARGN})
42       file(GLOB _dir_list ${_parent_src_dir}/${_dir}/${_glob_dir})
43       if(NOT _dir_list)
44         if(_glob_dir STREQUAL ".")
45           set(_dir_list ${_parent_src_dir}/${_dir}/.)
46         endif()
47       endif()
48       #message(STATUS "${_dir}/${_glob_dir} -> ${_dir_list} ")
49       foreach(_current_dir ${_dir_list})
50         file(GLOB _item_list ${_current_dir}/${_file_type})
51         #cmake bug: globbing with * also returns directories on Windows
52         set(files_list ${_item_list})
53         set(program_list)
54         foreach(_current_item ${_item_list})
55           if(files_list)
56             if(IS_DIRECTORY ${_current_item})
57               #message(STATUS "removing dir ${_current_item}")
58               list(REMOVE_ITEM files_list "${_current_item}")
59             else()
60               if ("${_file_type}" STREQUAL "*")
61                 foreach(_mask "/\\.[^/]+$" "\\.in$" "\\.py$" "CMakeLists\\.txt$" "\\.lyx~$")
62                   if(_current_item MATCHES ${_mask})
63                     #message(STATUS "removing item ${_current_item}")
64                     list(REMOVE_ITEM files_list "${_current_item}")
65                   endif()
66                 endforeach()
67               endif()
68             endif()
69           endif()
70         endforeach(_current_item)
71         if(files_list)
72           list(REMOVE_ITEM files_list "${_current_dir}/lyx.svg")
73           list(REMOVE_ITEM files_list "${_current_dir}/Makefile.am")
74           list(REMOVE_ITEM files_list "${_current_dir}/layouttranslations")
75           GET_FILENAME_COMPONENT(_base_dir ${_current_dir} NAME)
76           if(_glob_dir STREQUAL ".")
77             set(_base_dir .)
78           endif()
79
80           install(FILES ${files_list} DESTINATION "${_dest_subdir}${_dir}/${_base_dir}")
81           #message(STATUS "Installing  ${files_list} to ${_dest_subdir}${_dir}/${_base_dir}")
82         endif()
83         if(program_list)
84           if(_glob_dir STREQUAL ".")
85             set(_base_dir .)
86           endif()
87           install(FILES ${program_list} DESTINATION "${_dest_subdir}${_dir}/${_base_dir}")
88         endif()
89       endforeach(_current_dir)
90     endforeach(_glob_dir)
91   endforeach(_dir)
92 endmacro(lyx_install)
93
94
95 # language-specific-directories (like ca, de, es ...) are now globbed as "[a-z][a-z]"
96 set(_all_languages "[a-z][a-z]")
97
98 lyx_install("data" ${TOP_SRC_DIR}/lib bind         *.bind   . ${_all_languages})
99 lyx_install("data" ${TOP_SRC_DIR}/lib commands     *.def    .)
100
101 # this is handled in doc/CMakeLists.txt
102 #lyx_install("data" ${TOP_SRC_DIR}/lib doc          *.lyx    . ${_all_languages})
103 #lyx_install("data" ${TOP_SRC_DIR}/lib doc          *.txt    . ${_all_languages})
104 lyx_install("data" ${TOP_SRC_DIR}/lib doc          *      biblio clipart)
105
106 lyx_install("data" ${TOP_SRC_DIR}/lib doc/${_all_languages} *    clipart)
107
108 lyx_install("data" ${TOP_SRC_DIR}/lib examples     *      . ${_all_languages} springer thesis)
109 lyx_install("font" ${TOP_SRC_DIR}/lib/fonts .      *      .)
110 foreach(_imgext "png" "svgz" "gif" "xpm")
111   lyx_install("data" ${TOP_SRC_DIR}/lib images       "*.${_imgext}"      . ipa commands attic classic oxygen)
112   lyx_install("data" ${TOP_SRC_DIR}/lib images/math  "*.${_imgext}"      . oxygen)
113 endforeach()
114 lyx_install("data" ${TOP_SRC_DIR}/lib kbd          *      .)
115 lyx_install("data" ${TOP_SRC_DIR}/lib layouts      *      .)
116 lyx_install("data" ${TOP_SRC_DIR}/lib lyx2lyx      *.py   .)
117 lyx_install("data" ${TOP_SRC_DIR}/lib scripts      *.py   .)
118 lyx_install("data" ${TOP_SRC_DIR}/lib .            *.py   .)
119 lyx_install("data" ${TOP_SRC_DIR}/lib scripts      *.R    .)
120 lyx_install("data" ${TOP_SRC_DIR}/lib templates    *      . springer)
121 lyx_install("tex"  ${TOP_SRC_DIR}/lib/tex .        *      .)
122 lyx_install("data" ${TOP_SRC_DIR}/lib ui           *      .)
123 lyx_install("data" ${TOP_SRC_DIR}/lib .            *      .)
124
125 # Install
126 if(APPLE)
127   if(LYX_BUNDLE)
128     install(FILES ${TOP_SRC_DIR}/development/MacOSX/spotlight/Info.plist DESTINATION "${MACOSX_BUNDLE_STARTUP_COMMAND}/Contents/Library/Spotlight/LyX-Metadata.mdimporter/Contents")
129     install(FILES "${TOP_SRC_DIR}/development/MacOSX/PkgInfo" DESTINATION "${MACOSX_BUNDLE_STARTUP_COMMAND}/Contents")
130   endif()
131
132   install(FILES "${TOP_SRC_DIR}/development/MacOSX/lyxeditor" DESTINATION "${LYX_UTILITIES_INSTALL_PATH}")
133   install(FILES "${TOP_SRC_DIR}/development/MacOSX/LyX.icns" DESTINATION "${LYX_DATA_SUBDIR}")
134   set(program_suffix ${PROGRAM_SUFFIX})
135 elseif(UNIX)
136   set(program_suffix ${PROGRAM_SUFFIX})
137   configure_file(${TOP_SRC_DIR}/lib/lyx.desktop.in lyx${PROGRAM_SUFFIX}.desktop)
138   install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lyx${PROGRAM_SUFFIX}.desktop DESTINATION ${SYSTEM_DATADIR}/applications)
139   install(FILES ${TOP_SRC_DIR}/lib/images/lyx.svg RENAME lyx${PROGRAM_SUFFIX}.svg DESTINATION ${SYSTEM_DATADIR}/icons/hicolor/scalable/apps/)
140 endif()