CMakeLists.txt 7.97 KB
Newer Older
1 2 3 4 5 6 7 8
set(qt_SRCS
  mainqt.cpp
  platformtools.cpp
  kid3mainwindow.cpp
  recentfilesmenu.cpp
  browserdialog.cpp
  messagedialog.cpp
  configdialog.cpp
9
  mainwindowconfig.cpp
10 11 12 13 14 15 16 17 18 19 20 21
  shortcutsmodel.cpp
  shortcutsdelegate.cpp
)
set(qt_MOC_HDRS
  kid3mainwindow.h
  recentfilesmenu.h
  browserdialog.h
  messagedialog.h
  configdialog.h
  shortcutsmodel.h
  shortcutsdelegate.h
)
22 23
qt4_wrap_cpp(qt_GEN_MOC_SRCS ${qt_MOC_HDRS})
set(qt_SRCS ${qt_SRCS} ${qt_GEN_MOC_SRCS})
24 25 26 27 28 29 30 31 32 33 34 35 36

if (APPLE)
  # Icon and properties for .plist file
  set(MACOSX_BUNDLE_BUNDLE_NAME "Kid3")
  set(MACOSX_BUNDLE_ICON_FILE kid3.icns)
  set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${CPACK_PACKAGE_VERSION})
  set(MACOSX_BUNDLE_GUI_IDENTIFIER "net.sourceforge.kid3")
  set(MACOSX_BUNDLE_COPYRIGHT "Copyright (c) 2003-${RELEASE_YEAR} Urs Fleisch")
  set_source_files_properties(kid3.icns
    PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
  set(qt_SRCS ${qt_SRCS} kid3.icns)
  set_source_files_properties(qt.conf
    PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
Urs Fleisch's avatar
Urs Fleisch committed
37
  set(qt_SRCS ${qt_SRCS} qt.conf)
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
elseif (WIN32)
  if (MINGW)
    # support for Windows resource files with MinGW
    set(CMAKE_RC_COMPILER_INIT windres)
    enable_language(RC)
    set(CMAKE_RC_COMPILE_OBJECT
      "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
  endif (MINGW)
  # add Windows resource file with icon
  set(qt_SRCS ${qt_SRCS} kid3win.rc)
endif (APPLE)

if (UNIX AND NOT APPLE)
  find_program(GZIP_PROGRAM gzip)
  # install desktop file and icons for Linux
  add_custom_command(OUTPUT kid3-qt.desktop
    COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/fixdesktop.pl
      <${CMAKE_CURRENT_SOURCE_DIR}/../kid3.desktop >kid3-qt.desktop
    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../kid3.desktop
  )
  add_custom_target("desktop-file" ALL DEPENDS kid3-qt.desktop)
  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kid3-qt.desktop
    DESTINATION "${WITH_DATAROOTDIR}/applications")
  if (GZIP_PROGRAM)
    add_custom_command(OUTPUT kid3-qt.svg
      COMMAND ${GZIP_PROGRAM} -cd ${CMAKE_CURRENT_SOURCE_DIR}/../hisc-app-kid3.svgz >kid3-qt.svg
      DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../hisc-app-kid3.svgz
    )
    set(qt_SRCS ${qt_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/kid3-qt.svg)
    install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kid3-qt.svg
            DESTINATION "${WITH_DATAROOTDIR}/icons/hicolor/scalable/apps")
  else (GZIP_PROGRAM)
    install(FILES ../hisc-app-kid3.svgz
            DESTINATION "${WITH_DATAROOTDIR}/icons/hicolor/scalable/apps"
            RENAME kid3-qt.svgz)
  endif (GZIP_PROGRAM)
  install(FILES ../hi48-app-kid3.png
          DESTINATION "${WITH_DATAROOTDIR}/icons/hicolor/48x48/apps"
          RENAME kid3-qt.png)
  install(FILES ../hi32-app-kid3.png
          DESTINATION "${WITH_DATAROOTDIR}/icons/hicolor/32x32/apps"
          RENAME kid3-qt.png)
  install(FILES ../hi16-app-kid3.png
          DESTINATION "${WITH_DATAROOTDIR}/icons/hicolor/16x16/apps"
          RENAME kid3-qt.png)
83 84 85 86
elseif (APPLE)
  install(FILES ../hi48-app-kid3.png
          DESTINATION ${WITH_DATAROOTDIR}
          RENAME kid3.png)
87 88
endif (UNIX AND NOT APPLE)

89
add_definitions(${QT_DEFINITIONS} ${QT_EXECUTABLE_COMPILE_FLAGS})
90 91 92 93 94
set(qt_RESOURCES kid3.qrc)
qt4_add_resources(qt_GEN_RCS ${qt_RESOURCES})
add_executable(${KID3_EXECUTABLE} MACOSX_BUNDLE WIN32
  ${qt_SRCS} ${qt_GEN_RCS})

Urs Fleisch's avatar
Urs Fleisch committed
95
target_link_libraries(${KID3_EXECUTABLE} kid3-gui -lstdc++)
96

97 98 99 100 101 102 103
if (APPLE)
  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../../../macosx/Info.plist.in
                 ${CMAKE_CURRENT_BINARY_DIR}/Info.plist)
  set_target_properties(${KID3_EXECUTABLE} PROPERTIES
      MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist)
endif (APPLE)

104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
install(TARGETS ${KID3_EXECUTABLE}
  BUNDLE DESTINATION .
  RUNTIME DESTINATION ${WITH_BINDIR})

if (APPLE OR WIN32)

  # Put Qt libraries and plugins into installation package to create a
  # standalone bundle on Mac OS X and Windows
  set(plugin_dest_dir ${WITH_BINDIR})
  set(bundle_app
   "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${WITH_BINDIR}/${KID3_EXECUTABLE}")
  if (APPLE)
    set(plugin_dest_dir kid3.app/Contents/PlugIns)
    set(bundle_app "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/kid3.app")
  endif (APPLE)
  if (WIN32)
    set(bundle_app
      "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${WITH_BINDIR}/kid3.exe")
  endif (WIN32)
  string(REPLACE "/./" "/" bundle_app ${bundle_app})

  # Install Qt JPEG and Phonon plugins
  install(DIRECTORY "${QT_PLUGINS_DIR}/imageformats"
    DESTINATION ${plugin_dest_dir}
    FILES_MATCHING PATTERN "*jpeg${CMAKE_SHARED_LIBRARY_SUFFIX}"
                   PATTERN "*jpeg4${CMAKE_SHARED_LIBRARY_SUFFIX}")

  if (HAVE_QT5)
    if (APPLE)
      install(DIRECTORY "${QT_PLUGINS_DIR}/platforms"
        DESTINATION kid3.app/Contents/MacOS
        FILES_MATCHING PATTERN "libqcocoa${CMAKE_SHARED_LIBRARY_SUFFIX}")
      install(DIRECTORY "${QT_PLUGINS_DIR}/mediaservice"
        DESTINATION ${plugin_dest_dir}
        FILES_MATCHING PATTERN "libqavfmediaplayer${CMAKE_SHARED_LIBRARY_SUFFIX}")
    elseif (WIN32)
      install(DIRECTORY "${QT_PLUGINS_DIR}/platforms"
        DESTINATION ${plugin_dest_dir}
        FILES_MATCHING PATTERN "qwindows${CMAKE_SHARED_LIBRARY_SUFFIX}")
      install(DIRECTORY "${QT_PLUGINS_DIR}/mediaservice"
        DESTINATION ${plugin_dest_dir}
        FILES_MATCHING PATTERN "dsengine${CMAKE_SHARED_LIBRARY_SUFFIX}")
    endif (APPLE)
  endif (HAVE_QT5)

  if (HAVE_PHONON)
    install(DIRECTORY "${QT_PLUGINS_DIR}/phonon_backend"
      DESTINATION ${plugin_dest_dir}
      FILES_MATCHING
        PATTERN "*d4${CMAKE_SHARED_LIBRARY_SUFFIX}" EXCLUDE
        PATTERN "*${CMAKE_SHARED_LIBRARY_SUFFIX}")
  endif (HAVE_PHONON)

  # Install and fix up all dependencies of the executable and the plugins.
  # On Mac OS X only keep the i386 code in the Qt libraries and plugins.
  install(CODE "
    file(GLOB_RECURSE QTPLUGINS
      \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
    if (APPLE)
      file(GLOB_RECURSE QTPLATFORMPLUGINS
        \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/kid3.app/Contents/MacOS/platforms/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
      set(QTPLUGINS \"\${QTPLUGINS};\${QTPLATFORMPLUGINS}\")
    endif (APPLE)
167 168
    file(GLOB_RECURSE KID3PLUGINS
      \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${WITH_PLUGINSDIR}/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
169
    include(BundleUtilities)
170 171 172 173 174
    set(bundle_libs \"\${QTPLUGINS};\${KID3PLUGINS}\")
    if (APPLE AND BUILD_CLI_APP)
      set(bundle_libs \"\${bundle_libs};\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${WITH_LIBDIR}/kid3-cli\")
    endif (APPLE AND BUILD_CLI_APP)
    fixup_bundle(\"${bundle_app}\" \"\${bundle_libs}\" \"${QT_LIBRARY_DIR}\")
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
    if (APPLE)
      file(GLOB_RECURSE _qtlibs \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/kid3.app/Contents/Frameworks/*Qt*\")
      file(GLOB_RECURSE _plugins \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/kid3.app/Contents/PlugIns/*.dylib\")
      foreach (_universalBinary \${_plugins} \${_qtlibs})
        execute_process(COMMAND lipo \${_universalBinary} -output \${_universalBinary} -thin i386)
      endforeach (_universalBinary \${plugins})
    endif (APPLE)
    ")

endif (APPLE OR WIN32)

if (WIN32)
  if (NOT HAVE_QT5)
    # Unfortunately, the binutils which come with the gcc-4.4.0 in the MinGW
    # for Qt generate an executable which cannot be analyzed with dumpbin.
    # This happens when Kid3 is linked with libav (used with Chromaprint).
    # Therefore, the dependencies for kid3.exe are not added to the bundle.
    # This workaround adds the missing files.
    install(FILES "${QT_BINARY_DIR}/QtNetwork4.dll"
                  "${QT_BINARY_DIR}/QtXml4.dll"
            DESTINATION ${WITH_BINDIR})
  else (NOT HAVE_QT5)
    if (EXISTS "${_qt5Dir}/../ported-x32/bin/libjpeg-8.dll")
      install(FILES "${_qt5Dir}/../ported-x32/bin/libjpeg-8.dll"
              DESTINATION ${WITH_BINDIR})
    endif ()
201 202 203 204
    string(TOUPPER ${CMAKE_BUILD_TYPE} _build_type_uc)
    get_target_property(_qt5xml_location Qt5::Xml IMPORTED_LOCATION_${_build_type_uc})
    install(FILES ${_qt5xml_location}
            DESTINATION ${WITH_BINDIR})
205 206
  endif (NOT HAVE_QT5)
endif (WIN32)