CMakeLists.txt 8.35 KB
Newer Older
Jonas Stienen's avatar
Jonas Stienen committed
1 2 3 4 5 6 7 8
cmake_minimum_required( VERSION 2.8 )

project( ITABase )

list( APPEND CMAKE_MODULE_PATH "$ENV{VISTA_CMAKE_COMMON}" )
include( VistaCommon )

# dependencies
9
vista_use_package( VistaCoreLibs REQUIRED COMPONENTS VistaBase VistaInterProcComm VistaTools FIND_DEPENDENCIES )
Jonas Stienen's avatar
Jonas Stienen committed
10
vista_use_package( sndfile )
11
vista_use_package( samplerate )
Jonas Stienen's avatar
Jonas Stienen committed
12 13
vista_use_package( IPP QUIET )
vista_use_package( SimpleIni QUIET )
14
vista_use_package( SPLINE REQUIRED )
15
vista_find_package( libjson OPTIONAL QUIET )
Jonas Stienen's avatar
Jonas Stienen committed
16

Marco Berzborn's avatar
Marco Berzborn committed
17 18 19 20 21 22
if ( NOT WIN32 )
	vista_use_package ( Threads REQUIRED )
	list ( APPEND VISTA_USE_PACKAGE_LIBRARIES pthread )
endif ()


Jonas Stienen's avatar
Jonas Stienen committed
23
if( NOT DEFINED ITA_BASE_WITH_FASTMATH_IPP )
24
	set( ITA_BASE_WITH_FASTMATH_IPP OFF CACHE BOOL "Build with IPP implementation of fast math ops (requires license for redistribution)" )
25
endif( )
Jonas Stienen's avatar
Jonas Stienen committed
26 27 28

if( NOT DEFINED ITA_BASE_WITH_FASTMATH_ASSEMBLER )
	set( ITA_BASE_WITH_FASTMATH_ASSEMBLER OFF CACHE BOOL "Build with assembler implementation of fast math ops" )
29
endif( )
Jonas Stienen's avatar
Jonas Stienen committed
30 31 32

if( NOT DEFINED ITA_BASE_WITH_SNDFILE )
	set( ITA_BASE_WITH_SNDFILE ON CACHE BOOL "Build with libsndfile to read/write audio samples for ITASampleFrame" )
33
endif( )
Jonas Stienen's avatar
Jonas Stienen committed
34

35 36 37 38
if( NOT DEFINED ITA_BASE_WITH_SAMPLERATE )
	set( ITA_BASE_WITH_SAMPLERATE ON CACHE BOOL "Build with libsamplerate to auto-convert between samplerates" )
endif( )

Jonas Stienen's avatar
Jonas Stienen committed
39
if( NOT DEFINED ITA_BASE_WITH_OLD_ATOMICS )
40
	set( ITA_BASE_WITH_OLD_ATOMICS OFF CACHE BOOL "Build with old atomic code for non-C++11 compatible compilers" )
41
endif( )
Jonas Stienen's avatar
Jonas Stienen committed
42 43

if( NOT DEFINED ITA_BASE_WITH_REGULAR_EXPRESSIONS )
44
	set( ITA_BASE_WITH_REGULAR_EXPRESSIONS OFF CACHE BOOL "Build with old regular expressions code for string manipulation" )
45
endif( )
Jonas Stienen's avatar
Jonas Stienen committed
46 47

if( NOT DEFINED ITA_BASE_WITH_CONFIG_OLD_IMPL )
48
	set( ITA_BASE_WITH_CONFIG_OLD_IMPL OFF CACHE BOOL "Build with old INI file configuration implementation (uses legacy regular expressions)" )
49
endif( )
Jonas Stienen's avatar
Jonas Stienen committed
50

51
if( NOT DEFINED ITA_BASE_WITH_OLD_RAVEN_OPS )
52
	set( ITA_BASE_WITH_OLD_RAVEN_OPS OFF CACHE BOOL "Build with old ITAOps helper functions implementation (legacy code for RAVEN compatibility, adds GPL-licensed libs!)" )
53
endif( )
54

55 56 57 58
if( ITA_BASE_WITH_REGULAR_EXPRESSIONS )
	vista_use_package( PCRE QUIET )
endif( )

