-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
77 lines (62 loc) · 1.73 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
cmake_minimum_required( VERSION 3.15 )
project( libmad )
include(CMakeDependentOption)
set( TARGET libmad )
cmake_dependent_option( BUILD_SHARED "Build a shared library" Off "NOT WIN32" Off)
option( OPT_ACCURACY "Favour accuracy" On)
option( OPT_SPEED "Favour speed" Off)
option( OPT_SSO "Enable a fast subband synthesis approximation optimization" Off)
if( BUILD_SHARED )
add_library( ${TARGET} SHARED )
else()
add_library( ${TARGET} STATIC )
endif()
set(EXPORTED_HEADERS
detect_fpm.h
version.h
fixed.h
bit.h
timer.h
stream.h
frame.h
synth.h
decoder.h
)
target_sources( ${TARGET}
PRIVATE
bit.c
decoder.c
fixed.c
frame.c
huffman.c
layer12.c
layer3.c
stream.c
synth.c
timer.c
version.c
)
target_include_directories( ${TARGET} PRIVATE . "${CMAKE_BINARY_DIR}/include" )
target_compile_definitions( ${TARGET}
PRIVATE
HAVE_CONFIG_H
OPT_ACCURACY
${FPM}
)
target_compile_options( ${TARGET}
PRIVATE
$<$<C_COMPILER_ID:AppleClang,Clang,GNU>:-Wall>
$<$<C_COMPILER_ID:AppleClang,Clang,GNU>:-Wno-implicit-function-declaration>
$<$<C_COMPILER_ID:AppleClang,Clang,GNU>:-fPIC>
)
set (MAD_H "${CMAKE_BINARY_DIR}/include/mad.h")
configure_file( config.h.in "${CMAKE_BINARY_DIR}/include/config.h" )
configure_file( mad.h.in "${MAD_H}" )
foreach( header ${EXPORTED_HEADERS} )
file( READ ${header} HEADER_DATA )
string( REPLACE "# include" "// # include" HEADER_DATA_REPLACED "${HEADER_DATA}")
file( APPEND ${MAD_H} "// \"${header}\"\n\n${HEADER_DATA_REPLACED}\n" )
endforeach()
file( APPEND ${MAD_H} "# ifdef __cplusplus\n}\n# endif\n#endif\n" )
install(TARGETS ${TARGET})
install(FILES ${MAD_H} DESTINATION TYPE INCLUDE)