source: mediastreamer2/src/CMakeLists.txt @ 1433:099ab5051a2b

Last change on this file since 1433:099ab5051a2b was 1433:099ab5051a2b, checked in by Vadim Lebedev <vadim@…>, 17 months ago

cleanup build without video support

File size: 5.2 KB
Line 
1set(PACKAGE "mediastreamer2")
2set(PACKAGE_BUGREPORT "mediastreamer2")
3set(PACKAGE_NAME "mediastreamer2")
4set(PACKAGE_STRING "${PACKAGE} ${ORTP_VERSION}")
5set(PACKAGE_PLUGINS_DIR "plugins/")
6
7if(ANDROID)
8  set(CMAKE_THREAD_LIBS_INIT "-lc")
9  set(MS_LIBS ${MS_LIBS} m log)
10  add_definitions(-DANDROID)
11endif()
12include(FindThreads)
13
14set(MS_SRCS mscommon.c msfilter.c msqueue.c msticker.c alaw.c ulaw.c mssndcard.c msrtp.c
15        dtmfgen.c ice.c tee.c msconf.c msjoin.c msvolume.c mswebcam.c mtu.c void.c eventqueue.c
16        dsptools.c kiss_fft.c  kiss_fftr.c equalizer.c audiostream.c tonedetector.c itc.c audiomixer.c)
17
18if(NOT ENABLE_VIDEO)
19  list(REMOVE_ITEM MS_SRCS mswebcam.c)
20else(NOT ENABLE_VIDEO)
21  add_definitions(-DVIDEO_ENABLED)
22endif(NOT ENABLE_VIDEO)
23
24add_definitions(-DMS2_INTERNAL)
25if(USE_CSL)
26add_definitions(-DHAVE_CSL)
27endif(USE_CSL)
28
29if(LINUX AND NOT ANDROID)
30  set(MS_SRCS ${MS_SRCS} oss.c)
31  find_library(ALSA  asound)
32  if (ALSA)
33    set(MS_SRCS  ${MS_SRCS} alsa.c)
34    set(MS_LIBS  ${MS_LIBS} ${ALSA})
35    add_definitions(-D__ALSA_ENABLED__)
36  endif(ALSA)
37  add_definitions(-DHAVE_DLOPEN)
38endif(LINUX AND NOT ANDROID)
39
40if(ANDROID)
41  set(MS_SRCS  ${MS_SRCS} msandroid.cpp msjava.c)
42
43  add_definitions(
44          -include${CMAKE_CURRENT_SOURCE_DIR}/../build/android/libmediastreamer2_AndroidConfig.h)
45  include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../build/android" dummy .)
46
47  if (USE_WEBRTC)
48    set(MS_SRCS  ${MS_SRCS} msandroid_webrtc.cpp)
49    #set(MS_SRCS  ${MS_SRCS} audio_device_android_jni.cc audio_device_buffer.cc
50    #     file_impl.cc audio_device_utility.cc thread.cc thread_posix.cc
51    #     critical_section_posix.cc critical_section.cc event_posix.cc
52    #     event.cc audio_device_generic.cc audio_device_impl.cc
53    #     dummy/audio_device_dummy.cc dummy/audio_device_utility_dummy.cc
54    #     audio_device_utility_android.cc atomic32.cc msandroid_webrtc.cpp)
55    add_definitions(-DWEBRTC_ANDROID -DWEBRTC_CLOCK_TYPE_REALTIME
56          -DWEBRTC_LINUX)
57  endif()
58
59endif()
60
61add_definitions(-DMS2_INTERNAL)
62
63if(WIN32)
64  include_directories(../build/win32native/)
65  set(MS_SRCS ${MS_SRCS} winsnd3.c msfileplayer_win.c msfilerec_win.c)
66else(WIN32)
67  set(MS_SRCS ${MS_SRCS} msfileplayer.c msfilerec.c)
68endif(WIN32)
69
70find_file(GSM_GSM_H gsm/gsm.h PATHS ${GSM_INCLUDE_DIRS})
71if(GSM_GSM_H)
72  find_library(GSM_LIB gsm)
73endif(GSM_GSM_H)
74
75if(GSM_LIB)
76  include_directories(${GSM_INCLUDE_DIRS})
77  set(MS_LIBS ${MS_LIBS} ${GSM_LIB})
78  set(MS_SRCS ${MS_SRCS} gsm.c)
79else(GSM_LIB)
80  include_directories(${GSM_INCLUDE_DIRS})
81  set(MS_LIBS ${MS_LIBS} ${GSM_LIBRARIES})
82  set(MS_SRCS ${MS_SRCS} gsm.c)
83endif(GSM_LIB)
84
85find_file(SPEEX_H speex/speex.h PATHS ${SPEEX_INCLUDE_DIRS})
86if(SPEEX_H)
87  set(MS_LIBS  ${MS_LIBS} ${SPEEX_LIBRARIES} ${SPEEXDSP_LIBRARIES})
88  set(MS_SRCS ${MS_SRCS} msspeex.c msresample.c speexec.c)
89  include_directories(${SPEEX_INCLUDE_DIRS})
90else(SPEEX_H)
91  add_definitions(-DDISABLE_SPEEX)
92endif(SPEEX_H)
93
94if(PORTAUDIO_FOUND)
95  add_definitions(
96    -D__PORTAUDIO_ENABLED__
97  )
98  include_directories(${PORTAUDIO_INCLUDE_DIRS})
99  set(MS_SRCS  ${MS_SRCS} pasnd.c)
100  set(MS_LIBS  ${MS_LIBS} ${PORTAUDIO_LIBRARIES})
101endif(PORTAUDIO_FOUND)
102
103if(NOT CMAKE_UNDER_CE AND NOT IPHONE)
104        TEST_BIG_ENDIAN(BIG_ENDIAN)
105        if(BIG_ENDIAN)
106          add_definitions(
107                -DORTP_BIGENDIAN
108                -DWORDS_BIGENDIAN
109          )
110        endif(BIG_ENDIAN)
111endif(NOT CMAKE_UNDER_CE AND NOT IPHONE)
112
113if(NOT WIN32 AND NOT ANDROID)
114        # We want to generated the alldescs.h file
115        # Step 1:
116        #   Find all calls to MS_FILTER_DESC_EXPORT macro in the source file and extract the arguments
117        foreach(f ${MS_SRCS})
118         file(READ ${f} fc)
119         string(REGEX MATCHALL "MS_FILTER_DESC_EXPORT[(][^\n]*_desc[)]" mcs ${fc})
120         message("matches for ${f} are ${mcs} .")
121         set(fds ${fds} ${mcs})
122        endforeach(f)
123
124        string(REPLACE "MS_FILTER_DESC_EXPORT\(" "" fds ${fds})
125        string(REPLACE "\)" " " fds ${fds})
126        string(REPLACE "\n" "" fds ${fds})
127        string(REPLACE " " ";" fds ${fds})
128        set(fds ${fds})
129
130        # Here the 'fds' variable contains the list of filter names
131        #message("fds = ${fds}")
132
133        # Step 2:  Generate the file which refernces all the descriptors
134        set(fn "${CMAKE_CURRENT_BINARY_DIR}/alldescs.h")
135        file(WRITE ${fn} "#include \"mediastreamer2/msfilter.h\"\n\n")
136        foreach(fd ${fds})
137          file(APPEND ${fn} "extern MSFilterDesc ${fd};\n")
138        endforeach(fd)
139        file(APPEND ${fn} "MSFilterDesc *ms_filter_descs[]={\n")
140        foreach(fd ${fds})
141          file(APPEND ${fn} "&${fd},\n")
142        endforeach(fd)
143        file(APPEND ${fn} "0\n};\n")
144endif()
145
146if(IPHONE)
147  add_definitions(-D__MACIOUNIT_ENABLED__)
148  set(MS_SRCS  ${MS_SRCS} msiounit.c)
149endif()
150
151if(NOT ANDROID)
152  configure_file("${CMAKE_CURRENT_SOURCE_DIR}/mediastreamer-config.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/mediastreamer-config.h")
153  add_definitions(
154        -DHAVE_CONFIG_H
155        )
156endif()
157
158include_directories(${mediastreamer_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_DIR} ${ORTP_INCLUDE_DIRS})
159set(MEDIASTREAMER_INCLUDE_DIRS ${mediastreamer_SOURCE_DIR}/include CACHE STRING "mediastreamer2 include dir")
160
161add_library(mediastreamer SHARED ${MS_SRCS})
162if(NOT ANDROID)
163set_target_properties(mediastreamer PROPERTIES VERSION ${MEDIASTREAMER_VERSION_STRING} SOVERSION
164  ${MEDIASTREAMER_VERSION_STRING})
165endif()
166target_link_libraries(mediastreamer ${MS_LIBS} ${ORTP_LIBRARIES})
167set(MEDIASTREAMER_LIBRARIES mediastreamer CACHE STRING "mediastreamer2 libraries")
Note: See TracBrowser for help on using the repository browser.