Skip to content

Commit 61d878d

Browse files
Merge pull request #809 from henryborchers/cmake-build-lib
mediaconch library can be built with CMake
2 parents c7ec830 + c05eadd commit 61d878d

File tree

4 files changed

+153
-0
lines changed

4 files changed

+153
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Build_libs
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
strategy:
8+
matrix:
9+
library_type: [static, shared]
10+
os: [ubuntu-latest, macos-latest, windows-latest]
11+
include:
12+
- os: ubuntu-latest
13+
cmake_preset_name: conan-release
14+
- os: macos-latest
15+
cmake_preset_name: conan-release
16+
- os: windows-latest
17+
cmake_preset_name: conan-default
18+
fail-fast: false
19+
runs-on: ${{ matrix.os }}
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
- uses: actions/setup-python@v4
24+
with:
25+
cache: 'pip' # caching pip dependencies
26+
- name: "install dependencies" # use conan package manager to install c and c++ dependencies
27+
run: |
28+
pip install --disable-pip-version-check uv
29+
uvx conan profile detect
30+
uvx conan install -of build --requires="zlib/1.3.1" --requires="libxslt/1.1.43" --requires="libxml2/2.13.8" --requires="libzen/0.4.38" --requires="libmediainfo/22.03" --build=missing -g CMakeDeps -g CMakeToolchain
31+
- name: Configure cmake
32+
run: |
33+
cmake --preset ${{ matrix.cmake_preset_name }} -D BUILD_SHARED_LIBS=${{ matrix.library_type == 'static' && 'NO' || 'YES'}}
34+
- name: Build
35+
run: |
36+
cmake --build --preset conan-release
37+
- name: Install
38+
run: |
39+
cmake --install build --prefix sample_prefix

CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
project(mediaconch)
3+
set(CMAKE_CXX_STANDARD 11)
4+
cmake_policy(SET CMP0135 NEW)
5+
6+
option(MEDIACONCH_WITH_SQLITE "Enable SQLite DB" OFF)
7+
option(MEDIACONCH_WITH_JANSSON "Enable Jansson Library" OFF)
8+
option(MEDIACONCH_WITH_LIBEVENT "Enable Libevent" OFF)
9+
10+
find_package(ZLIB REQUIRED)
11+
find_package(ZenLib REQUIRED)
12+
find_package(libxml2 REQUIRED)
13+
find_package(LibXslt REQUIRED)
14+
find_package(MediaInfoLib REQUIRED)
15+
16+
find_package(jansson QUIET)
17+
find_package(Libevent QUIET)
18+
19+
add_subdirectory(Source)

Source/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Other configurations can be added here such as CLI, or GUI
2+
add_subdirectory(Lib)

Source/Lib/CMakeLists.txt

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
add_library(MediaConchLib
2+
../Common/Configuration.cpp
3+
../Common/Core.cpp
4+
../Common/DaemonClient.cpp
5+
../Common/Database.cpp
6+
../Common/DatabaseReport.cpp
7+
../Common/DpfManager.cpp
8+
../Common/Http.cpp
9+
../Common/Httpd.cpp
10+
../Common/IMSC1.cpp
11+
../Common/JS_Tree.cpp
12+
../Common/Json.cpp
13+
../Common/LibEventHttp.cpp
14+
../Common/LibEventHttpd.cpp
15+
../Common/MediaConchLib.cpp
16+
../Common/NoDatabaseReport.cpp
17+
../Common/Plugin.cpp
18+
../Common/PluginFileLog.cpp
19+
../Common/PluginPreHook.cpp
20+
../Common/PluginsConfig.cpp
21+
../Common/PluginsManager.cpp
22+
../Common/Policy.cpp
23+
../Common/Policies.cpp
24+
../Common/Queue.cpp
25+
../Common/Reports.cpp
26+
../Common/REST_API.cpp
27+
../Common/Scheduler.cpp
28+
../Common/Schema.cpp
29+
../Common/SQLLite.cpp
30+
../Common/SQLLiteReport.cpp
31+
../Common/UnknownPolicy.cpp
32+
../Common/VeraPDF.cpp
33+
../Common/WatchFolder.cpp
34+
../Common/WatchFoldersManager.cpp
35+
../Common/Xslt.cpp
36+
../Common/XsltPolicy.cpp
37+
../IMSC1/IMSC1Plugin.cpp
38+
../Checker/Checker.cpp
39+
../Checker/Path.cpp
40+
../ThirdParty/tfsxml/tfsxml.cpp
41+
MediaConchDLL.cpp
42+
Lib.cpp
43+
)
44+
45+
target_link_libraries(MediaConchLib
46+
PRIVATE
47+
zen
48+
LibXml2::LibXml2
49+
libxslt::libxslt
50+
ZLIB::ZLIB
51+
mediainfo
52+
)
53+
54+
add_library(MediaConch:lib ALIAS MediaConchLib)
55+
56+
set_target_properties(MediaConchLib PROPERTIES
57+
OUTPUT_NAME mediaconch
58+
PUBLIC_HEADER MediaConchDLL.h
59+
)
60+
61+
target_include_directories(MediaConchLib
62+
PRIVATE
63+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/Source>
64+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/Source/Lib>
65+
)
66+
67+
if (MEDIACONCH_WITH_SQLITE)
68+
target_sources(MediaConchLib PRIVATE ../ThirdParty/sqlite/sqlite3.c)
69+
target_include_directories(MediaConchLib PRIVATE ../ThirdParty/sqlite)
70+
target_compile_definitions(MediaConchLib PRIVATE HAVE_SQLITE)
71+
endif ()
72+
73+
if(Libevent_FOUND AND MEDIACONCH_WITH_LIBEVENT)
74+
target_link_libraries(MediaConchLib PRIVATE libevent::libevent)
75+
target_compile_definitions(MediaConchLib PRIVATE HAVE_LIBEVENT)
76+
endif ()
77+
78+
if(jansson_FOUND AND MEDIACONCH_WITH_JANSSON)
79+
target_link_libraries(MediaConchLib PRIVATE jansson::jansson)
80+
target_compile_definitions(MediaConchLib PRIVATE HAVE_JANSSON)
81+
endif ()
82+
83+
install(TARGETS MediaConchLib EXPORT MediaConchTargets
84+
RUNTIME DESTINATION bin
85+
LIBRARY DESTINATION lib
86+
ARCHIVE DESTINATION lib
87+
PUBLIC_HEADER DESTINATION include/MediaConch
88+
)
89+
install(EXPORT MediaConchTargets
90+
FILE MediaConchTargets.cmake
91+
NAMESPACE MediaConch::
92+
DESTINATION share/cmake/${PROJECT_NAME}
93+
)

0 commit comments

Comments
 (0)