CMakeLists.txt 11.9 KB
Newer Older
1 2 3 4 5
#
# VLMC build system
# Authors: Rohit Yadav <rohityadav89@gmail.com>
#          Ludovic Fauvet <etix@vlmc.org>
#
Ludovic Fauvet's avatar
Ludovic Fauvet committed
6

7
# Project Info
8 9 10
SET(PROJECT_NAME_SHORT   "VLMC")
SET(PROJECT_NAME_LONG    "VideoLAN Movie Creator")
SET(PROJECT_DESCRIPTION  "VLMC (VideoLAN Movie Creator) is a cross-platform, non-linear video editing software based on the VLC Media Player.")
11
SET(PROJECT_COPYRIGHT    "Copyright (C) 2008-2014 VideoLAN")
12 13 14 15
SET(PROJECT_CONTACT      "vlmc-devel@videolan.org")
SET(PROJECT_VENDOR       "VLMC Team")
SET(ORG_WEBSITE          "videolan.org")

16 17
option(FORCE_QT4 "Forces VLMC to build using Qt4" OFF)

18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
# Configuring build type
IF(NOT CMAKE_BUILD_TYPE)
    SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING
        "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
        FORCE)
    MESSAGE("Setting build type to '${CMAKE_BUILD_TYPE}'")
ELSE(NOT CMAKE_BUILD_TYPE)
    MESSAGE("Build type set to '${CMAKE_BUILD_TYPE}'")
ENDIF(NOT CMAKE_BUILD_TYPE)

IF(WIN32)
    # Building in release for WIN32
    SET(CMAKE_BUILD_TYPE "Release")
    SET_PROPERTY(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE QT_NO_DEBUG)
    # Use mingw's sprintf instead of windows's
    ADD_DEFINITIONS( -D__USE_MINGW_ANSI_STDIO=1 )
ENDIF(WIN32)

36
# Find Git Version Patch
37 38 39 40
FIND_PROGRAM(GIT git)
IF(GIT)
    EXECUTE_PROCESS(
        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
41
        COMMAND ${GIT} rev-parse --short HEAD
42 43 44 45
        OUTPUT_VARIABLE GIT_OUT OUTPUT_STRIP_TRAILING_WHITESPACE
    )
    SET(GIT_PATCH "git${GIT_OUT}")
ENDIF(GIT)
46 47

# version: 0.2.x
Ludovic Fauvet's avatar
Ludovic Fauvet committed
48
SET(CPACK_PACKAGE_VERSION_MAJOR "0")
49
SET(CPACK_PACKAGE_VERSION_MINOR "2")
50
SET(CPACK_PACKAGE_VERSION_PATCH "0")
51
SET(CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
52
SET(PROJECT_VERSION_MAJOR ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR})
53 54
SET(PROJECT_VERSION ${CPACK_PACKAGE_VERSION})

55 56
MESSAGE(STATUS "VLMC Version: ${PROJECT_VERSION}")

57 58
STRING(TOLOWER ${PROJECT_NAME_SHORT} PROJECT_NAME_SHORT_LOWER)
PROJECT(${PROJECT_NAME_SHORT_LOWER}-${PROJECT_VERSION})
59 60

# Codename of the Project :-)
61 62 63
SET(CODENAME "alpha")

# System Information
Ludovic Fauvet's avatar
Ludovic Fauvet committed
64
SITE_NAME(HOSTNAME)
65
SET(SYSNAME ${CMAKE_SYSTEM}-${CMAKE_SYSTEM_PROCESSOR})
Ludovic Fauvet's avatar
Ludovic Fauvet committed
66

67
# CMake Settings
68
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
Ludovic Fauvet's avatar
Ludovic Fauvet committed
69 70
SET(CMAKE_COLOR_MAKEFILE ON)
SET(CMAKE_VERBOSE_MAKEFILE OFF)
71

72 73 74 75 76
# Find includes in corresponding build directories
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
SET(CMAKE_AUTOMOC ON)

