build script optimization (#642)

* implement make install
set CMAKE_INSTALL_PREFIX e.g. to /opt to install to /opt/hyperion
set ENABLE_SYSTEM_INSTALL to ON to activate installation
after compiling use
make install
or
make install/strip
(for performance/size optimized binaries - compile in Release to get best performance)

* cleanup cmake files
use
cmake -DINSTALL_PREFIX=/opt/hyperion ..
to install all files to hyperion or
cmake -DINSTALL_PREFIX=/usr/
to install to usr. install folders are linux standard. bin go to bin folder and additionals (effects) go to share/hyperion

* add uninstall target - be patient with that, this will remove files from your system
install service files to share/hyperion - if you want to use them you have to make a symlink to your location of service files

* optimize build release script
install service files into hyperion share folder (services not activated, this must be done by distribution package script)
initial support of cmake option -DPLATFORM= option. This selects platform specific cmake flags. no need for -DENABLE_... options (unless you want some special things)
automatic detect for apple build

* update submodule


Former-commit-id: 5f06f314841810c780c871f810158010d3d2de70
This commit is contained in:
redPanther
2016-05-22 00:27:06 +02:00
committed by brindosch
parent 19a6bf1ee7
commit b293ea20db
13 changed files with 186 additions and 114 deletions

View File

@@ -1,22 +1,47 @@
# Define the main-project name
project(Hyperion)
project(hyperiond)
# define the minimum cmake version (as required by cmake)
cmake_minimum_required(VERSION 2.8)
#set(CMAKE_TOOLCHAIN_FILE /opt/raspberrypi/Toolchain-RaspberryPi.cmake)
SET ( DEFAULT_AMLOGIC OFF )
SET ( DEFAULT_DISPMANX OFF )
SET ( DEFAULT_FB OFF )
SET ( DEFAULT_OSX OFF )
SET ( DEFAULT_X11 OFF )
SET ( DEFAULT_WS2812BPWM OFF )
SET ( DEFAULT_WS281XPWM OFF )
if (APPLE)
SET ( DEFAULT_OSX ON )
else ()
if ( ${PLATFORM} STREQUAL "rpi" )
SET ( DEFAULT_DISPMANX ON )
SET ( DEFAULT_WS2812BPWM ON )
SET ( DEFAULT_WS281XPWM ON )
elseif ( ${PLATFORM} STREQUAL "wetek" )
SET ( DEFAULT_AMLOGIC ON )
SET ( DEFAULT_FB ON )
elseif ( ${PLATFORM} STREQUAL "x86" )
SET ( DEFAULT_X11 ON )
elseif ( ${PLATFORM} STREQUAL "imx6" )
SET ( DEFAULT_FB ON )
endif()
endif ()
# set the build options
option(ENABLE_AMLOGIC "Enable the AMLOGIC video grabber" OFF)
option(ENABLE_AMLOGIC "Enable the AMLOGIC video grabber" ${DEFAULT_AMLOGIC} )
message(STATUS "ENABLE_AMLOGIC = " ${ENABLE_AMLOGIC})
option(ENABLE_DISPMANX "Enable the RPi dispmanx grabber" ON)
option(ENABLE_DISPMANX "Enable the RPi dispmanx grabber" ${DEFAULT_DISPMANX} )
message(STATUS "ENABLE_DISPMANX = " ${ENABLE_DISPMANX})
option(ENABLE_FB "Enable the framebuffer grabber" OFF)
option(ENABLE_FB "Enable the framebuffer grabber" ${DEFAULT_FB} )
message(STATUS "ENABLE_FB = " ${ENABLE_FB})
option(ENABLE_OSX "Enable the osx grabber" OFF)
option(ENABLE_OSX "Enable the osx grabber" ${DEFAULT_OSX} )
message(STATUS "ENABLE_OSX = " ${ENABLE_OSX})
option(ENABLE_PROTOBUF "Enable PROTOBUF server" ON)
@@ -31,13 +56,13 @@ message(STATUS "ENABLE_TINKERFORGE = " ${ENABLE_TINKERFORGE})
option(ENABLE_V4L2 "Enable the V4L2 grabber" ON)
message(STATUS "ENABLE_V4L2 = " ${ENABLE_V4L2})
option(ENABLE_WS2812BPWM "Enable the WS2812b-PWM device" OFF)
option(ENABLE_WS2812BPWM "Enable the WS2812b-PWM device" ${DEFAULT_WS2812BPWM} )
message(STATUS "ENABLE_WS2812BPWM = " ${ENABLE_WS2812BPWM})
option(ENABLE_WS281XPWM "Enable the WS281x-PWM device" OFF)
option(ENABLE_WS281XPWM "Enable the WS281x-PWM device" ${DEFAULT_WS281XPWM} )
message(STATUS "ENABLE_WS281XPWM = " ${ENABLE_WS281XPWM})
option(ENABLE_X11 "Enable the X11 grabber" OFF)
option(ENABLE_X11 "Enable the X11 grabber" ${DEFAULT_X11})
message(STATUS "ENABLE_X11 = " ${ENABLE_X11})
option(ENABLE_QT5 "Enable QT5" OFF)
@@ -48,20 +73,26 @@ message(STATUS "ENABLE_TESTS = " ${ENABLE_TESTS})
if(ENABLE_V4L2 AND NOT ENABLE_PROTOBUF)
message(FATAL_ERROR "V4L2 grabber requires PROTOBUF. Disable V4L2 or enable PROTOBUF")
endif(ENABLE_V4L2 AND NOT ENABLE_PROTOBUF)
endif()
if(ENABLE_FB AND ENABLE_DISPMANX)
message(FATAL_ERROR "dispmanx grabber and framebuffer grabber cannot be used at the same time")
endif(ENABLE_FB AND ENABLE_DISPMANX)
endif()
if(ENABLE_FB AND ENABLE_OSX)
message(FATAL_ERROR "osx grabber and framebuffer grabber cannot be used at the same time")
endif(ENABLE_FB AND ENABLE_OSX)
endif()
if(ENABLE_OSX AND ENABLE_DISPMANX)
message(FATAL_ERROR "dispmanx grabber and osx grabber cannot be used at the same time")
endif(ENABLE_OSX AND ENABLE_DISPMANX)
endif()
if (DEFINED INSTALL_PREFIX)
SET( ENABLE_SYSTEM_INSTALL ON)
SET( CMAKE_INSTALL_PREFIX "${INSTALL_PREFIX}" )
else()
SET(ENABLE_SYSTEM_INSTALL OFF)
endif()
SET ( PROTOBUF_INSTALL_BIN_DIR ${CMAKE_BINARY_DIR}/proto )
SET ( PROTOBUF_INSTALL_LIB_DIR ${CMAKE_BINARY_DIR}/proto )
@@ -85,15 +116,15 @@ include_directories("${PROJECT_BINARY_DIR}")
if(ENABLE_QT5)
ADD_DEFINITIONS ( -DENABLE_QT5 )
#find_package(Qt5Widgets)
else(ENABLE_QT5)
else()
# Add specific cmake modules to find qt4 (default version finds first available QT which might not be qt4)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/qt4)
endif(ENABLE_QT5)
endif()
# Define the global output path of binaries
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
SET(DEPLOY_DIR "${CMAKE_SOURCE_DIR}/deploy/hyperion" )
file(MAKE_DIRECTORY ${LIBRARY_OUTPUT_PATH})
file(MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
@@ -113,10 +144,10 @@ if(ENABLE_QT5)
find_package(Qt5 COMPONENTS Core Gui Widgets Network REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
# set(CMAKE_CXX_FLAGS "-fPIC")
else(ENABLE_QT5)
else()
# Configure the use of QT4
find_package(Qt4 COMPONENTS QtCore QtNetwork QtGui REQUIRED QUIET)
endif(ENABLE_QT5)
endif()
#add libusb and pthreads
find_package(libusb-1.0 REQUIRED)
@@ -124,10 +155,10 @@ find_package(Threads REQUIRED)
if(ENABLE_QT5)
#include(${QT_USE_FILE})
add_definitions(${QT_DEFINITIONS})
else(ENABLE_QT5)
else()
include(${QT_USE_FILE})
add_definitions(${QT_DEFINITIONS})
endif(ENABLE_QT5)
endif()
# TODO[TvdZ]: This linking directory should only be added if we are cross compiling
if(NOT APPLE)
@@ -148,8 +179,13 @@ add_subdirectory(libsrc)
add_subdirectory(src)
if (ENABLE_TESTS)
add_subdirectory(test)
endif (ENABLE_TESTS)
endif ()
# Add the doxygen generation directory
add_subdirectory(doc)
# uninstall target
configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)