101 lines
2.6 KiB
CMake
101 lines
2.6 KiB
CMake
cmake_minimum_required(VERSION 3.16)
|
|
project(Eclipt VERSION 1.0.0 LANGUAGES CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
option(ECLIPT_BUILD_SHARED "Build shared library" ON)
|
|
option(ECLIPT_BUILD_EXAMPLES "Build examples" OFF)
|
|
option(ECLIPT_USE_SDL2 "Use SDL2 for Linux display" ON)
|
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
pkg_check_modules(FFMPEG REQUIRED
|
|
libavformat
|
|
libavcodec
|
|
libavutil
|
|
libswscale
|
|
libswresample
|
|
)
|
|
|
|
if(ECLIPT_USE_SDL2)
|
|
pkg_check_modules(SDL2 REQUIRED sdl2)
|
|
endif()
|
|
|
|
include_directories(
|
|
${CMAKE_SOURCE_DIR}/libEcliptPlayer/include
|
|
${CMAKE_SOURCE_DIR}/platform/linux/include
|
|
${FFMPEG_INCLUDE_DIRS}
|
|
)
|
|
|
|
if(ECLIPT_USE_SDL2)
|
|
include_directories(${SDL2_INCLUDE_DIRS})
|
|
endif()
|
|
|
|
set(ECLIPT_SOURCES
|
|
libEcliptPlayer/src/core/EcliptPlayer.cpp
|
|
libEcliptPlayer/src/demuxer/FFmpegDemuxer.cpp
|
|
libEcliptPlayer/src/decoder/FFmpegDecoder.cpp
|
|
libEcliptPlayer/src/subtitle/SubtitleRenderer.cpp
|
|
libEcliptPlayer/src/playlist/Playlist.cpp
|
|
libEcliptPlayer/src/playlist/EPG.cpp
|
|
)
|
|
|
|
set(ECLIPT_HEADERS
|
|
libEcliptPlayer/include/eclipt/Config.h
|
|
libEcliptPlayer/include/eclipt/Decoder.h
|
|
libEcliptPlayer/include/eclipt/Demuxer.h
|
|
libEcliptPlayer/include/eclipt/EcliptPlayer.h
|
|
libEcliptPlayer/include/eclipt/EPG.h
|
|
libEcliptPlayer/include/eclipt/Frame.h
|
|
libEcliptPlayer/include/eclipt/Playlist.h
|
|
libEcliptPlayer/include/eclipt/Subtitle.h
|
|
)
|
|
|
|
add_library(EcliptPlayer ${ECLIPT_SOURCES} ${ECLIPT_HEADERS})
|
|
target_link_libraries(EcliptPlayer PRIVATE ${FFMPEG_LIBRARIES})
|
|
target_compile_options(EcliptPlayer PRIVATE ${FFMPEG_CFLAGS})
|
|
|
|
if(WIN32)
|
|
target_compile_definitions(EcliptPlayer PRIVATE _CRT_SECURE_NO_WARNINGS)
|
|
endif()
|
|
|
|
set_target_properties(EcliptPlayer PROPERTIES
|
|
VERSION ${PROJECT_VERSION}
|
|
SOVERSION ${PROJECT_VERSION_MAJOR}
|
|
PUBLIC_HEADER "${ECLIPT_HEADERS}"
|
|
)
|
|
|
|
if(UNIX AND NOT APPLE)
|
|
install(TARGETS EcliptPlayer
|
|
LIBRARY DESTINATION lib
|
|
PUBLIC_HEADER DESTINATION include/eclipt
|
|
)
|
|
endif()
|
|
|
|
if(ECLIPT_USE_SDL2)
|
|
set(LINUX_SOURCES
|
|
platform/linux/src/EcliptLinux.cpp
|
|
platform/linux/src/main.cpp
|
|
)
|
|
|
|
add_executable(eclipt-linux ${LINUX_SOURCES})
|
|
target_link_libraries(eclipt-linux PRIVATE
|
|
EcliptPlayer
|
|
${SDL2_LIBRARIES}
|
|
pthread
|
|
)
|
|
endif()
|
|
|
|
if(ECLIPT_BUILD_EXAMPLES)
|
|
add_subdirectory(examples)
|
|
endif()
|
|
|
|
message(STATUS "Eclipt version: ${PROJECT_VERSION}")
|
|
message(STATUS "FFmpeg version: ${FFMPEG_VERSION}")
|
|
message(STATUS "Build shared: ${ECLIPT_BUILD_SHARED}")
|
|
message(STATUS "Use SDL2: ${ECLIPT_USE_SDL2}")
|