77
# Set path to additional CMake modules
Ludovic Fauvet's avatar
Ludovic Fauvet committed
78 79
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})

80 81 82
# Path to contribs
SET(CONTRIBS_PATH ${CMAKE_CURRENT_SOURCE_DIR}/contribs)

83
# Optionally allow embedding libvlc into the binary as
Ludovic Fauvet's avatar
Ludovic Fauvet committed
84
# VLMC requires libVLC
85
# SET (WITH_LIBVLC FALSE CACHE BOOL "Compile LibVLC in VLMC")
Ludovic Fauvet's avatar
Ludovic Fauvet committed
86

87 88
IF (UNIX)
    SET(WITH_PROFILING FALSE CACHE BOOL "Build with profiling support" )
89
    SET(CMAKE_INSTALL_PREFIX /usr)
90
    SET(CPACK_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
91 92
ENDIF(UNIX)

93
SET(WITH_GUI TRUE CACHE BOOL "Enable the VLMC's GUI")
94 95 96 97 98 99 100 101 102
SET(WITH_CRASHBUTTON FALSE CACHE BOOL "Enable the crash button")

IF(NOT APPLE)
    SET(WITH_CRASHHANDLER_GUI TRUE CACHE BOOL "Enable the crash handler GUI (with backtrace and restart capabilities)")
    SET(WITH_CRASHHANDLER TRUE CACHE BOOL "Enable the crash handler")
ELSE(NOT APPLE)
    #FIXME: Mac OS port does n't start if crash handler is enabled.
    SET(WITH_CRASHHANDLER_GUI FALSE CACHE BOOL "Disable crash handler gui...")
    SET(WITH_CRASHHANDLER False CACHE BOOL "Disable the crash handler")
103 104
    #SET(CMAKE_OSX_ARCHITECTURES i386)
    #SET(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}")
105
ENDIF(NOT APPLE)
106

107 108
FIND_PACKAGE(LIBVLC REQUIRED)
list(APPEND VLMC_LIBS ${LIBVLC_LIBRARY} ${LIBVLCCORE_LIBRARY})
Ludovic Fauvet's avatar
Ludovic Fauvet committed
109 110
INCLUDE_DIRECTORIES(${LIBVLC_INCLUDE_DIR})

111
FIND_PACKAGE(frei0r REQUIRED)
112

113 114 115 116 117
if(APPLE)
    find_library(FOUNDATION_FRAMEWORK Foundation)
    find_library(APPKIT_FRAMEWORK AppKit)
endif()

118 119
INCLUDE_DIRECTORIES(${FREI0R_INCLUDE_DIR})

120 121 122
# Manually set Qt5 path for OSX installed using brew
SET(CMAKE_PREFIX_PATH "/usr/local/opt/qt5")

123 124
# search for Qt4
if (NOT FORCE_QT4)
125 126 127
    find_package(Qt5Core QUIET)
    if (Qt5Core_FOUND)
        message(STATUS "Using qt5")
128 129
        # go on with other packages
        if(WITH_GUI)
130
            find_package(Qt5 COMPONENTS Widgets Gui Xml Network)
131
        else()
132
            find_packages(Qt5 COMPONENTS Xml Network)
133 134
        endif()

135 136 137
        macro(qt_use_modules)
            qt5_use_modules(${ARGN})
        endmacro()
138

139 140 141 142 143 144 145 146 147 148 149 150 151
        macro(qt_wrap_ui)
            qt5_wrap_ui(${ARGN})
        endmacro()

        macro(qt_add_resources)
            qt5_add_resources(${ARGN})
        endmacro()

        find_package(Qt5LinguistTools REQUIRED)
        macro(qt_add_translation)
            qt5_add_translation(${ARGN})
        endmacro()
    endif()
152 153
endif()
if(NOT Qt5Core_FOUND)
154 155 156
    if (NOT FORCE_QT4)
        message(STATUS "Could not find Qt5, searching for Qt4 instead...")
    endif()
157

158
    set(NEEDED_QT4_COMPONENTS "QtCore" "QtXml" "QtNetwork")
159 160 161 162
    if( WITH_GUI )
        list(APPEND NEEDED_QT4_COMPONENTS "QtGui")
    endif()

163 164
    find_package(Qt4 REQUIRED COMPONENTS ${NEEDED_QT4_COMPONENTS})
    message(STATUS "Found Qt4 & ${NEEDED_QT4_COMPONENTS} modules")
165
    macro(qt_use_modules)
166

167 168 169 170 171 172 173 174 175 176 177 178 179
    endmacro()

    macro(qt_wrap_ui)
        qt4_wrap_ui(${ARGN})
    endmacro()

    macro(qt_add_resources)
        qt4_add_resources(${ARGN})
    endmacro()

    macro(qt_add_translation)
        qt4_add_translation(${ARGN})
    endmacro()
180

181 182
    include(${QT_USE_FILE})
    add_definitions(${QT_DEFINITIONS})
183

184 185 186 187
    # On linux & using Qt4 we need to manually add -lX11
    if (UNIX AND NOT APPLE)
        list(APPEND VLMC_LIBS -lX11)
    endif()
188
endif()
Ludovic Fauvet's avatar
Ludovic Fauvet committed
189 190 191

# layout of VLMC installation
# (default values are platform-specific)
192 193
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/effects)
Ludovic Fauvet's avatar
Ludovic Fauvet committed
194

