-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
44 lines (37 loc) · 1.48 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
cmake_minimum_required(VERSION 2.8)
project (a-lame-mp3-encoder)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
option(LAME_INCDIR "Lame include directory" "")
# compiler options
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set (CMAKE_CXX_FLAGS "--std=c++11 ${CMAKE_CXX_FLAGS}")
endif ()
#message(SEND_ERROR ${LAME_INCDIR})
if(NOT ${LAME_INCDIR} STREQUAL "")
include_directories(${LAME_INCDIR})
else()
message(FATAL_ERROR "You need to define LAME_INCDIR")
endif()
#if(${LAME_LIBDIR})
# link_directories(${LAME_LIBDIR})
#else()
# message(FATAL_ERROR "You need to define LAME_LIBDIR")
#endif()
# static linking
find_library(LIBLAME libmp3lame.a)
# build binary
add_executable(a-lame-mp3-encoder
${CMAKE_CURRENT_SOURCE_DIR}/src/wavdecoder.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/directory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/mp3encoder.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/batch-encoder.cpp)
target_link_libraries(a-lame-mp3-encoder ${LIBLAME} pthread)
# build tests
add_executable(dir_test ${CMAKE_CURRENT_SOURCE_DIR}/src/directory.cpp)
target_compile_definitions(dir_test PRIVATE TEST_DIR)
add_executable(wav_test ${CMAKE_CURRENT_SOURCE_DIR}/src/wavdecoder.cpp)
target_compile_definitions(wav_test PRIVATE TEST_WAV)
add_executable(enc_test ${CMAKE_CURRENT_SOURCE_DIR}/src/mp3encoder.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/wavdecoder.cpp)
target_compile_definitions(enc_test PRIVATE TEST_ENC)
target_link_libraries(enc_test ${LIBLAME})