Skip to content

Commit 41ac5f0

Browse files
authored
Add cmake configurations to the tarball. (#776)
1 parent 2572842 commit 41ac5f0

File tree

5 files changed

+100
-5
lines changed

5 files changed

+100
-5
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rs/libmoq/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = ["Luke Curley <kixelated@gmail.com>", "Brian Medley <bpm@bmedley.org>"
55
repository = "https://github.com/moq-dev/moq"
66
license = "MIT OR Apache-2.0"
77

8-
version = "0.1.1"
8+
version = "0.1.2"
99
edition = "2021"
1010

1111
keywords = ["quic", "http3", "webtransport", "media", "live"]

rs/libmoq/build.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,31 @@ if [[ "$TARGET" != *"-windows-"* ]]; then
101101
cp "$WORKSPACE_DIR/target/moq.pc" "$PACKAGE_DIR/lib/pkgconfig/"
102102
fi
103103

104+
# Generate CMake config files from templates
105+
mkdir -p "$PACKAGE_DIR/lib/cmake/moq"
106+
107+
# Determine library filename
108+
if [[ "$TARGET" == *"-windows-"* ]]; then
109+
LIB_FILE="moq.lib"
110+
else
111+
LIB_FILE="libmoq.a"
112+
fi
113+
114+
# Extract major version
115+
MAJOR_VERSION="${VERSION%%.*}"
116+
117+
# Generate moq-config.cmake from template
118+
sed -e "s|@LIB_FILE@|${LIB_FILE}|g" \
119+
-e "s|@VERSION@|${VERSION}|g" \
120+
"$SCRIPT_DIR/cmake/moq-config.cmake.in" > "$PACKAGE_DIR/lib/cmake/moq/moq-config.cmake"
121+
122+
# Generate moq-config-version.cmake from template
123+
sed -e "s|@VERSION@|${VERSION}|g" \
124+
-e "s|@MAJOR_VERSION@|${MAJOR_VERSION}|g" \
125+
"$SCRIPT_DIR/cmake/moq-config-version.cmake.in" > "$PACKAGE_DIR/lib/cmake/moq/moq-config-version.cmake"
126+
127+
echo "Generated CMake config files from templates"
128+
104129
# Create archive
105130
cd "$OUTPUT_DIR"
106131
if [[ "$TARGET" == *"-windows-"* ]]; then
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# moq CMake version file
2+
3+
set(PACKAGE_VERSION "@VERSION@")
4+
5+
# Check whether the requested version is compatible
6+
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
7+
set(PACKAGE_VERSION_COMPATIBLE FALSE)
8+
else()
9+
set(PACKAGE_VERSION_COMPATIBLE TRUE)
10+
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
11+
set(PACKAGE_VERSION_EXACT TRUE)
12+
endif()
13+
endif()
14+
15+
# Check for same major version (SameMajorVersion compatibility)
16+
if(PACKAGE_FIND_VERSION_MAJOR STREQUAL "@MAJOR_VERSION@")
17+
set(PACKAGE_VERSION_COMPATIBLE TRUE)
18+
else()
19+
set(PACKAGE_VERSION_COMPATIBLE FALSE)
20+
endif()
Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,55 @@
1-
@PACKAGE_INIT@
1+
# moq CMake configuration file
22

3-
include("${CMAKE_CURRENT_LIST_DIR}/moq-targets.cmake")
3+
# Compute installation prefix relative to this file
4+
get_filename_component(_moq_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH)
5+
get_filename_component(_moq_prefix "${_moq_prefix}" PATH)
6+
get_filename_component(_moq_prefix "${_moq_prefix}" PATH)
7+
get_filename_component(_moq_prefix "${_moq_prefix}" PATH)
48

5-
check_required_components(moq)
9+
# Set install paths
10+
set(PACKAGE_PREFIX_DIR "${_moq_prefix}")
11+
set(_moq_includedir "${_moq_prefix}/include")
12+
set(_moq_libdir "${_moq_prefix}/lib")
13+
14+
set(_moq_lib_name "@LIB_FILE@")
15+
16+
# Create imported target
17+
if(NOT TARGET moq::moq)
18+
add_library(moq::moq STATIC IMPORTED)
19+
20+
set_target_properties(moq::moq PROPERTIES
21+
IMPORTED_LOCATION "${_moq_libdir}/${_moq_lib_name}"
22+
INTERFACE_INCLUDE_DIRECTORIES "${_moq_includedir}"
23+
)
24+
25+
# Link required system frameworks on macOS
26+
if(APPLE)
27+
set_property(TARGET moq::moq APPEND PROPERTY
28+
INTERFACE_LINK_LIBRARIES "-framework CoreFoundation" "-framework Security"
29+
)
30+
endif()
31+
32+
# On Windows, add required system libraries
33+
if(WIN32)
34+
set_property(TARGET moq::moq APPEND PROPERTY
35+
INTERFACE_LINK_LIBRARIES "ws2_32" "userenv" "bcrypt" "ntdll"
36+
)
37+
endif()
38+
39+
# On Linux, add required system libraries
40+
if(UNIX AND NOT APPLE)
41+
set_property(TARGET moq::moq APPEND PROPERTY
42+
INTERFACE_LINK_LIBRARIES "dl" "m" "pthread"
43+
)
44+
endif()
45+
endif()
46+
47+
# Clean up internal variables
48+
unset(_moq_prefix)
49+
unset(_moq_includedir)
50+
unset(_moq_libdir)
51+
unset(_moq_lib_name)
52+
53+
# Package metadata
54+
set(moq_FOUND TRUE)
55+
set(moq_VERSION "@VERSION@")

0 commit comments

Comments
 (0)