195 196
# Copy the sh launcher
IF (NOT WIN32)
197
    CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/cmake/vlmc.sh" "${CMAKE_CURRENT_BINARY_DIR}/vlmc" COPYONLY)
198 199
ENDIF(NOT WIN32)

Ludovic Fauvet's avatar
Ludovic Fauvet committed
200 201 202 203 204 205 206
# common for MAC and UNIX
SET (DEFAULT_BIN_SUBDIR     bin)
SET (DEFAULT_LIB_SUBDIR     lib)
SET (DEFAULT_DATA_SUBDIR    share)
SET (DEFAULT_SRC_SUBDIR     src)
SET (DEFAULT_INCLUDE_SUBDIR include)

207 208 209 210 211 212
SET (VLMC_BIN_SUBDIR     "${DEFAULT_BIN_SUBDIR}"        CACHE STRING "Subdirectory where executables will be installed")
SET (VLMC_LIB_SUBDIR     "${DEFAULT_LIB_SUBDIR}"        CACHE STRING "Subdirectory where libraries will be installed")
SET (VLMC_DATA_SUBDIR    "${DEFAULT_DATA_SUBDIR}"       CACHE STRING "Subdirectory where VLMC data will be installed")
SET (VLMC_SRC_SUBDIR     "${DEFAULT_SRC_SUBDIR}"        CACHE STRING "Subdirectory where VLMC source is")
SET (VLMC_INCLUDE_SUBDIR "${DEFAULT_INCLUDE_SUBDIR}"    CACHE STRING "Subdirectory where header files will be installed")

Ludovic Fauvet's avatar
Ludovic Fauvet committed
213
# full paths for the installation
214 215 216 217 218 219 220
SET (VLMC_BIN_DIR     ${CMAKE_INSTALL_PREFIX}/${VLMC_BIN_SUBDIR})
SET (VLMC_LIB_DIR     ${CMAKE_INSTALL_PREFIX}/${VLMC_LIB_SUBDIR})
SET (VLMC_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/${VLMC_INCLUDE_SUBDIR})
SET (VLMC_DATA_DIR    ${CMAKE_INSTALL_PREFIX}/${VLMC_DATA_SUBDIR}/vlmc/)
SET (VLMC_DOC_DIR     ${CMAKE_INSTALL_PREFIX}/${VLMC_DATA_SUBDIR}/doc/vlmc/)
SET (VLMC_EFFECTS_DIR ${CMAKE_INSTALL_PREFIX}/${VLMC_LIB_SUBDIR}/vlmc/effects/)
SET (VLMC_DESKTOP_DIR ${CMAKE_INSTALL_PREFIX}/${VLMC_DATA_SUBDIR}/applications/)
221
SET (VLMC_PIXMAPS_DIR ${CMAKE_INSTALL_PREFIX}/${VLMC_DATA_SUBDIR}/pixmaps/)
Ludovic Fauvet's avatar
Ludovic Fauvet committed
222 223 224

