1 From 8abe6385e433b44c43134b4deef208c7498ab0d7 Mon Sep 17 00:00:00 2001
2 From: Emily <hello@emily.moe>
3 Date: Sat, 3 Aug 2024 12:21:12 +0100
4 Subject: [PATCH 3/4] Modernize CMake build system
6 Use GNUInstallDirs, CTest, and FindPkgConfig.
9 CMakeLists.txt | 25 +++++++++++--------------
10 libmusly/CMakeLists.txt | 11 +++--------
11 musly/CMakeLists.txt | 6 +-----
12 4 files changed, 16 insertions(+), 28 deletions(-)
14 diff --git a/.travis.yml b/.travis.yml
15 index 8556b26..b051004 100644
18 @@ -19,7 +19,7 @@ matrix:
22 - - cmake -DBUILD_TEST=ON ..
27 diff --git a/CMakeLists.txt b/CMakeLists.txt
28 index 4fab4ab..8d8bf0e 100644
32 # (c) 2013-2014, Dominik Schnitzer <dominik@schnitzer.at>
33 # 2014, Jan Schlueter <jan.schlueter@ofai.at>
35 -cmake_minimum_required(VERSION 2.8)
36 +cmake_minimum_required(VERSION 3.17)
39 +include(GNUInstallDirs)
41 set(MUSLY_VERSION "0.2")
42 add_definitions(-DMUSLY_VERSION="${MUSLY_VERSION}")
44 @@ -36,8 +38,6 @@ else ()
45 set(BUILD_SHARED_LIBS ON)
48 -option(BUILD_TEST "Build selftest executable" OFF)
50 option(USE_OPENMP "Compile with OpenMP support (Parallelization)" OFF)
53 @@ -54,26 +54,23 @@ if (USE_OPENMP)
57 -set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
59 -find_package(Eigen3 REQUIRED)
60 -find_package(LibAV 0.8 COMPONENTS avcodec avformat avutil REQUIRED)
61 +find_package(PkgConfig REQUIRED)
62 +pkg_check_modules(EIGEN3 REQUIRED IMPORTED_TARGET eigen3)
63 +pkg_check_modules(FFMPEG REQUIRED IMPORTED_TARGET
69 - "${PROJECT_BINARY_DIR}"
70 "${PROJECT_SOURCE_DIR}/include")
72 add_subdirectory(libmusly)
73 add_subdirectory(musly)
74 add_subdirectory(include)
78 add_subdirectory(test)
82 set(musly_DOC_FILES AUTHORS COPYING README.md)
83 -set(musly_DOC_PATH "share/doc/musly")
84 -install(FILES ${musly_DOC_FILES}
85 - DESTINATION ${musly_DOC_PATH})
87 +install(FILES ${musly_DOC_FILES} DESTINATION ${CMAKE_INSTALL_DOCDIR})
88 diff --git a/libmusly/CMakeLists.txt b/libmusly/CMakeLists.txt
89 index 98151df..b9f6d11 100644
90 --- a/libmusly/CMakeLists.txt
91 +++ b/libmusly/CMakeLists.txt
93 # (c) 2013-2014, Dominik Schnitzer <dominik@schnitzer.at>
94 # 2014-2016, Jan Schlueter <jan.schlueter@ofai.at>
99 if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external")
102 @@ -24,8 +21,6 @@ endif()
106 - ${EIGEN3_INCLUDE_DIR}
107 - ${LIBAV_INCLUDE_DIRS}
108 ${CMAKE_CURRENT_SOURCE_DIR})
111 @@ -60,7 +55,8 @@ set_target_properties(libmusly
113 target_link_libraries(libmusly
115 - ${LIBAV_LIBRARIES})
119 # link against winsock2 for ntohl() and htonl()
120 target_link_libraries(libmusly ws2_32)
121 @@ -69,5 +65,4 @@ endif()
122 set_target_properties(libmusly
123 PROPERTIES PREFIX "")
125 -install(TARGETS libmusly
127 +install(TARGETS libmusly)
128 diff --git a/musly/CMakeLists.txt b/musly/CMakeLists.txt
129 index 88d153b..846ed2c 100644
130 --- a/musly/CMakeLists.txt
131 +++ b/musly/CMakeLists.txt
134 # (c) 2013, Dominik Schnitzer <dominik@schnitzer.at>
136 -include_directories(
137 - ${EIGEN3_INCLUDE_DIR})
143 @@ -17,4 +13,4 @@ add_executable(musly
144 target_link_libraries(musly
147 -install(TARGETS musly DESTINATION bin)
148 +install(TARGETS musly)