59 60 61 62 63
if( NOT DEFINED ITA_BASE_WITH_JSON_SUPPORT )
	set( ITA_BASE_WITH_JSON_SUPPORT ${LIBJSON_FOUND} CACHE BOOL "Build ITA Base with JSON support" )
endif( )


Jonas Stienen's avatar
Jonas Stienen committed
64 65 66 67 68 69 70

# includes
include_directories( "include" )


# files
set( ITABaseHeader
71
	"include/ITAAudioSample.h"
Jonas Stienen's avatar
Jonas Stienen committed
72
	"include/ITABaseDefinitions.h"
73
	"include/ITABlockMath.h"
Jonas Stienen's avatar
Jonas Stienen committed
74 75 76 77 78
	"include/ITABufferedAudioFileWriter.h"
	"include/ITAClock.h"
	"include/ITAConstants.h"
	"include/ITACriticalSection.h"
	"include/ITADataLog.h"
79
	"include/ITADebug.h"
Jonas Stienen's avatar
Jonas Stienen committed
80 81 82 83 84
	"include/ITAEndianness.h"
	"include/ITAException.h"
	"include/ITAFade.h"
	"include/ITAFastMath.h"
	"include/ITAFileSystemUtils.h"
85
	"include/ITAFiniteImpulseResponse.h"
86
	"include/ITAFunctors.h"
87
	"include/ITAHDFTSpectra.h"
Jonas Stienen's avatar
Jonas Stienen committed
88
	"include/ITAHDFTSpectrum.h"
89
	"include/ITAInterpolation.h"
90
	"include/ITAISO9613.h"
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
91
	"include/ITALog.h"
92
	"include/ITAMagnitudeSpectrum.h"
93
	"include/ITAMultichannelFiniteImpulseResponse.h"
Jonas Stienen's avatar
Jonas Stienen committed
94 95 96 97
	"include/ITANumericUtils.h"
	"include/ITASampleBuffer.h"
	"include/ITASampleFrame.h"
	"include/ITASampleTypeConversion.h"
98
	"include/ITASimpleConvolution.h"
99
	"include/ITASpectrum.h"
Jonas Stienen's avatar
Jonas Stienen committed
100 101
	"include/ITAStopWatch.h"
	"include/ITAStringUtils.h"
102
	"include/ITAThirdOctaveMagnitudeSpectrum.h"
Jonas Stienen's avatar
Jonas Stienen committed
103 104 105
	"include/ITATimeSeriesAnalyzer.h"
	"include/ITATypes.h"
	"include/ITAUncopyable.h"
106
	"include/ITAWholeOctaveMagnitudeSpectrum.h"
Jonas Stienen's avatar
Jonas Stienen committed
107 108 109
	"include/ITAWinPCClock.h"
	)
set( ITABaseSources
110
	"src/ITABlockMath.cpp"
Jonas Stienen's avatar
Jonas Stienen committed
111 112 113 114 115 116
	"src/ITABufferedAudioFileWriter.cpp"
	"src/ITAClock.cpp"
	"src/ITACriticalSection.cpp"
	"src/ITACriticalSectionImpl.h"
	"src/ITACriticalSectionPosixImpl.h"
	"src/ITACriticalSectionWin32Impl.h"
117
	"src/ITADebug.cpp"
Jonas Stienen's avatar
Jonas Stienen committed
118 119 120 121
	"src/ITAEndianness.cpp"
	"src/ITAException.cpp"
	"src/ITAFade.cpp"
	"src/ITAFileSystemUtils.cpp"
122
	"src/ITAFiniteImpulseResponse.cpp"
123
	"src/ITAHDFTSpectra.cpp"
Jonas Stienen's avatar
Jonas Stienen committed
124
	"src/ITAHDFTSpectrum.cpp"
125
	"src/ITAInterpolation.cpp"
126
	"src/ITAISO9613.cpp"
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
127
	"src/ITALog.cpp"
128
	"src/ITAMagnitudeSpectrum.cpp"
129
	"src/ITAMultichannelFiniteImpulseResponse.cpp"
Jonas Stienen's avatar
Jonas Stienen committed
130 131 132 133
	"src/ITANumericUtils.cpp"
	"src/ITASampleBuffer.cpp"
	"src/ITASampleFrame.cpp"
	"src/ITASampleTypeConversion.cpp"
134
	"src/ITASimpleConvolution.cpp"
135
	"src/ITASpectrum.cpp"
Jonas Stienen's avatar
Jonas Stienen committed
136
	"src/ITAStopWatch.cpp"
137
	"src/ITATypes.cpp"
Jonas Stienen's avatar
Jonas Stienen committed
138 139 140
	"src/ITAWinPCClock.cpp"
	)