# manual page - makes sense only on unix systems
IF (UNIX)
225 226
    SET (DEFAULT_MANUAL_SUBDIR  ${VLMC_DATA_SUBDIR}/man)
    SET (VLMC_MANUAL_SUBDIR  "${DEFAULT_MANUAL_SUBDIR}"  CACHE STRING "Subdirectory where manual files will be installed")
227 228
    MARK_AS_ADVANCED (VLMC_MANUAL_SUBDIR)
    SET (VLMC_MANUAL_DIR  ${CMAKE_INSTALL_PREFIX}/${VLMC_MANUAL_SUBDIR})
Ludovic Fauvet's avatar
Ludovic Fauvet committed
229 230
ENDIF (UNIX)

231
SUBDIRS(ts)
Ludovic Fauvet's avatar
Ludovic Fauvet committed
232
SUBDIRS(src)
233
SUBDIRS(nsis)
234
SUBDIRS(effects)
Ludovic Fauvet's avatar
Ludovic Fauvet committed
235

236
# Copy stuff to doc subdirectory
237
INSTALL (FILES AUTHORS COPYING INSTALL NEWS README THANKS TRANSLATORS
238
         DESTINATION ${VLMC_DOC_DIR})
Ludovic Fauvet's avatar
Ludovic Fauvet committed
239

240 241 242
# Copy .desktop file
INSTALL (FILES share/vlmc.desktop DESTINATION ${VLMC_DESKTOP_DIR})

243 244 245
# Copy the VLMC pixmap
INSTALL (FILES share/vlmc.png DESTINATION ${VLMC_PIXMAPS_DIR})

246 247 248 249 250 251
# On UNIX copy the man page
IF (UNIX)
    INSTALL (FILES ${CMAKE_SOURCE_DIR}/doc/vlmc.1
             DESTINATION ${VLMC_MANUAL_DIR}/man1)
ENDIF (UNIX)

252 253 254 255 256 257
# Copy the share directory (TODO: add checks if the dir is empty, don't install)
# INSTALL (DIRECTORY share/ DESTINATION ${VLMC_DATA_DIR}
#         PATTERN "*.desktop" EXCLUDE
#         PATTERN "*.ico" EXCLUDE
#         PATTERN "*.icns" EXCLUDE
#         PATTERN "vlmc.png" EXCLUDE)
258

Ludovic Fauvet's avatar
Ludovic Fauvet committed
259
#############################################################
260
# Package Settings
Ludovic Fauvet's avatar
Ludovic Fauvet committed
261 262 263

INCLUDE(InstallRequiredSystemLibraries)

264 265
SET(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
SET(CPACK_PACKAGE_NAME ${PROJECT_NAME_SHORT})
266 267 268 269
SET(CPACK_PACKAGE_DESCRIPTION ${PROJECT_NAME_LONG})
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_NAME_SHORT} \n ${PROJECT_DESCRIPTION}")
SET(CPACK_PACKAGE_VENDOR ${PROJECT_VENDOR})
SET(CPACK_PACKAGE_CONTACT ${PROJECT_CONTACT})
270 271 272
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README")
SET(CPACK_RESOURCE_FILE_README ${CMAKE_SOURCE_DIR}/README)
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
273 274
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")

275
# Force Package Name
276
SET(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME}${GIT_PATCH}-${CPACK_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})
277 278

