]> git.lyx.org Git - lyx.git/blob - development/cmake/Install.cmake
5402d5bc42669f4afa65c1e6968fe04a89f5f2c4
[lyx.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/share/lyx2.0 -Dnls=1
4
5 message(STATUS "Installing to ${CMAKE_INSTALL_PREFIX}, defined by CMAKE_INSTALL_PREFIX")
6
7 # the macro scans the directories "_parent_src_dir/_dir/_current_dir" for *._file_type files
8 # and installs the files in CMAKE_INSTALL_PREFIX/_current_dir
9 # dir_item is on item of the remaining arguments
10 macro(lyx_install _parent_src_dir _gl_dir _file_type)
11   #message("checking parents ${_parent_src_dir}")
12   file(GLOB _dirs RELATIVE "${_parent_src_dir}" ${_parent_src_dir}/${_gl_dir})
13   #cmake bug on Windows: if _gl_dir==. _dirs is empty but on linux _dirs==.
14   if(NOT _dirs)
15     set(_dirs .)
16   endif() 
17   foreach(_dir ${_dirs})
18     foreach(_glob_dir ${ARGN})
19       file(GLOB _dir_list ${_parent_src_dir}/${_dir}/${_glob_dir})
20       if(NOT _dir_list)
21         if(_glob_dir STREQUAL ".")
22           set(_dir_list ${_parent_src_dir}/${_dir}/.)
23         endif()
24       endif()
25       #message(STATUS "${_dir}/${_glob_dir} -> ${_dir_list} ")
26       foreach(_current_dir ${_dir_list})
27         file(GLOB _item_list ${_current_dir}/${_file_type})
28         #cmake bug: globbing with * also returns directories on Windows
29         set(files_list ${_item_list})
30         foreach(_current_item ${_item_list})
31           if(files_list)
32             if(IS_DIRECTORY ${_current_item})
33               #message(STATUS "removing dir ${_current_item}")
34               list(REMOVE_ITEM files_list "${_current_item}")
35             else()
36               if(_current_item MATCHES "/\\.[^/]+$")
37                 #message(STATUS "removing hidden ${_current_item}")
38                 list(REMOVE_ITEM files_list "${_current_item}")
39               endif()
40               if(_current_item MATCHES "\\.in$")
41                 #message(STATUS "removing .in file ${_current_item}")
42                 list(REMOVE_ITEM files_list "${_current_item}")
43               endif()
44             endif()
45           endif()
46         endforeach(_current_item)
47         if(files_list)
48           list(REMOVE_ITEM files_list "${_current_dir}/lyx.svg")
49           list(REMOVE_ITEM files_list "${_current_dir}/Makefile.am")
50           list(REMOVE_ITEM files_list "${_current_dir}/layouttranslations")
51           GET_FILENAME_COMPONENT(_base_dir ${_current_dir} NAME)
52           if(_glob_dir STREQUAL ".")
53             set(_base_dir .)
54           endif()
55           #message(STATUS "install ${LYX_DATA_SUBDIR}${_dir}/${_base_dir}: ${files_list} ")
56           #message(STATUS "install at ${CMAKE_INSTALL_PREFIX}/${LYX_DATA_SUBDIR}${_dir}/${_base_dir}")
57           install(FILES ${files_list} DESTINATION ${LYX_DATA_SUBDIR}${_dir}/${_base_dir})
58         endif()
59       endforeach(_current_dir)
60     endforeach(_glob_dir)
61   endforeach(_dir)
62 endmacro(lyx_install)
63
64
65 # language-specific-directories (like ca, de, es ...) are now globbed as "[a-z][a-z]"
66 set(_all_languages "[a-z][a-z]")
67
68 lyx_install(${TOP_SRC_DIR}/lib bind         *.bind   . ${_all_languages})
69 lyx_install(${TOP_SRC_DIR}/lib commands     *.def    .)
70
71 # this is handled in doc/CMakeLists.txt
72 #lyx_install(${TOP_SRC_DIR}/lib doc          *.lyx    . ${_all_languages})
73 #lyx_install(${TOP_SRC_DIR}/lib doc          *.txt    . ${_all_languages})
74 lyx_install(${TOP_SRC_DIR}/lib doc          *      biblio clipart)
75
76 lyx_install(${TOP_SRC_DIR}/lib doc/${_all_languages} *    clipart)
77
78 lyx_install(${TOP_SRC_DIR}/lib examples     *      . ${_all_languages})
79 lyx_install(${TOP_SRC_DIR}/lib fonts        *      .)
80 lyx_install(${TOP_SRC_DIR}/lib images       *      . math commands attic classic oxygen)
81 lyx_install(${TOP_SRC_DIR}/lib kbd          *      .)
82 lyx_install(${TOP_SRC_DIR}/lib layouts      *      .)
83 lyx_install(${TOP_SRC_DIR}/lib lyx2lyx      *.py   .)
84 lyx_install(${TOP_SRC_DIR}/lib scripts      *.py   .)
85 lyx_install(${TOP_SRC_DIR}/lib scripts      *.R    .)
86 lyx_install(${TOP_SRC_DIR}/lib templates    *      . attic springer thesis)
87 lyx_install(${TOP_SRC_DIR}/lib tex          *      .)
88 lyx_install(${TOP_SRC_DIR}/lib ui           *      .)
89 lyx_install(${TOP_SRC_DIR}/lib .            *      .)
90
91 if(UNIX)
92   set(program_suffix ${PROGRAM_SUFFIX})
93   configure_file(${TOP_SRC_DIR}/lib/lyx.desktop.in lyx${PROGRAM_SUFFIX}.desktop)
94   install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lyx${PROGRAM_SUFFIX}.desktop DESTINATION applications)
95   install(FILES ${TOP_SRC_DIR}/lib/images/lyx.svg RENAME lyx${PROGRAM_SUFFIX}.svg DESTINATION images)
96 endif()