You are not logged in.
This is my first PKGBUILD so bare with me please if the question is stupid.
I have a C++ project on github that I am trying to turn into a package to upload to AUR.
The project is built with the following CMakeLists.txt:
cmake_minimum_required(VERSION 3.28)
project(MyProject LANGUAGES CXX)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
include(FetchContent)
FetchContent_Declare(SFML
GIT_REPOSITORY https://github.com/SFML/SFML.git
GIT_TAG 3.0.1
GIT_SHALLOW ON
EXCLUDE_FROM_ALL
SYSTEM)
FetchContent_MakeAvailable(SFML)
add_executable(main WIN32 src/main.cxx)
target_link_options(main PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/ENTRY:mainCRTStartup>
)
file(COPY "${PROJECT_SOURCE_DIR}/media" DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/")
target_compile_features(main PRIVATE cxx_std_17)
target_link_libraries(main PRIVATE SFML::Graphics)
It produces a binary file and a directory with media files at bin/ subdirectory. What should be in my package() function to correctly install the binary with media files.
My PKGBUILD
pkgname=myproject
pkgver=v0.1.0.alpha.r0.gbb91f88
pkgrel=1
pkgdesc="MyProject"
arch=('x86_64')
url="https://github.com/anonymous/${pkgname}"
license=('MIT')
depends=('cmake')
makedepends=('git' 'cmake' 'base-devel')
source=("git+${url}.git")
sha256sums=('SKIP')
pkgver() {
cd "${pkgname}"
git describe --long --tags | sed 's/^v-//;s/\([^-]*-g\)/r\1/;s/-/./g' | sed 's/\([^-]*-\)g/\1r/' | sed 's/\([^-]*\)-\([^-]*\)/r\2.g/'
}
build() {
mkdir -p "${srcdir}/build"
cd "${srcdir}/build"
cmake -DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
"${srcdir}/${pkgname}"
make
}
package() {
cd "${srcdir}/build"
make DESTDIR="${pkgdir}" install
}
UPDATE I am catching up to my stupidity, I forgot to add install() to my cmake config.
install(TARGETS main DESTINATION bin)
install(DIRECTORY "${PROJECT_SOURCE_DIR}/media/" DESTINATION share/myproject)
Last edited by rumata (2025-10-08 19:07:34)
Offline