CMakeLists.txt 7.92 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 )
Jonas Stienen's avatar
Jonas Stienen committed
15

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


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

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" )
28
endif( )
Jonas Stienen's avatar
Jonas Stienen committed
29 30 31

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" )
32
endif( )
Jonas Stienen's avatar
Jonas Stienen committed
33

34 35 36 37
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
38
if( NOT DEFINED ITA_BASE_WITH_OLD_ATOMICS )
39
	set( ITA_BASE_WITH_OLD_ATOMICS OFF CACHE BOOL "Build with old atomic code for non-C++11 compatible compilers" )
40
endif( )
Jonas Stienen's avatar
Jonas Stienen committed
41 42

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

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

50
if( NOT DEFINED ITA_BASE_WITH_OLD_RAVEN_OPS )
51
	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!)" )
52
endif( )
53

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

Jonas Stienen's avatar
Jonas Stienen committed
58 59 60 61 62 63 64

# includes
include_directories( "include" )


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

js908001's avatar
js908001 committed
135 136 137

# Win32 implementations
if( WIN32 )
Jonas Stienen's avatar
Jonas Stienen committed
138 139
	list( APPEND ITABaseHeader "include/ITAHPT.h" "include/ITAMutex.h" "include/ITATimer.h" )
	list( APPEND ITABaseSources "src/ITAHPT.cpp" "src/ITAMutex.cpp" "src/ITATimer.cpp" )
140
else( )
Fabian Schlieper's avatar
Fabian Schlieper committed
141 142 143
	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" )
144
endif( )
Jonas Stienen's avatar
Jonas Stienen committed
145

Jonas Stienen's avatar
Jonas Stienen committed
146 147 148 149 150 151 152 153 154 155 156 157 158
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"
		)
159
		add_definitions( -DITABASE_WITH_SNDFILE )
160
endif( )
Jonas Stienen's avatar
Jonas Stienen committed
161

162 163 164 165 166
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
167 168 169 170
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
171
else( )
Jonas Stienen's avatar
Jonas Stienen committed
172
	set( ITABaseSources "${ITABaseSources}" "src/ITAFastMathImpl.cpp" )
173
endif( )
Jonas Stienen's avatar
Jonas Stienen committed
174 175

if( ITA_BASE_WITH_OLD_ATOMICS )
176
	set( ITABaseHeader "${ITABaseHeader}" "include/ITAAtomicOps.h" "include/ITAAtomicPrimitives.h" )
Jonas Stienen's avatar
Jonas Stienen committed
177 178
	if( WIN32 )
		set( ITABaseSources "${ITABaseSources}" "src/ITAAtomicOpsWin32Impl.cpp" )
179
	else( )
Jonas Stienen's avatar
Jonas Stienen committed
180
		set( ITABaseSources "${ITABaseSources}" "src/ITAAtomicOpsGCCBuiltinsImpl.cpp" )
181 182
	endif( )
endif( )
Jonas Stienen's avatar
Jonas Stienen committed
183

184
if( ITA_BASE_WITH_OLD_RAVEN_OPS )
185 186
	if( NOT ITA_BASE_WITH_CONFIG_OLD_IMPL )
		message( FATAL_ERROR "ITABase old RAVEN ops requires regular expressions and old config implementation. Please activate." )
187
	endif( )
188 189 190
	if( NOT VSPLINE_FOUND )
		message( FATAL_ERROR "ITABase old RAVEN ops requires SPLINE, which was not found. Please provide." )
	endif( )
191 192
	set( ITABaseHeader "${ITABaseHeader}" "include/ITAOps.h" )
	set( ITABaseSources "${ITABaseSources}" "src/ITAOps.cpp" )
193
endif( )
194

Jonas Stienen's avatar
Jonas Stienen committed
195 196
if( VPCRE_FOUND AND ITA_BASE_WITH_REGULAR_EXPRESSIONS )
	add_definitions( -DPCRE_STATIC )
197 198
	list( APPEND ITABaseHeaders "include/ITAASCIITable.h" )
	list( APPEND ITABaseSources "src/ITAStringUtilsPCRE.cpp" "src/ITAASCIITable.cpp" )
199
else( )
200
	list( APPEND ITABaseSources "src/ITAStringUtils.cpp" )
201
endif( )
Jonas Stienen's avatar
Jonas Stienen committed
202 203 204 205

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." )
206
	endif( )
207 208
	list( APPEND ITABaseHeader "include/ITAConfigUtils.h" )
	list( APPEND ITABaseSources "src/ITAConfigUtils.cpp" "src/ITAConfigUtilsWin32Impl.cpp" )
209
endif( )
210

211

212 213
# preprocessor
if( BUILD_SHARED_LIBS )
214
	add_definitions( -DITA_BASE_EXPORT )
215
else( )
216
	add_definitions( -DITA_BASE_STATIC )
217
endif( )
Jonas Stienen's avatar
Jonas Stienen committed
218

219 220
if( ITA_VISTA_BUILD_STATIC )
	add_definitions( -DVISTABASE_STATIC -DVISTAMATH_STATIC -DVISTAASPECTS_STATIC -DVISTATOOLS_STATIC -DVISTAINTERPROCCOMM_STATIC )
221 222 223
	if( WIN32 )
		list( APPEND VISTA_USE_PACKAGE_LIBRARIES Ws2_32 )
	endif( )
224
endif( )
Jonas Stienen's avatar
Jonas Stienen committed
225

Fabian Schlieper's avatar
Fabian Schlieper committed
226 227
if( NOT WIN32 )
	add_definitions( -std=gnu++11 )
228 229
endif( )

Fabian Schlieper's avatar
Fabian Schlieper committed
230

Jonas Stienen's avatar
Jonas Stienen committed
231
# linker
232
add_library( ITABase ${ITABaseHeader} ${ITABaseSources} )
Jonas Stienen's avatar
Jonas Stienen committed
233 234 235 236 237 238 239 240 241 242 243 244 245 246
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
247 248 249
if( ITA_CORE_LIBS_WITH_TESTS )
	set( ITABASE_COMMON_BUILD TRUE )
	add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/tests" )
250
endif( )