| 1 |
cmake_minimum_required(VERSION 3.11) |
| 2 |
|
| 3 |
project( |
| 4 |
opustags |
| 5 |
VERSION 1.10.1 |
| 6 |
LANGUAGES CXX |
| 7 |
) |
| 8 |
|
| 9 |
set(CMAKE_CXX_STANDARD 20) |
| 10 |
set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 11 |
|
| 12 |
# opustags is mainly developed with glibc, which introduces a few |
| 13 |
# incompatibilites with BSDs, like getline not being defined by default. |
| 14 |
# _GNU_SOURCE should trigger BSD’s libc GNU compatibility mode to fix that. |
| 15 |
add_definitions(-D_GNU_SOURCE) |
| 16 |
|
| 17 |
find_package(PkgConfig REQUIRED) |
| 18 |
pkg_check_modules(OGG REQUIRED ogg) |
| 19 |
add_compile_options(${OGG_CFLAGS}) |
| 20 |
link_directories(${OGG_LIBRARY_DIRS}) |
| 21 |
|
| 22 |
include(FindIconv) |
| 23 |
|
| 24 |
# We need endian.h on Linux, and sys/endian.h on BSD. |
| 25 |
include(CheckIncludeFileCXX) |
| 26 |
check_include_file_cxx(endian.h HAVE_ENDIAN_H) |
| 27 |
check_include_file_cxx(sys/endian.h HAVE_SYS_ENDIAN_H) |
| 28 |
|
| 29 |
include(CheckStructHasMember) |
| 30 |
check_struct_has_member("struct stat" st_mtim sys/stat.h HAVE_STAT_ST_MTIM LANGUAGE CXX) |
| 31 |
check_struct_has_member("struct stat" st_mtimespec sys/stat.h HAVE_STAT_ST_MTIMESPEC LANGUAGE CXX) |
| 32 |
|
| 33 |
configure_file(src/config.h.in config.h @ONLY) |
| 34 |
include_directories(BEFORE src "${CMAKE_BINARY_DIR}" ${OGG_INCLUDE_DIRS} ${Iconv_INCLUDE_DIRS}) |
| 35 |
|
| 36 |
add_library( |
| 37 |
ot |
| 38 |
STATIC |
| 39 |
src/base64.cc |
| 40 |
src/cli.cc |
| 41 |
src/ogg.cc |
| 42 |
src/opus.cc |
| 43 |
src/system.cc |
| 44 |
) |
| 45 |
target_link_libraries(ot PUBLIC ${OGG_LIBRARIES} ${Iconv_LIBRARIES}) |
| 46 |
|
| 47 |
add_executable(opustags src/opustags.cc) |
| 48 |
target_link_libraries(opustags ot) |
| 49 |
|
| 50 |
include(GNUInstallDirs) |
| 51 |
install(TARGETS opustags DESTINATION "${CMAKE_INSTALL_BINDIR}") |
| 52 |
configure_file(opustags.1 . @ONLY) |
| 53 |
install(FILES "${CMAKE_BINARY_DIR}/opustags.1" DESTINATION "${CMAKE_INSTALL_MANDIR}/man1") |
| 54 |
install(FILES CHANGELOG.md CONTRIBUTING.md LICENSE README.md DESTINATION ${CMAKE_INSTALL_DOCDIR}) |
| 55 |
|
| 56 |
add_subdirectory(t) |