js908001's avatar
js908001 committed
141

142 143 144 145 146 147 148 149
if( ITA_BASE_WITH_JSON_SUPPORT )
	vista_use_package( libjson REQUIRED )
	add_definitions( -DWITH_JSON_SUPPORT )
	list( APPEND ITABaseHeader "include/ITABase/UtilsJSON.h" )
	list( APPEND ITABaseSources "src/ITABase/UtilsJSON.cpp" )
endif( )


js908001's avatar
js908001 committed
150 151
# Win32 implementations
if( WIN32 )
Jonas Stienen's avatar
Jonas Stienen committed
152 153
	list( APPEND ITABaseHeader "include/ITAHPT.h" "include/ITAMutex.h" "include/ITATimer.h" )
	list( APPEND ITABaseSources "src/ITAHPT.cpp" "src/ITAMutex.cpp" "src/ITATimer.cpp" )
154
else( )
Fabian Schlieper's avatar
Fabian Schlieper committed
155 156 157
	add_definitions( -DUSE_SIMPLEINI )
	list( APPEND ITABaseSources "src/ITAPosixRealtimeClock.cpp" "src/simpleini/SimpleIni.h" "src/simpleini/ConvertUTF.h" "src/simpleini/ConvertUTF.c"  )
	list( APPEND ITABaseSources "src/ITAConfigUtilsSimpleIniImpl.cpp" )
158
endif( )
Jonas Stienen's avatar
Jonas Stienen committed
159

Jonas Stienen's avatar
Jonas Stienen committed
160 161 162 163 164 165 166 167 168 169 170 171 172
if( VSNDFILE_FOUND AND ITA_BASE_WITH_SNDFILE  )
	set( ITABaseHeader "${ITABaseHeader}"
		"include/ITAAudiofileCommon.h"
		"include/ITAAudiofileReader.h"
		"include/ITAAudiofileWriter.h"
		)
	set( ITABaseSources "${ITABaseSources}" 
		"src/ITAAudiofileCommon.cpp"
		"src/ITAAudiofileReader.cpp"
		"src/ITAAudiofileWriter.cpp"
		"src/libsndfileAudiofileReader.cpp"
		"src/libsndfileAudiofileWriter.cpp"
		)
173
		add_definitions( -DITABASE_WITH_SNDFILE )
174
endif( )
Jonas Stienen's avatar
Jonas Stienen committed
175

176 177 178 179 180
if( VSAMPLERATE_FOUND AND ITA_BASE_WITH_SAMPLERATE )
	set( ITABaseHeader "${ITABaseHeader}" "include/ITAAudioSample.h" )
	set( ITABaseSources "${ITABaseSources}" "src/ITAAudioSample.cpp" )
endif( )

Jonas Stienen's avatar
Jonas Stienen committed
181 182 183 184
if( VIPP_FOUND AND ITA_BASE_WITH_FASTMATH_IPP )
	set( ITABaseSources "${ITABaseSources}" "src/ITAFastMathImplIPP.cpp" )
elseif( ITA_BASE_WITH_FASTMATH_ASSEMBLER )
	set( ITABaseSources "${ITABaseSources}" "src/ITAFastMathImplAssembler.cpp" ) # not recommended
185
else( )
Jonas Stienen's avatar
Jonas Stienen committed
186
	set( ITABaseSources "${ITABaseSources}" "src/ITAFastMathImpl.cpp" )
187
endif( )
Jonas Stienen's avatar
Jonas Stienen committed
188 189

if( ITA_BASE_WITH_OLD_ATOMICS )
190
	set( ITABaseHeader "${ITABaseHeader}" "include/ITAAtomicOps.h" "include/ITAAtomicPrimitives.h" )
Jonas Stienen's avatar
Jonas Stienen committed
191 192
	if( WIN32 )
		set( ITABaseSources "${ITABaseSources}" "src/ITAAtomicOpsWin32Impl.cpp" )
193
	else( )
