Skip to content

Commit

Permalink
build: set rpath
Browse files Browse the repository at this point in the history
  • Loading branch information
silenium-dev committed Jul 24, 2024
1 parent 0c19b75 commit 9d39cd5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ build/
!**/src/test/**/build/
.kotlin
*.log
*.webm
*.mkv
*.mp4
nv12.png
output.png
rgb.png
Expand Down
6 changes: 6 additions & 0 deletions native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.21)
if (NOT DEFINED PROJECT_NAME)
set(PROJECT_NAME "compose-av")
endif ()
if (NOT DEFINED FFMPEG_PLATFORM)
message(FATAL_ERROR "FFMPEG_PLATFORM must be defined")
endif ()

project(${PROJECT_NAME} LANGUAGES CXX)

Expand Down Expand Up @@ -62,6 +65,9 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
pkg_check_modules(ffmpeg REQUIRED IMPORTED_TARGET libavcodec libavformat libavutil libswscale)
target_link_libraries(${PROJECT_NAME} PRIVATE PkgConfig::GL PkgConfig::ffmpeg)
target_include_directories(${PROJECT_NAME} PRIVATE "${JAVA_HOME}/include/linux")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND patchelf --set-rpath \$ORIGIN,\$ORIGIN/${FFMPEG_PLATFORM} $<TARGET_FILE:${PROJECT_NAME}>
)
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_include_directories(${PROJECT_NAME} PRIVATE "${FFMPEG_PREFIX}\\include")
target_link_libraries(${PROJECT_NAME} PRIVATE "${FFMPEG_PREFIX}\\lib\\avcodec.lib" "${FFMPEG_PREFIX}\\lib\\avformat.lib" "${FFMPEG_PREFIX}\\lib\\avutil.lib" "${FFMPEG_PREFIX}\\lib\\swscale.lib")
Expand Down
4 changes: 3 additions & 1 deletion native/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ val generateMakefile = tasks.register<Exec>("generateMakefile") {
val additionalFlags = mutableListOf(
"-DJAVA_HOME=${System.getProperty("java.home")}",
"-DPROJECT_NAME=${rootProject.name}",
"-DFFMPEG_PLATFORM=linux-x86_64", // TODO: Detect platform
)
if (OSUtils.isWindows()) {
additionalFlags += "-DFFMPEG_PREFIX=\"${findProperty("ffmpeg.prefix") ?: error("ffmpeg.prefix is not set")}\""
Expand Down Expand Up @@ -85,7 +86,8 @@ artifacts {
publishing {
publications {
create<MavenPublication>("natives${artifactSuffix.split("-").joinToString("") { it.capitalized() }}") {
// from()
artifact(jar)
artifactId = "${rootProject.name}-natives-$artifactSuffix"
}
}
}
3 changes: 0 additions & 3 deletions src/test/resources/video.webm

This file was deleted.

0 comments on commit 9d39cd5

Please sign in to comment.