Skip to content

Added non-default option to build as a shared library #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.10)
project(mpegts)
set(CMAKE_CXX_STANDARD 17)

option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)

#Macro for printing all CMake variables
macro(print_all_variables)
message(STATUS "print_all_variables------------------------------------------{")
Expand All @@ -21,7 +23,11 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/mpegts/)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/unit_tests/)

file(GLOB libfiles ${CMAKE_CURRENT_SOURCE_DIR}/mpegts/*.cpp)
add_library(mpegts STATIC ${libfiles})

add_library(mpegts ${libfiles})


set_target_properties(mpegts PROPERTIES PUBLIC_HEADER "mpegts/mpegts_demuxer.h;mpegts/mpegts_muxer.h;mpegts/simple_buffer.h;mpegts/ts_packet.h")

add_executable(mpeg_ts_dmx_tests ${CMAKE_CURRENT_SOURCE_DIR}/main_dmx.cpp)
target_link_libraries(mpeg_ts_dmx_tests mpegts Threads::Threads)
Expand All @@ -31,4 +37,9 @@ target_link_libraries(mpeg_ts_mx_tests mpegts Threads::Threads)

file(GLOB unit_tests_sources ${CMAKE_CURRENT_SOURCE_DIR}/unit_tests/*.cpp)
add_executable(mpeg_ts_unit_tests ${unit_tests_sources} ${CMAKE_CURRENT_SOURCE_DIR}/unit_tests.cpp)
target_link_libraries(mpeg_ts_unit_tests mpegts Threads::Threads)
target_link_libraries(mpeg_ts_unit_tests mpegts Threads::Threads)

install(TARGETS mpegts
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include/mpegts
)