Jonas Stienen's avatar
Jonas Stienen committed
194
		set( ITABaseSources "${ITABaseSources}" "src/ITAAtomicOpsGCCBuiltinsImpl.cpp" )
195 196
	endif( )
endif( )
Jonas Stienen's avatar
Jonas Stienen committed
197

198
if( ITA_BASE_WITH_OLD_RAVEN_OPS )
199 200
	if( NOT ITA_BASE_WITH_CONFIG_OLD_IMPL )
		message( FATAL_ERROR "ITABase old RAVEN ops requires regular expressions and old config implementation. Please activate." )
201
	endif( )
202 203 204
	if( NOT VSPLINE_FOUND )
		message( FATAL_ERROR "ITABase old RAVEN ops requires SPLINE, which was not found. Please provide." )
	endif( )
205 206
	set( ITABaseHeader "${ITABaseHeader}" "include/ITAOps.h" )
	set( ITABaseSources "${ITABaseSources}" "src/ITAOps.cpp" )
207
endif( )
208

Jonas Stienen's avatar
Jonas Stienen committed
209 210
if( VPCRE_FOUND AND ITA_BASE_WITH_REGULAR_EXPRESSIONS )
	add_definitions( -DPCRE_STATIC )
211 212
	list( APPEND ITABaseHeaders "include/ITAASCIITable.h" )
	list( APPEND ITABaseSources "src/ITAStringUtilsPCRE.cpp" "src/ITAASCIITable.cpp" )
213
else( )
214
	list( APPEND ITABaseSources "src/ITAStringUtils.cpp" )
215
endif( )
Jonas Stienen's avatar
Jonas Stienen committed
216 217 218 219

if( ITA_BASE_WITH_CONFIG_OLD_IMPL AND NOT ITA_BASE_WITH_CONFIG_SIMPLE_INI )
	if( NOT ITA_BASE_WITH_REGULAR_EXPRESSIONS )
		message( FATAL_ERROR "ITABase old config implementation requires regular expressions. Please activate." )
220
	endif( )
221 222
	list( APPEND ITABaseHeader "include/ITAConfigUtils.h" )
	list( APPEND ITABaseSources "src/ITAConfigUtils.cpp" "src/ITAConfigUtilsWin32Impl.cpp" )
223
endif( )
224

225

226 227
# preprocessor
if( BUILD_SHARED_LIBS )
228
	add_definitions( -DITA_BASE_EXPORT )
229
else( )
230
	add_definitions( -DITA_BASE_STATIC )
231
endif( )
Jonas Stienen's avatar
Jonas Stienen committed
232

233 234
if( ITA_VISTA_BUILD_STATIC )
	add_definitions( -DVISTABASE_STATIC -DVISTAMATH_STATIC -DVISTAASPECTS_STATIC -DVISTATOOLS_STATIC -DVISTAINTERPROCCOMM_STATIC )
235 236 237
	if( WIN32 )
		list( APPEND VISTA_USE_PACKAGE_LIBRARIES Ws2_32 )
	endif( )
238
endif( )
Jonas Stienen's avatar
Jonas Stienen committed
239

Fabian Schlieper's avatar
Fabian Schlieper committed
240 241
if( NOT WIN32 )
	add_definitions( -std=gnu++11 )
242 243
endif( )

Fabian Schlieper's avatar
Fabian Schlieper committed
244

Jonas Stienen's avatar
Jonas Stienen committed
245
# linker
246
add_library( ITABase ${ITABaseHeader} ${ITABaseSources} )
Jonas Stienen's avatar
Jonas Stienen committed
247 248 249 250 251 252 253 254 255 256 257 258 259 260
target_link_libraries( ITABase ${VISTA_USE_PACKAGE_LIBRARIES} )


# configure
vista_configure_lib( ITABase )
vista_install( ITABase )
set( ITABASE_INCLUDE_OUTDIR "${CMAKE_CURRENT_SOURCE_DIR}/include" )
vista_create_cmake_configs( ITABase )
vista_create_default_info_file( ITABase )

set_property( TARGET ITABase PROPERTY FOLDER "ITACoreLibs" )


# tests
261 262 263
if( ITA_CORE_LIBS_WITH_TESTS )
	set( ITABASE_COMMON_BUILD TRUE )
	add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/tests" )
264
endif( )