aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
blob: 16ac794791ca9565f950f4272d35e2a36b5aefb1 (plain)
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
########################################################################
# Project setup
########################################################################

cmake_minimum_required(VERSION 2.8)
project(Toolame-DAB C)

# Select the release build type by default to get optimization flags
if(NOT CMAKE_BUILD_TYPE)
   set(CMAKE_BUILD_TYPE "Release")
   message(STATUS "Build type not specified: defaulting to release.")
endif(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "")

list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)


########################################################################
# Version information
########################################################################

set(VERSION_INFO_MAJOR  0)
set(VERSION_INFO_MINOR  0)
set(VERSION_INFO_PATCH  0)

if(NOT DEFINED VERSION_INFO_EXTRA)
    set(VERSION_INFO_EXTRA "git")
endif()
include(Version)

set(VERSION "${VERSION_INFO}")


########################################################################
# Compiler specific setup
########################################################################

set(CMAKE_CFLAGS "${CMAKE_C_FLAGS} -W -Wall")
add_definitions(-fomit-frame-pointer)
add_definitions(-march=native)
add_definitions(-DGIT_VERSION="${VERSION}")
add_definitions(-DINLINE=)
add_definitions(-DNEWENCODE)


########################################################################
# Find build dependencies
########################################################################

find_package(PkgConfig)

# libm
find_library(M_LIB m REQUIRED)

# threads
find_package(Threads REQUIRED)

# libzmq
pkg_check_modules(ZMQ libzmq>=4.0 REQUIRED)
if(NOT ZMQ_FOUND)
    message(FATAL_ERROR "libmzq required to compile toolame-dab \n")
endif()
include_directories(${ZMQ_INCLUDE_DIRS})

# libjack
pkg_check_modules(JACK jack)

# libvlc
pkg_check_modules(VLC libvlc)


########################################################################
# Options
########################################################################

# vlc input
option(ENABLE_INPUT_VLC
    "libvlc input plugin" ${VLC_FOUND})

# jack input
option(ENABLE_INPUT_JACK
    "Jack input plugin" ${JACK_FOUND})


if(ENABLE_INPUT_VLC)
    if(NOT VLC_FOUND)
        message(FATAL_ERROR "libvlc required to compile toolame-dab with ENABLE_INPUT_VLC \n")
    endif()
    add_definitions(-DVLC_INPUT)
    include_directories(${VLC_INCLUDE_DIRS})
    list(APPEND other_libs ${VLC_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
endif()


if(ENABLE_INPUT_JACK)
    if(NOT JACK_FOUND)
        message(FATAL_ERROR "libjack required to compile toolame-dab with ENABLE_INPUT_JACK \n")
    endif()
    add_definitions(-DJACK_INPUT)
    include_directories(${JACK_INCLUDE_DIRS})
    list(APPEND other_libs ${JACK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
endif()


########################################################################
# Setup apps
########################################################################

list(APPEND toolame_sources
    common.c
    encode.c
    ieeefloat.c
    toolame.c
    portableio.c
    psycho_n1.c
    psycho_0.c
    psycho_1.c
    psycho_2.c
    psycho_3.c
    psycho_4.c
    fft.c
    subband.c
    audio_read.c
    bitstream.c
    mem.c
    crc.c
    tables.c
    availbits.c
    ath.c
    encode_new.c
    zmqoutput.c
    utils.c
    xpad.c
    vlc_input.c
    )

add_executable(toolame ${toolame_sources})
set_target_properties(toolame PROPERTIES OUTPUT_NAME toolame-dab)
target_link_libraries(toolame ${M_LIB} ${ZMQ_LIBRARIES} ${other_libs})

install(TARGETS toolame DESTINATION bin)


########################################################################
# Create uninstall target
########################################################################

configure_file(
    "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
    "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
    IMMEDIATE @ONLY)

add_custom_target(uninstall
    COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)