Skip to content

Commit 4d7b7d3

Browse files
committed
fix build of testing with flac
1 parent 318d0e7 commit 4d7b7d3

File tree

3 files changed

+63
-5
lines changed

3 files changed

+63
-5
lines changed

tests/CMakeLists.txt

+12-5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ include_directories (
2626
${CMAKE_BINARY_DIR}/noson/public
2727
${CMAKE_SOURCE_DIR}/noson/src)
2828

29+
find_package(FLAC)
30+
find_package(FLACXX)
31+
2932
###############################################################################
3033
# add targets
3134
add_executable (testdevice src/testdevice.cpp)
@@ -44,16 +47,20 @@ add_executable (testintrinsic src/testintrinsic.cpp)
4447
add_dependencies (testintrinsic noson)
4548
target_link_libraries (testintrinsic noson)
4649

47-
add_executable (tests16le2flac src/tests16le2flac.cpp)
48-
add_dependencies (tests16le2flac noson)
49-
target_link_libraries (tests16le2flac noson)
50-
50+
if (FLACXX_FOUND AND FLAC_FOUND)
51+
include_directories (BEFORE SYSTEM ${FLACXX_INCLUDE_DIR})
52+
add_executable (tests16le2flac src/tests16le2flac.cpp)
53+
add_dependencies (tests16le2flac noson)
54+
target_link_libraries (tests16le2flac noson)
55+
endif ()
5156

5257
###############################################################################
5358
# add unit tests
5459
include(UnitTestProject)
5560

56-
unittest_project(NAME check_flac_encoder SOURCES src/check_flac_encoder.cpp TARGET noson)
61+
if (FLACXX_FOUND AND FLAC_FOUND)
62+
unittest_project(NAME check_flac_encoder SOURCES src/check_flac_encoder.cpp TARGET noson)
63+
endif ()
5764
unittest_project(NAME check_compressor SOURCES src/check_compressor.cpp TARGET noson)
5865
unittest_project(NAME check_soap_parser SOURCES src/check_soap_parser.cpp TARGET noson)
5966
unittest_project(NAME check_intrinsic SOURCES src/check_intrinsic.cpp TARGET noson)

tests/cmake/FindFLAC.cmake

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#
2+
# Find and configure FLAC package
3+
#
4+
if(FLAC_INCLUDE_DIR AND FLAC_LIBRARIES)
5+
set(FLAC_FIND_QUIETLY true)
6+
endif()
7+
8+
find_path(FLAC_INCLUDE_DIR FLAC/metadata.h)
9+
find_library(FLAC_LIBRARIES FLAC)
10+
11+
if(FLAC_INCLUDE_DIR AND FLAC_LIBRARIES)
12+
set(FLAC_FOUND true)
13+
if(NOT FLAC_FIND_QUIETLY)
14+
message(STATUS "Found Flac: ${FLAC_LIBRARIES}")
15+
endif()
16+
else()
17+
if(FLAC_FIND_REQUIRED)
18+
message(FATAL_ERROR "Could not find FLAC")
19+
endif()
20+
if(NOT FLAC_FIND_QUIETLY)
21+
message(STATUS "Could not find FLAC")
22+
endif()
23+
endif()
24+
25+
mark_as_advanced(FLAC_INCLUDE_DIR FLAC_LIBRARIES)
26+

tests/cmake/FindFLACXX.cmake

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#
2+
# Find and configure FLACXX package
3+
#
4+
if(FLACXX_INCLUDE_DIR AND FLACXX_LIBRARIES)
5+
set(FLACXX_FIND_QUIETLY true)
6+
endif()
7+
8+
find_path(FLACXX_INCLUDE_DIR FLAC++/metadata.h)
9+
find_library(FLACXX_LIBRARIES FLAC++)
10+
11+
if(FLACXX_INCLUDE_DIR AND FLACXX_LIBRARIES)
12+
set(FLACXX_FOUND true)
13+
if(NOT FLACXX_FIND_QUIETLY)
14+
message(STATUS "Found Flac++: ${FLACXX_LIBRARIES}")
15+
endif()
16+
else()
17+
if(FLACXX_FIND_REQUIRED)
18+
message(FATAL_ERROR "Could not find FLAC++")
19+
endif()
20+
if(NOT FLACXX_FIND_QUIETLY)
21+
message(STATUS "Could not find FLAC++")
22+
endif()
23+
endif()
24+
25+
mark_as_advanced(FLACXX_INCLUDE_DIR FLACXX_LIBRARIES)

0 commit comments

Comments
 (0)