-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge PR #11: Replace Makefile with CMake project
- Loading branch information
Showing
5 changed files
with
126 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1 @@ | ||
*.[oa] | ||
*~ | ||
ossp-alsap | ||
ossp-padsp | ||
osspd | ||
osstest | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
|
||
list(APPEND CMAKE_MODULE_PATH | ||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake" | ||
) | ||
|
||
project("OSS Proxy" | ||
VERSION 1.3.2 | ||
DESCRIPTION "Emulate OSS device(s) using CUSE." | ||
HOMEPAGE_URL "https://github.com/OpenMandrivaSoftware/ossp" | ||
LANGUAGES "C" | ||
) | ||
|
||
option(alsa "Build ALSA slave." OFF) | ||
option(daemon "Build daemon." ON) | ||
option(pulseaudio "Build PulseAudio slave." ON) | ||
option(test "Build test." OFF) | ||
|
||
include(ossp-util) | ||
|
||
if(test) | ||
include(CTest) | ||
endif() | ||
|
||
# Shared library | ||
add_library(libossp OBJECT | ||
"ossp.c" | ||
"ossp.h" | ||
"ossp-slave.c" | ||
"ossp-slave.h" | ||
"ossp-util.c" | ||
"ossp-util.h" | ||
) | ||
|
||
target_compile_definitions(libossp | ||
PUBLIC | ||
"OSSP_VERSION=\"${PROJECT_VERSION}\"" | ||
) | ||
|
||
# Daemon | ||
if(daemon) | ||
add_executable(osspd "osspd.c") | ||
set_output_dir(osspd) | ||
|
||
link_pkg(osspd "fuse") | ||
target_link_libraries(osspd PRIVATE libossp) | ||
|
||
install_daemon(osspd) | ||
endif() | ||
|
||
# ALSA slave | ||
if(alsa) | ||
add_executable(ossp-alsap "ossp-alsap.c") | ||
set_output_dir(ossp-alsap) | ||
|
||
link_pkg(ossp-alsap "alsa") | ||
target_link_libraries(ossp-alsap PRIVATE libossp) | ||
|
||
install_slave(ossp-alsap) | ||
endif() | ||
|
||
# PulseAudio slave | ||
if(pulseaudio) | ||
add_executable(ossp-padsp "ossp-padsp.c") | ||
set_output_dir(ossp-padsp) | ||
|
||
link_pkg(ossp-padsp "libpulse") | ||
target_link_libraries(ossp-padsp PRIVATE libossp) | ||
|
||
install_slave(ossp-padsp) | ||
endif() | ||
|
||
if(test) | ||
add_executable(osstest "osstest.c") | ||
|
||
add_test( | ||
NAME osstest | ||
COMMAND osstest | ||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR} | ||
) | ||
endif() | ||
|
||
install_udev_rules("98-osscuse.rules") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
include(GNUInstallDirs) | ||
|
||
find_package(PkgConfig REQUIRED) | ||
|
||
set(INSTALL_UDEVRULESDIR | ||
"${CMAKE_INSTALL_PREFIX}/lib/udev/rules.d" | ||
CACHE PATH | ||
"Install path for udev rules." | ||
) | ||
|
||
function(link_pkg TARGET PKG) | ||
pkg_search_module(${PKG} ${PKG} REQUIRED) | ||
|
||
target_compile_options(${TARGET} PRIVATE ${${PKG}_CFLAGS}) | ||
target_include_directories(${TARGET} PRIVATE ${${PKG}_INCLUDE_DIRS}) | ||
target_link_libraries(${TARGET} PRIVATE ${${PKG}_LINK_LIBRARIES}) | ||
endfunction() | ||
|
||
macro(set_output_dir TARGET) | ||
set_target_properties(${TARGET} | ||
PROPERTIES | ||
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} | ||
) | ||
endmacro() | ||
|
||
macro(install_daemon TARGET) | ||
install(TARGETS ${TARGET} | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR} | ||
) | ||
endmacro() | ||
|
||
macro(install_slave TARGET) | ||
install(TARGETS ${TARGET} | ||
RUNTIME DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/ossp" | ||
) | ||
endmacro() | ||
|
||
macro(install_udev_rules FILES) | ||
install(FILES ${FILES} | ||
DESTINATION ${INSTALL_UDEVRULESDIR} | ||
) | ||
endmacro() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters