summaryrefslogtreecommitdiffstats
path: root/flow/gsl/CMakeLists.txt
blob: 7c880ee1fb05ba0a08d99b3fc41cd5856c8d3289 (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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#################################################
#
#  (C) 2010 Serghei Amelian
#  serghei (DOT) amelian (AT) gmail.com
#
#  Improvements and feedback are welcome
#
#  This file is released under GPL >= 2
#
#################################################

include( CheckCSourceCompiles )


##### check for ogg/vorbis ######################

set( GSL_HAVE_OGGVORBIS 0 )
if( WITH_VORBIS )

  pkg_search_module( VORBIS vorbis )

  if( VORBIS_FOUND )

    pkg_search_module( VORBISFILE vorbisfile )

    if( VORBISFILE_FOUND )

      set( GSL_HAVE_OGGVORBIS 1 )

      set( bak_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} )
      set( CMAKE_REQUIRED_LIBRARIES ${VORBISFILE_LIBRARIES} )
      check_c_source_compiles(
        "#include <vorbis/vorbisfile.h>
        int main() { ov_read_float(0,0,0); return 0; } "
        GSL_HAVE_OGGVORBIS_RC3 )
      if( NOT GSL_HAVE_OGGVORBIS_RC3 )
        set( GSL_HAVE_OGGVORBIS_RC3 0 )
      endif( NOT GSL_HAVE_OGGVORBIS_RC3 )
      set( CMAKE_REQUIRED_LIBRARIES ${bak_CMAKE_REQUIRED_LIBRARIES} )

    else( VORBISFILE_FOUND )

      message(FATAL_ERROR "\nOgg/Vorbis support are requested, but `libvorbisfile` not found" )

    endif( VORBISFILE_FOUND )

  else( VORBIS_FOUND )

    message(FATAL_ERROR "\nOgg/Vorbis support are requested, but `libvorbis` but found" )

  endif( VORBIS_FOUND )

endif( WITH_VORBIS )


##### check for libmad MPEG decoder #############

set( GSL_HAVE_LIBMAD 0 )
if( WITH_MAD )

  pkg_search_module( MAD mad )

  if( MAD_FOUND )
    set( GSL_HAVE_LIBMAD 1 )
  else( MAD_FOUND )
    message(FATAL_ERROR "\nMAD support are requested, but `libmad` not found" )
  endif( MAD_FOUND )

endif( WITH_MAD )


##### check for some type sizes #################

include( CheckTypeSize )

check_type_size( pthread_mutex_t GSL_SIZEOF_PTH_MUTEX_T )
check_type_size( pthread_cond_t GSL_SIZEOF_PTH_COND_T )
check_type_size( intmax_t GSL_SIZEOF_STD_INTMAX_T )

set( bak_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} )
set( CMAKE_REQUIRED_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} )
check_c_source_compiles(
  "#define _XOPEN_SOURCE 500
  #include <pthread.h>
  int main()
  {
      int (*attr_settype) (pthread_mutexattr_t *__attr, int __kind) = pthread_mutexattr_settype;
      int val = PTHREAD_MUTEX_RECURSIVE; attr_settype = 0; val = 0;
      return 0;
  }"
  GSL_HAVE_MUTEXATTR_SETTYPE )
  if( NOT GSL_HAVE_MUTEXATTR_SETTYPE )
    set( GSL_HAVE_MUTEXATTR_SETTYPE 0 )
  endif( NOT GSL_HAVE_MUTEXATTR_SETTYPE )
set( CMAKE_REQUIRED_LIBRARIES ${bak_CMAKE_REQUIRED_LIBRARIES} )

set( GSL_USE_GSL_GLIB 1 )
set( GSL_USE_ARTS_THREADS 1 )


##### write configuration #######################

configure_file( gslconfig.h.in gslconfig.h @ONLY )


##### compile ###################################

set( gsl_INCS
  ${CMAKE_CURRENT_BINARY_DIR}/gslconfig.h
  gslcommon.h
  gsldatacache.h
  gsldatahandle.h
  gsldefs.h
  gslloader.h
  gslmath.h
  gslfilter.h
  gsldatautils.h
  gsldatahandle-vorbis.h
  gslconvert.h
  gslfft.h
  gslieee754.h
  gslsignal.h
  gslmagic.h
  gslengine.h
  gslwaveosc.h
  gslwavechunk.h
  gsldatahandle-mad.h
  gslosctable.h
  gsloscillator.h
)

set( gsl_SRCS
  gsldatacache.c
  gsldatahandle.c
  gslwavechunk.c
  gsldatahandle-vorbis.c
  gslmath.c
  gslfilter.c
  gslcommon.c
  gsldatautils.c
  gslmagic.c
  gslloader-wav.c
  gslloader-gslwave.c
  gslloader-mad.c
  gslloader-oggvorbis.c
  gslconvert.c
  gslfft.c
  gslsignal.c
  gslloader.c
  gslwaveosc.c
  gslengine.c
  gsloputil.c
  gslopmaster.c
  gslopschedule.c
  gsldatahandle-mad.c
  gslosctable.c
  gsloscillator.c
  gslfilehash.c
  gslartsthreads.cc
)

include_directories(
  ${CMAKE_BINARY_DIR}
  ${CMAKE_BINARY_DIR}/mcop
  ${CMAKE_SOURCE_DIR}/mcop # for thread.h
  ${CMAKE_CURRENT_BINARY_DIR}/.. # for gsl/gslconfig.h
  ${CMAKE_CURRENT_SOURCE_DIR}/.. # for gsl/gslcommon.h
  ${GLIB2_INCLUDE_DIRS}
)

add_library( gsl STATIC ${gsl_SRCS} )
set_target_properties( gsl PROPERTIES COMPILE_FLAGS -fPIC )
target_link_libraries( gsl ${GLIB2_LIBRARIES} ${GTHREAD2_LIBRARIES} ${VORBISFILE_LIBRARIES} ${MAD_LIBRARIES} )


##### install ###################################

install( FILES ${gsl_INCS} DESTINATION ${INCLUDE_INSTALL_DIR}/gsl )