| 1 |
cmake_minimum_required(VERSION ${CADABRA_CMAKE_VERSION}) |
| 2 |
project(CadabraGtkmm) |
| 3 |
|
| 4 |
|
| 5 |
#--------------------------------------------------------------------------- |
| 6 |
# Preamble. |
| 7 |
#--------------------------------------------------------------------------- |
| 8 |
|
| 9 |
message(STATUS "Using GTKMM frontend") |
| 10 |
|
| 11 |
set(INSTALL_SHARE_DIR share/cadabra2 CACHE PATH "Installation directory for shared files.") |
| 12 |
set(INSTALL_IMAGES_DIR share/cadabra2/images CACHE PATH "Installation directory for image files.") |
| 13 |
set(INSTALL_DESKTOP_DIR share/applications CACHE PATH "Installation directory for .desktop files.") |
| 14 |
set(INSTALL_ICONS_DIR share/icons CACHE PATH "Installation directory for icons.") |
| 15 |
|
| 16 |
|
| 17 |
#--------------------------------------------------------------------------- |
| 18 |
# Locate libraries. |
| 19 |
#--------------------------------------------------------------------------- |
| 20 |
|
| 21 |
find_package(Threads) |
| 22 |
find_package(SQLITE3) |
| 23 |
find_package(GLIBMM) |
| 24 |
find_package(GTKMM3) |
| 25 |
find_package(Boost 1.45.0 COMPONENTS system) |
| 26 |
set(Boost_USE_STATIC_LIBS OFF) |
| 27 |
set(Boost_USE_MULTITHREADED ON) |
| 28 |
set(Boost_USE_STATIC_RUNTIME OFF) |
| 29 |
|
| 30 |
|
| 31 |
#--------------------------------------------------------------------------- |
| 32 |
# Enumerate input files and directories. |
| 33 |
#--------------------------------------------------------------------------- |
| 34 |
|
| 35 |
set(cadabra_gtk_src |
| 36 |
main.cc |
| 37 |
ChooseColoursDialog.cc |
| 38 |
DiffViewer.cc |
| 39 |
NotebookWindow.cc |
| 40 |
NotebookCanvas.cc |
| 41 |
SelectFileDialog.cc |
| 42 |
TeXView.cc |
| 43 |
CodeInput.cc |
| 44 |
ImageView.cc |
| 45 |
Cadabra.cc |
| 46 |
Console.cc |
| 47 |
Keywords.cc |
| 48 |
../common/TeXEngine.cc |
| 49 |
../common/lodepng.cc |
| 50 |
# ../common/exec-stream.cc |
| 51 |
${CADABRA_LIBS_DIR}/tiny-process-library/process.cpp |
| 52 |
${CADABRA_LIBS_DIR}/base64/base64.cc |
| 53 |
) |
| 54 |
if (MSVC) |
| 55 |
list(APPEND cadabra_gtk_src ${CADABRA_LIBS_DIR}/tiny-process-library/process_win.cpp) |
| 56 |
# Configure and add resource file to list of sources |
| 57 |
configure_file(win_res.rc.in ${CMAKE_CURRENT_BINARY_DIR}/win_res.rc) |
| 58 |
list(APPEND cadabra_gtk_src ${CMAKE_CURRENT_BINARY_DIR}/win_res.rc) |
| 59 |
else() |
| 60 |
list(APPEND cadabra_gtk_src ${CADABRA_LIBS_DIR}/tiny-process-library/process_unix.cpp) |
| 61 |
endif() |
| 62 |
|
| 63 |
|
| 64 |
#--------------------------------------------------------------------------- |
| 65 |
# Include directories and preprocessor definitions. |
| 66 |
#--------------------------------------------------------------------------- |
| 67 |
|
| 68 |
include_directories( |
| 69 |
"." |
| 70 |
"${CADABRA_CORE_DIR}" |
| 71 |
"${CADABRA_CLIENT_SERVER_DIR}" |
| 72 |
"${CADABRA_LIBS_DIR}/internal/include" |
| 73 |
"${CADABRA_LIBS_DIR}/websocketpp" |
| 74 |
"${CADABRA_LIBS_DIR}/tiny-process-library" |
| 75 |
"${CADABRA_LIBS_DIR}/nlohmann" |
| 76 |
${Boost_INCLUDE_DIRS} |
| 77 |
${SQLITE3_INCLUDE_DIR} |
| 78 |
) |
| 79 |
|
| 80 |
if(ENABLE_SYSTEM_JSONCPP) |
| 81 |
include_directories( |
| 82 |
${JSONCPP_INCLUDE_DIRS} |
| 83 |
) |
| 84 |
else() |
| 85 |
include_directories( |
| 86 |
"${CADABRA_LIBS_DIR}/jsoncpp" |
| 87 |
) |
| 88 |
endif() |
| 89 |
|
| 90 |
add_definitions( |
| 91 |
"-D_WEBSOCKETPP_CPP11_STL_" |
| 92 |
"-DBOOST_LOG_DYN_LINK" |
| 93 |
) |
| 94 |
|
| 95 |
#--------------------------------------------------------------------------- |
| 96 |
# Targets. |
| 97 |
#--------------------------------------------------------------------------- |
| 98 |
|
| 99 |
if ((NOT MSVC) OR (MSVC AND CADABRA_DEBUG_BUILD) OR (MSVC AND MSVC_TARGET_CONSOLE)) |
| 100 |
add_executable(cadabra2-gtk ${cadabra_gtk_src}) |
| 101 |
else() |
| 102 |
add_executable(cadabra2-gtk WIN32 ${cadabra_gtk_src}) |
| 103 |
endif() |
| 104 |
|
| 105 |
target_link_libraries(cadabra2-gtk |
| 106 |
cadabra_client |
| 107 |
${Boost_LIBRARIES} |
| 108 |
${GLIBMM_LIBRARIES} |
| 109 |
${GTKMM3_LIBRARIES} |
| 110 |
${SQLITE3_LIBRARIES} |
| 111 |
Threads::Threads |
| 112 |
# dl |
| 113 |
) |
| 114 |
|
| 115 |
|
| 116 |
#--------------------------------------------------------------------------- |
| 117 |
# Installation. |
| 118 |
#--------------------------------------------------------------------------- |
| 119 |
|
| 120 |
install(TARGETS cadabra2-gtk DESTINATION bin) |
| 121 |
|
| 122 |
# Create installation directories with correct permissions. |
| 123 |
if (NOT INSTALL_TARGETS_ONLY) |
| 124 |
install_directory_permissions(${INSTALL_SHARE_DIR}) |
| 125 |
install_directory_permissions(${INSTALL_IMAGES_DIR}) |
| 126 |
install_directory_permissions(${INSTALL_DESKTOP_DIR}) |
| 127 |
install_directory_permissions(${INSTALL_ICONS_DIR}) |
| 128 |
install_directory_permissions("${INSTALL_ICONS_DIR}/hicolor") |
| 129 |
install_directory_permissions("${INSTALL_ICONS_DIR}/hicolor/64x64") |
| 130 |
install_directory_permissions("${INSTALL_ICONS_DIR}/hicolor/256x256") |
| 131 |
install_directory_permissions("${INSTALL_ICONS_DIR}/hicolor/scalable") |
| 132 |
install_directory_permissions("${INSTALL_ICONS_DIR}/hicolor/64x64/apps") |
| 133 |
install_directory_permissions("${INSTALL_ICONS_DIR}/hicolor/256x256/apps") |
| 134 |
install_directory_permissions("${INSTALL_ICONS_DIR}/hicolor/scalable/apps") |
| 135 |
|
| 136 |
install(FILES ${CADABRA_IMAGES_DIR}/256x256/cadabra2-gtk.png DESTINATION ${INSTALL_IMAGES_DIR}) |
| 137 |
|
| 138 |
#xdg-desktop-menu messes up the file permissions, so we just install things by hand... |
| 139 |
#install(CODE "execute_process(COMMAND ${XDG-DESKTOP-MENU_EXECUTABLE} install --novendor ${PROJECT_SOURCE_DIR}/../../config/cadabra2.desktop)") |
| 140 |
|
| 141 |
# Icons are a nightmare... |
| 142 |
# |
| 143 |
# - You cannot just plainly install in /usr/share/icons/hicolor because that is not where Homebrew/OS X |
| 144 |
# stores the icons (it uses /usr/local/share/icons/hicolor). |
| 145 |
# - /usr/local/share/icons/hicolor may lack an index.theme file, which means that things below there |
| 146 |
# actually never get picked up (or at least not by cinnamon). |
| 147 |
# - So we need to copy index.theme into /usr/local if it does not exist there yet. |
| 148 |
# - In order to avoid all that, just use /usr/share/icons on Linux; package managers will install it |
| 149 |
# there anyway. |
| 150 |
# - gtk-update-icon-cache is broken and only works half of the time. |
| 151 |
# |
| 152 |
# BUT: package managers really do not like this approach, so we're back to doing the proper thing and |
| 153 |
# hope window managers will eventually fix this. |
| 154 |
|
| 155 |
set(ICON_PREFIX "${CMAKE_INSTALL_PREFIX}") |
| 156 |
|
| 157 |
set(ICON_PREFIX_WITH_DESTDIR $ENV{DESTDIR}${ICON_PREFIX}) |
| 158 |
install(FILES ${CADABRA_IMAGES_DIR}/64x64/cadabra2-gtk.png DESTINATION ${ICON_PREFIX}/share/icons/hicolor/64x64/apps) |
| 159 |
install(FILES ${CADABRA_IMAGES_DIR}/128x128/cadabra2-gtk.png DESTINATION ${ICON_PREFIX}/share/icons/hicolor/128x128/apps) |
| 160 |
install(FILES ${CADABRA_IMAGES_DIR}/256x256/cadabra2-gtk.png DESTINATION ${ICON_PREFIX}/share/icons/hicolor/256x256/apps) |
| 161 |
install(FILES ${CADABRA_IMAGES_DIR}/cadabra2-gtk.svg DESTINATION ${ICON_PREFIX}/share/icons/hicolor/scalable/apps) |
| 162 |
install(FILES ${CADABRA_ROOT_DIR}/config/cadabra2-gtk.desktop DESTINATION ${ICON_PREFIX}/share/applications) |
| 163 |
install(CODE "execute_process(COMMAND touch ${ICON_PREFIX_WITH_DESTDIR}/share/icons/hicolor/icon-theme.cache)") |
| 164 |
install(CODE "execute_process(COMMAND gtk-update-icon-cache-3.0 {ICON_PREFIX_WITH_DESTDIR}/share/icons/hicolor)") |
| 165 |
install(CODE "execute_process(COMMAND chmod go+r ${ICON_PREFIX_WITH_DESTDIR}/share/icons/hicolor/icon-theme.cache)") |
| 166 |
|
| 167 |
# Install shared libraries on Windows. |
| 168 |
# https://stackoverflow.com/questions/32662215/how-do-you-install-gtk-3-0-on-windows |
| 169 |
if(WIN32) |
| 170 |
# All things to make GTK apps work and look decent on Windows 10. |
| 171 |
# We always need the Adwaita theme for fallback icons, but VCPKG |
| 172 |
# does not yet distribute it, so we include it here (also see |
| 173 |
# https://github.com/Microsoft/vcpkg/pull/693). The Windows 10 theme |
| 174 |
# comes from https://github.com/B00merang-Project/Windows-10. |
| 175 |
# Settings as suggested by Luca Bacci on gtk-devel-list. |
| 176 |
install(FILES config/gschemas.compiled DESTINATION ${CMAKE_INSTALL_PREFIX}/share/glib-2.0/schemas) |
| 177 |
install(FILES config/settings.ini DESTINATION ${CMAKE_INSTALL_PREFIX}/etc/gtk-3.0/) |
| 178 |
install(DIRECTORY theme/Windows10 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/themes) |
| 179 |
install(DIRECTORY icons/Adwaita DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons) |
| 180 |
install(DIRECTORY icons/hicolor DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons) |
| 181 |
install_dlls_from("frontend/gtkmm") |
| 182 |
endif() |
| 183 |
endif() |
| 184 |
|
| 185 |
# manual pages |
| 186 |
if(NOT MSVC) |
| 187 |
install( |
| 188 |
FILES |
| 189 |
../../man/man1/cadabra2-gtk.1 |
| 190 |
DESTINATION |
| 191 |
share/man/man1 |
| 192 |
) |
| 193 |
endif() |