CMakeLists.txt 3.8 KB
Newer Older
Nicolas Bouillot's avatar
Nicolas Bouillot committed
1 2 3 4 5 6 7 8 9 10
# CMake Config
cmake_minimum_required(VERSION 3.5.1)

#
# CONFIGURATION
#

# Project Variables
set(NDI2SHMDATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(NDI2SHMDATA_VERSION_MAJOR 0)
Nicolas Bouillot's avatar
Nicolas Bouillot committed
11
set(NDI2SHMDATA_VERSION_MINOR 2)
12
set(NDI2SHMDATA_VERSION_PATCH 0)
Nicolas Bouillot's avatar
Nicolas Bouillot committed
13 14 15 16 17 18 19 20 21 22
set(NDI2SHMDATA_VERSION_STRING ${NDI2SHMDATA_VERSION_MAJOR}.${NDI2SHMDATA_VERSION_MINOR}.${NDI2SHMDATA_VERSION_PATCH})
set(SHMDATA_REQUIRED_VERSION 1.3)

# Package (pkg-config) Information
set(PACKAGE_NAME ndi2shmdata)
set(PACKAGE_DESCRIPTION "Ndi2shmdata provides tools for sharing video between shmdata and NewTek's NDI")
set(PACKAGE_URL "https://gitlab.com/sat-metalab/ndi2shmdata")
set(PACKAGE_VERSION ${NDI2SHMDATA_VERSION_STRING})

# Compilation
Nicolas Bouillot's avatar
Nicolas Bouillot committed
23
set(CMAKE_CXX_STANDARD 17)
Nicolas Bouillot's avatar
Nicolas Bouillot committed
24 25 26 27 28 29 30
set(DATADIR ${CMAKE_INSTALL_PREFIX}/share/ndi2shmdata/)

# CPack - General
set(CPACK_PACKAGE_NAME ${PACKAGE_NAME})
set(CPACK_PACKAGE_VENDOR "Metalab - Société des arts technologiques")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PACKAGE_DESCRIPTION}")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
31
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
Nicolas Bouillot's avatar
Nicolas Bouillot committed
32 33 34 35 36 37 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
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_VERSION_MAJOR "${NDI2SHMDATA_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${NDI2SHMDATA_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${NDI2SHMDATA_VERSION_PATCH}")
set(CPACK_GENERATOR TGZ)
set(CPACK_SOURCE_GENERATOR TGZ)
set(CPACK_COMPONENTS_ALL applications)

# CPack - Applications
set(CPACK_COMPONENT_APPLICATIONS_DISPLAY_NAME "ndi2shmdata & shmdata2ndi")
set(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION "Application for converting ndi to shmdata")
set(CPACK_COMPONENT_APPLICATIONS_DEPENDS libraries)

# CPack - Source
set(CPACK_SOURCE_IGNORE_FILES "/\.hooks/;/\.idea/;/build/;/html/;/scripts/;${CPACK_SOURCE_IGNORE_FILES}")

# Add local cmake directory to ckame module path in case we need it
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")

#
# INCLUDES
#

include(FeatureSummary)
include(CPack)
include(PackageSourceTest)
include(CMakeDependentOption)

#
# PROJECT
#

project(Ndi2shmdata)
enable_testing()
66 67 68 69 70 71
option(ACCEPT_NDI_LICENSE "Accept NDI License Agreement" OFF)

if (NOT ACCEPT_NDI_LICENSE)
  message(FATAL_ERROR "ndi2shmdata compilation requires acceptation of the NDI License. The license is available in the ndi-sdk folder. License can be accepted using the following cmake option: -DACCEPT_NDI_LICENSE=ON\nExample 'cmake -DACCEPT_NDI_LICENSE=ON ..' ")
endif()

Nicolas Bouillot's avatar
Nicolas Bouillot committed
72 73 74 75 76 77 78 79 80 81 82 83

# Prerequisites
find_package(PkgConfig REQUIRED)

# This is required in the case where macport screwed with the paths on mac os x
set(ENV{PKG_CONFIG_PATH} "/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH")

pkg_check_modules(SHMDATA REQUIRED shmdata-${SHMDATA_REQUIRED_VERSION})

# Global stuff


84 85 86 87
link_directories(
  ${SHMDATA_LIBRARY_DIRS}
  ${NDI2SHMDATA_DIR}/ndi-sdk/lib/x86_64-linux-gnu
)
Nicolas Bouillot's avatar
Nicolas Bouillot committed
88

89 90 91 92 93 94
link_libraries(
  ${SHMDATA_LIBRARIES}
  dl
  ndi
  pthread
)
Nicolas Bouillot's avatar
Nicolas Bouillot committed
95 96

include_directories(
97 98
  ${SHMDATA_INCLUDE_DIRS}
  ${NDI2SHMDATA_DIR}/ndi-sdk/include
Nicolas Bouillot's avatar
Nicolas Bouillot committed
99 100 101 102 103 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
)

add_compile_options(${SHMDATA_CFLAGS})

# BUILD TYPE
if(CMAKE_BUILD_TYPE EQUAL "Debug")
    add_definitions(-DDEBUG)
endif()

# WARNINGS
add_definitions(-Wall)
add_definitions(-Wextra)
add_definitions(-Werror)
add_definitions(-Wno-error=unused-parameter)

# OSX (not tested !)
if(APPLE AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
    set(OSX TRUE)
    add_definitions(-DOSX)
    add_compile_options(-ObjC++) # Allows objective-c building
endif ()

#
# MODULES
#

add_subdirectory(src)

#
# OTHER TARGETS
#

# Uninstall
configure_file(
    "${CMAKE_CURRENT_SOURCE_DIR}/CMakeUninstall.cmake.in"
    "${CMAKE_CURRENT_BINARY_DIR}/CMakeUninstall.cmake"
    IMMEDIATE @ONLY)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/CMakeUninstall.cmake)

#
# POST
#

# Report
feature_summary(WHAT ALL)