Skip to content
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

Added cmake improvements. #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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: 9 additions & 6 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ jobs:
gcc --version
cmake --version

- name: Build and install libxutils
run: cd libxutils && ./build.sh --tool=cmake --install
#- name: Build and install libxutils
# run: cd libxutils && ./build.sh --tool=cmake --install

- name: Make build
run: |
mkdir build
cd build
cmake ..
make
cd libxutils && cmake -Bbuild -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/libxmedia -DDEPENDENCIES_PREFIX_INSTALL=${{github.workspace}}/libxmedia && cmake --build build --target install

- name: Uploading libxmedia
uses: actions/upload-artifact@v4
with:
name: ubuntu_latest_libxmedia
path: ${{github.workspace}}/libxmedia
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,9 @@ modules.order
Module.symvers
Mkfile.old
dkms.conf

# IDE temporary files
.idea
cmake-build-debug
cmake-build-release
libxmedia
60 changes: 34 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,37 +1,45 @@
cmake_minimum_required(VERSION 3.10)

project(xmedia)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O2 -Wall -D_XUTILS_DEBUG")

include_directories(${PROJECT_SOURCE_DIR}/src)
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)

include(dependencies/dependencies.cmake)

file(GLOB SOURCES src/*.c)
add_library(${PROJECT_NAME}
${SOURCES})

set(SOURCES
${PROJECT_SOURCE_DIR}/src/codec.c
${PROJECT_SOURCE_DIR}/src/decoder.c
${PROJECT_SOURCE_DIR}/src/encoder.c
${PROJECT_SOURCE_DIR}/src/frame.c
${PROJECT_SOURCE_DIR}/src/meta.c
${PROJECT_SOURCE_DIR}/src/mpegts.c
${PROJECT_SOURCE_DIR}/src/nalu.c
${PROJECT_SOURCE_DIR}/src/status.c
${PROJECT_SOURCE_DIR}/src/stream.c
${PROJECT_SOURCE_DIR}/src/version.c
)
add_dependencies(${PROJECT_NAME} dependencies)

add_library(${PROJECT_NAME} STATIC ${SOURCES})
SET(DST_DIR "/usr/local/include/xmedia")
target_include_directories(${PROJECT_NAME}
PRIVATE
${DEPENDENCIES_PREFIX_INSTALL}/include
${DEPENDENCIES_PREFIX_INSTALL}/include/xutils # TODO: temporary inconvinient should be reduced usage "" in the xutils headers
src)

find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBAV REQUIRED IMPORTED_TARGET
libavutil
libavcodec
libavformat
libavdevice
#libavfilter
libswscale
libswresample)

target_link_libraries(${PROJECT_NAME}
PUBLIC
-L${DEPENDENCIES_PREFIX_INSTALL}/lib # TODO: expected all dependencies located here
xutils
pthread
avutil
avcodec
avformat
avdevice
swscale
swresample
)

install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION /usr/local/lib)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/ DESTINATION ${DST_DIR} FILES_MATCHING PATTERN "*.h")
PkgConfig::LIBAV)

include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}
ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR})

install(DIRECTORY src/ DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/xmedia FILES_MATCHING PATTERN "*.h")
14 changes: 14 additions & 0 deletions dependencies/dependencies.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
if("${DEPENDENCIES_PREFIX_INSTALL}" STREQUAL "")
set(DEPENDENCIES_PREFIX_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/dependencies)
endif()

set(dependencies_LIST)

include(ExternalProject)
ExternalProject_Add(libxutils_external
GIT_REPOSITORY https://github.com/kala13x/libxutils
GIT_TAG feature/fixes-for-cmake-added-macos-support
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${DEPENDENCIES_PREFIX_INSTALL} -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS})
list(APPEND dependencies_LIST libxutils_external)

add_custom_target(dependencies DEPENDS ${dependencies_LIST})
14 changes: 7 additions & 7 deletions src/stdinc.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
#ifndef __XMEDIA_STDINC_H__
#define __XMEDIA_STDINC_H__

#include <xutils/array.h>
#include <xutils/xtime.h>
#include <xutils/xjson.h>
#include <xutils/data/array.h>
#include <xutils/sys/xtime.h>
#include <xutils/data/xjson.h>
#include <xutils/xstd.h>
#include <xutils/xsig.h>
#include <xutils/xlog.h>
#include <xutils/xstr.h>
#include <xutils/xfs.h>
#include <xutils/sys/xsig.h>
#include <xutils/sys/xlog.h>
#include <xutils/data/xstr.h>
#include <xutils/sys/xfs.h>

#include <libavformat/avformat.h>
#include <libavdevice/avdevice.h>
Expand Down
Loading