# NSIS Windows Installer
Ludovic Fauvet's avatar
Ludovic Fauvet committed
279
IF(WIN32 AND NOT UNIX)
280 281 282 283 284 285 286
    # There is a bug in NSI that does not handle full unix paths properly. Make
    # sure there is at least one set of four (4) backslashes.
    SET(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/share\\\\vlmc.png")
    SET(CPACK_NSIS_INSTALLED_ICON_NAME "\\\\vlmc.exe")
    SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} VLMC")
    SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\vlmc.org")
    SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\vlmc.org")
287
    SET(CPACK_NSIS_CONTACT ${PROJECT_CONTACT})
288
    SET(CPACK_NSIS_MODIFY_PATH ON)
Ludovic Fauvet's avatar
Ludovic Fauvet committed
289
ELSE(WIN32 AND NOT UNIX)
290 291
    #SET(CPACK_STRIP_FILES "VLMC")
    #SET(CPACK_SOURCE_STRIP_FILES "")
Ludovic Fauvet's avatar
Ludovic Fauvet committed
292 293
ENDIF(WIN32 AND NOT UNIX)

294 295
# RPM packages
INCLUDE ( ${CMAKE_MODULE_PATH}/RpmBuild.cmake )
296
IF ( RPMBUILD_FOUND AND NOT WIN32 )
297
    SET(CPACK_GENERATOR "RPM")
298 299 300 301 302 303 304 305 306
    SET(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
    SET(CPACK_RPM_PACKAGE_NAME ${CPACK_PACKAGE_NAME})
    SET(CPACK_RPM_PACKAGE_VERSION ${PROJECT_VERSION})
    SET(CPACK_RPM_PACKAGE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
    SET(CPACK_RPM_PACKAGE_GROUP ${PROJECT_VENDOR})
    SET(CPACK_RPM_PACKAGE_VENDOR ${PROJECT_VENDOR})
    SET(CPACK_RPM_PACKAGE_DESCRIPTION ${PROJECT_DESCRIPTION})
    SET(CPACK_RPM_PACKAGE_ARCHITECTURE i386) # Change to your architecture here
    SET(CPACK_RPM_PACKAGE_DEPENDS "qt ( >= 4.6 ), qt-x11 ( >= 4.6 )") # Specify dependencies here
307
    SET(CPACK_SET_DESTDIR TRUE)
308
ENDIF ( RPMBUILD_FOUND AND NOT WIN32 )
309

310 311
# Debian packages
INCLUDE ( ${CMAKE_MODULE_PATH}/DpkgBuild.cmake )
312
IF ( DPKG_FOUND AND NOT WIN32 )
313
    SET(CPACK_GENERATOR "DEB")
314 315 316 317 318 319
    SET(CPACK_DEBIAN_PACKAGE_NAME ${CPACK_PACKAGE_NAME})
    SET(CPACK_DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
    SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
    SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_PACKAGE_VENDOR} <${CPACK_PACKAGE_CONTACT}>")
    SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
    SET(CPACK_DEBIAN_PACKAGE_DEBUG ON)
320
    SET(CPACK_DEBIAN_PACKAGE_DEPENDS ${PACKAGE_REQUIRES})
321
    SET(CPACK_SET_DESTDIR TRUE)
322
ENDIF ( DPKG_FOUND AND NOT WIN32 )
323

324
# Mac Bundle
325 326 327 328 329
IF( APPLE )
    SET(CPACK_GENERATOR "DragNDrop")
    #Libraries are bundled directly
    SET(CPACK_COMPONENT_LIBRARIES_HIDDEN TRUE)
    # Bundle Properties
330
    SET(MACOSX_BUNDLE_BUNDLE_NAME VLMC)
331 332 333 334 335 336 337 338
    SET(MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION})
    SET(MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION})
    SET(MACOSX_BUNDLE_LONG_VERSION_STRING "Version ${PROJECT_VERSION}")
    #SET(CPACK_STRIP_FILES TRUE)
ENDIF( APPLE )

SET(CPACK_PACKAGE_EXECUTABLES "vlmc" "VLMC")
INCLUDE(CPack)