CMakeLists.txt 28.6 KB
Newer Older
1
############################################################################
Ghislain MARY's avatar
Ghislain MARY committed
2
# CMakeLists.txt
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
# Copyright (C) 2014  Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
############################################################################

include(ExternalProject)

25
set(ep_base "${LINPHONE_BUILDER_WORK_DIR}/${CONFIG_NAME}")
26 27
set_property(DIRECTORY PROPERTY EP_BASE ${ep_base})

28

29 30 31
# Define the architecture. It will be used to generate the URL to get prebuilt dependencies.
if(WIN32)
	set(LINPHONE_BUILDER_ARCHITECTURE "Win32")
32 33 34 35
elseif(UNIX)
	if(APPLE)
		set(LINPHONE_BUILDER_ARCHITECTURE "OsX64")
	endif()
36 37 38
endif()


39
if(CMAKE_VERBOSE_MAKEFILE)
40
	set(AUTOTOOLS_VERBOSE_MAKEFILE 1)
41
else()
42
	set(AUTOTOOLS_VERBOSE_MAKEFILE 0)
43
endif()
44 45


Ghislain MARY's avatar
Ghislain MARY committed
46 47
# Check for build tools and show an error if one of them is not present
include(cmake/CheckBuildTools.cmake)
48

49

50
set(LINPHONE_BUILDER_EP_VARS)
51
set(LINPHONE_BUILDER_INCLUDED_BUILDERS)
52
set(LINPHONE_BUILDER_EXTERNAL_SOURCE_PATH_BUILDERS)
53 54

macro(linphone_builder_expand_external_project_vars)
Ghislain MARY's avatar
Ghislain MARY committed
55 56 57 58 59 60 61 62 63 64
	set(LINPHONE_BUILDER_EP_ARGS "")
	set(LINPHONE_BUILDER_EP_VARNAMES "")
	foreach(arg ${LINPHONE_BUILDER_EP_VARS})
		string(REPLACE ":" ";" varname_and_vartype ${arg})
		set(target_info_list ${target_info_list})
		list(GET varname_and_vartype 0 _varname)
		list(GET varname_and_vartype 1 _vartype)
		list(APPEND LINPHONE_BUILDER_EP_ARGS -D${_varname}:${_vartype}=${${_varname}})
		list(APPEND LINPHONE_BUILDER_EP_VARNAMES ${_varname})
	endforeach()
65
endmacro()
66 67 68 69

list(APPEND LINPHONE_BUILDER_EP_VARS
	CMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH
	CMAKE_BUILD_TYPE:STRING
70
	CMAKE_BUILD_WITH_INSTALL_RPATH:BOOL
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
	CMAKE_BUNDLE_OUTPUT_DIRECTORY:PATH
	CMAKE_C_FLAGS_DEBUG:STRING
	CMAKE_C_FLAGS_MINSIZEREL:STRING
	CMAKE_C_FLAGS_RELEASE:STRING
	CMAKE_C_FLAGS_RELWITHDEBINFO:STRING
	CMAKE_C_FLAGS:STRING
	CMAKE_CXX_FLAGS_DEBUG:STRING
	CMAKE_CXX_FLAGS_MINSIZEREL:STRING
	CMAKE_CXX_FLAGS_RELEASE:STRING
	CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING
	CMAKE_CXX_FLAGS:STRING
	CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING
	CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING
	CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING
	CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING
	CMAKE_EXE_LINKER_FLAGS:STRING
	CMAKE_EXTRA_GENERATOR:STRING
88
	CMAKE_GENERATOR_PLATFORM:STRING
89
	CMAKE_INSTALL_PREFIX:PATH
90 91
	CMAKE_INSTALL_RPATH:PATH
	CMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL
92 93 94 95 96 97 98
	CMAKE_LIBRARY_OUTPUT_DIRECTORY:PATH
	CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING
	CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING
	CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING
	CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING
	CMAKE_MODULE_LINKER_FLAGS:STRING
	CMAKE_MODULE_PATH:PATH
99
	CMAKE_NO_BUILD_TYPE:BOOL
100
	CMAKE_PREFIX_PATH:STRING
101 102 103 104 105 106 107
	CMAKE_RUNTIME_OUTPUT_DIRECTORY:PATH
	CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING
	CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING
	CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING
	CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING
	CMAKE_SHARED_LINKER_FLAGS:STRING
	CMAKE_SKIP_RPATH:BOOL
108
	CMAKE_SKIP_BUILD_RPATH:BOOL
109
	CMAKE_VERBOSE_MAKEFILE:BOOL
110 111 112
	MSVC_C_ARCHITECTURE_ID:STRING
	MSVC_CXX_ARCHITECTURE_ID:STRING
	MSVC_VERSION:STRING
113
)
114
if(CMAKE_CROSSCOMPILING)
Ghislain MARY's avatar
Ghislain MARY committed
115
	list(APPEND LINPHONE_BUILDER_EP_VARS
116 117 118 119
		CMAKE_SYSTEM_NAME:STRING
		CMAKE_SYSTEM_VERSION:STRING
	)
endif()
120 121
if(APPLE)
	list(APPEND LINPHONE_BUILDER_EP_VARS
122
		CMAKE_MACOSX_RPATH:BOOL
123 124 125
		CMAKE_OSX_ARCHITECTURES:STRING
		CMAKE_OSX_DEPLOYMENT_TARGET:STRING
	)
126
endif()
127 128 129
if(CMAKE_TOOLCHAIN_FILE)
	list(APPEND LINPHONE_BUILDER_EP_VARS CMAKE_TOOLCHAIN_FILE:PATH)
endif()
130 131


132 133 134 135 136 137 138 139 140 141
function(linphone_builder_get_autotools_configuration)
	if(MSVC)
		set(_generator "MinGW Makefiles")
	else()
		set(_generator "${CMAKE_GENERATOR}")
	endif()
	set(_autotools_command ${CMAKE_COMMAND} -G "${_generator}")
	if(CMAKE_TOOLCHAIN_FILE)
		list(APPEND _autotools_command "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
	endif()
142 143 144
	if(LINPHONE_BUILDER_OSX_ARCHITECTURES)
		list(APPEND _autotools_command "-DLINPHONE_BUILDER_OSX_ARCHITECTURES=${LINPHONE_BUILDER_OSX_ARCHITECTURES}")
	endif()
145
	list(APPEND _autotools_command "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Autotools/")
146 147
	execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/Autotools)
	execute_process(COMMAND ${_autotools_command} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/Autotools)
148 149 150
	unset(_autotools_command)
	unset(_extra_generator)
	unset(_generator)
151
	include(${CMAKE_BINARY_DIR}/Autotools/Autotools.cmake)
Ghislain MARY's avatar
Ghislain MARY committed
152
endfunction()
153 154


155 156 157 158 159 160 161 162 163 164 165 166
macro(linphone_builder_create_targets_list)
	set(LINPHONE_BUILDER_TARGETS )
	if("${LINPHONE_BUILDER_TARGET}" STREQUAL "belle-sip")
		list(APPEND LINPHONE_BUILDER_TARGETS "belle-sip")
	elseif("${LINPHONE_BUILDER_TARGET}" STREQUAL "ortp")
		list(APPEND LINPHONE_BUILDER_TARGETS "ortp")
	elseif("${LINPHONE_BUILDER_TARGET}" STREQUAL "ms2")
		list(APPEND LINPHONE_BUILDER_TARGETS "ortp" "ms2")
	elseif("${LINPHONE_BUILDER_TARGET}" STREQUAL "ms2-plugins")
		list(APPEND LINPHONE_BUILDER_TARGETS "ortp" "ms2" "ms2-plugins")
	elseif("${LINPHONE_BUILDER_TARGET}" STREQUAL "linphone")
		list(APPEND LINPHONE_BUILDER_TARGETS "belle-sip" "ortp" "ms2" "ms2-plugins" "linphone")
Guillaume BIENKOWSKI's avatar
Guillaume BIENKOWSKI committed
167
	elseif("${LINPHONE_BUILDER_TARGET}" STREQUAL "flexisip")
168
		list(APPEND LINPHONE_BUILDER_TARGETS "ortp" "flexisip")
169 170
	elseif("${LINPHONE_BUILDER_TARGET}" STREQUAL "odb")
		list(APPEND LINPHONE_BUILDER_TARGETS "odb" )
171 172 173
	else()
		message(FATAL_ERROR "Invalid LINPHONE_BUILDER_TARGET '${LINPHONE_BUILDER_TARGET}'")
	endif()
Ghislain MARY's avatar
Ghislain MARY committed
174
endmacro()
175 176 177 178 179 180 181 182 183 184


macro(linphone_builder_include_builder BUILDER)
	list(FIND LINPHONE_BUILDER_INCLUDED_BUILDERS ${BUILDER} _already_included)
	if(_already_included EQUAL -1)
		message(STATUS "Including builder ${BUILDER}")
		include(${CMAKE_CURRENT_SOURCE_DIR}/builders/${BUILDER}.cmake)
		list(APPEND LINPHONE_BUILDER_INCLUDED_BUILDERS ${BUILDER})
	endif()
	unset(_already_included)
Ghislain MARY's avatar
Ghislain MARY committed
185
endmacro()
186 187 188 189


macro(linphone_builder_add_builder_to_target TARGETNAME BUILDER)
	linphone_builder_include_builder(${BUILDER})
190 191
	if(LINPHONE_BUILDER_BUILD_ONLY_EXTERNAL_SOURCE_PATH AND LINPHONE_BUILDER_EXTERNAL_SOURCE_PATH)
		foreach(SUBDIR ${EP_${BUILDER}_EXTERNAL_SOURCE_PATHS})
192 193
			set(_source_dir "${LINPHONE_BUILDER_EXTERNAL_SOURCE_PATH}/${SUBDIR}")
			if(EXISTS "${_source_dir}")
194 195
				message(STATUS "${TARGETNAME} depends on external source path ${LINPHONE_BUILDER_EXTERNAL_SOURCE_PATH}/${SUBDIR}")
				set(_build_from_external_source_path 1)
196
				break()
197 198 199 200 201 202
			endif()
		endforeach()
		if(_build_from_external_source_path)
			list(FIND LINPHONE_BUILDER_EXTERNAL_SOURCE_PATH_BUILDERS ${BUILDER} _already_included)
			if(_already_included EQUAL -1)
				message(STATUS "add external source path builder ${BUILDER}")
203 204
				set(EP_${BUILDER}_SOURCE_DIR "${_source_dir}")
				list(APPEND LINPHONE_BUILDER_EXTERNAL_SOURCE_PATH_BUILDERS ${BUILDER})
205 206 207 208 209 210 211 212 213 214
			endif()
			unset(_already_included)
		else()
			list(REMOVE_ITEM LINPHONE_BUILDER_INCLUDED_BUILDERS ${BUILDER})
		endif()
		unset(_build_from_external_source_path)
	else()
		message(STATUS "${TARGETNAME} depends on external project EP_${BUILDER}")
		add_dependencies(${TARGETNAME} EP_${BUILDER})
	endif()
Ghislain MARY's avatar
Ghislain MARY committed
215
endmacro()
216 217


218
macro(linphone_builder_apply_flags)
219
	foreach(BUILD_CONFIG "" "_DEBUG" "_MINSIZEREL" "_RELEASE" "_RELWITHDEBINFO")
220 221 222
		if(NOT "${LINPHONE_BUILDER_CPPFLAGS}" STREQUAL "")
			set(CMAKE_C_FLAGS${BUILD_CONFIG} "${CMAKE_C_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_CPPFLAGS}")
			set(CMAKE_CXX_FLAGS${BUILD_CONFIG} "${CMAKE_CXX_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_CPPFLAGS}")
223 224
			set(AUTOTOOLS_C_FLAGS${BUILD_CONFIG} "${AUTOTOOLS_C_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_CPPFLAGS}")
			set(AUTOTOOLS_CXX_FLAGS${BUILD_CONFIG} "${AUTOTOOLS_CXX_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_CPPFLAGS}")
Ghislain MARY's avatar
Ghislain MARY committed
225
		endif()
226 227
		if(NOT "${LINPHONE_BUILDER_CFLAGS}" STREQUAL "")
			set(CMAKE_C_FLAGS${BUILD_CONFIG} "${CMAKE_C_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_CFLAGS}")
228
			set(AUTOTOOLS_C_FLAGS${BUILD_CONFIG} "${AUTOTOOLS_C_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_CFLAGS}")
Ghislain MARY's avatar
Ghislain MARY committed
229
		endif()
230 231
		if(NOT "${LINPHONE_BUILDER_CXXFLAGS}" STREQUAL "")
			set(CMAKE_CXX_FLAGS${BUILD_CONFIG} "${CMAKE_CXX_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_CXXFLAGS}")
232
			set(AUTOTOOLS_CXX_FLAGS${BUILD_CONFIG} "{AUTOTOOLS_CXX_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_CXX_FLAGS}")
Ghislain MARY's avatar
Ghislain MARY committed
233
		endif()
Ghislain MARY's avatar
Ghislain MARY committed
234 235 236
		if(NOT "${LINPHONE_BUILDER_OBJCFLAGS}" STREQUAL "")
			set(CMAKE_C_FLAGS${BUILD_CONFIG} "${CMAKE_C_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_OBJCFLAGS}")
			set(AUTOTOOLS_OBJC_FLAGS${BUILD_CONFIG} "${AUTOTOOLS_OBJC_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_OBJCFLAGS}")
Ghislain MARY's avatar
Ghislain MARY committed
237
		endif()
238
		if(NOT "${LINPHONE_BUILDER_LDFLAGS}" STREQUAL "")
239
			# TODO: The two following lines should not be here
240 241
			set(CMAKE_C_FLAGS${BUILD_CONFIG} "${CMAKE_C_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_LDFLAGS}")
			set(CMAKE_CXX_FLAGS${BUILD_CONFIG} "${CMAKE_CXX_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_LDFLAGS}")
242

243 244 245
			set(CMAKE_EXE_LINKER_FLAGS${BUILD_CONFIG} "${CMAKE_EXE_LINKER_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_LDFLAGS}")
			set(CMAKE_MODULE_LINKER_FLAGS${BUILD_CONFIG} "${CMAKE_MODULE_LINKER_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_LDFLAGS}")
			set(CMAKE_SHARED_LINKER_FLAGS${BUILD_CONFIG} "${CMAKE_SHARED_LINKER_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_LDFLAGS}")
246
			set(AUTOTOOLS_LINKER_FLAGS${BUILD_CONFIG} "${AUTOTOOLS_LINKER_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_LDFLAGS}")
Ghislain MARY's avatar
Ghislain MARY committed
247 248 249
		endif()
	endforeach()
endmacro()
250 251


252
macro(linphone_builder_apply_cmake_flags_to_autotools_project PROJNAME)
253
	if("${EP_${PROJNAME}_BUILD_METHOD}" STREQUAL "autotools")
254 255 256 257 258 259
		set(BUILD_TYPES "Debug" "Release" "RelWithDebInfo" "MinSizeRel")
		list(FIND BUILD_TYPES "${CMAKE_BUILD_TYPE}" BUILD_TYPE_FOUND)
		set(BUILD_TYPE_SUFFIX "")
		if(NOT ${BUILD_TYPE_FOUND} EQUAL -1)
			string(TOUPPER "${CMAKE_BUILD_TYPE}" UPPER_BUILD_TYPE)
			set(BUILD_TYPE_SUFFIX "_${UPPER_BUILD_TYPE}")
Ghislain MARY's avatar
Ghislain MARY committed
260
		endif()
261 262 263 264 265
		set(ep_asflags "${AUTOTOOLS_AS_FLAGS${BUILD_TYPE_SUFFIX}}")
		set(ep_cppflags "${AUTOTOOLS_CPP_FLAGS${BUILD_TYPE_SUFFIX}}")
		set(ep_cflags "${AUTOTOOLS_C_FLAGS${BUILD_TYPE_SUFFIX}}")
		set(ep_cxxflags "${AUTOTOOLS_CXX_FLAGS${BUILD_TYPE_SUFFIX}}")
		set(ep_objcflags "${AUTOTOOLS_OBJC_FLAGS${BUILD_TYPE_SUFFIX}}")
Ghislain MARY's avatar
Ghislain MARY committed
266
		set(ep_ldflags "${AUTOTOOLS_LINKER_FLAGS${BUILD_TYPE_SUFFIX}}")
267
	endif()
Ghislain MARY's avatar
Ghislain MARY committed
268
endmacro()
269 270


271
macro(linphone_builder_apply_extra_flags PROJNAME)
272
	if("${EP_${PROJNAME}_BUILD_METHOD}" STREQUAL "autotools")
273 274 275 276 277 278
		set(ep_asflags "${ep_asflags} ${EP_${PROJNAME}_EXTRA_ASFLAGS}")
		set(ep_cppflags "${ep_cppflags} ${EP_${PROJNAME}_EXTRA_CPPFLAGS}")
		set(ep_cflags "${ep_cflags} ${EP_${PROJNAME}_EXTRA_CFLAGS}")
		set(ep_cxxflags "${ep_cxxflags} ${EP_${PROJNAME}_EXTRA_CXXFLAGS}")
		set(ep_objcflags "${ep_objcflags} ${EP_${PROJNAME}_EXTRA_OBJCFLAGS}")
		set(ep_ldflags "${ep_ldflags} ${EP_${PROJNAME}_EXTRA_LDFLAGS}")
279
	else()
280 281 282
		foreach(BUILD_CONFIG "" "_DEBUG" "_MINSIZEREL" "_RELEASE" "_RELWITHDEBINFO")
			if(NOT "${EP_${PROJNAME}_EXTRA_CFLAGS}" STREQUAL "")
				set(CMAKE_C_FLAGS${BUILD_CONFIG} "${CMAKE_C_FLAGS${BUILD_CONFIG}} ${EP_${PROJNAME}_EXTRA_CFLAGS}")
Ghislain MARY's avatar
Ghislain MARY committed
283
			endif()
284 285
			if(NOT "${EP_${PROJNAME}_EXTRA_CXXFLAGS}" STREQUAL "")
				set(CMAKE_CXX_FLAGS${BUILD_CONFIG} "${CMAKE_CXX_FLAGS${BUILD_CONFIG}} ${EP_${PROJNAME}_EXTRA_CXXFLAGS}")
Ghislain MARY's avatar
Ghislain MARY committed
286
			endif()
287 288 289 290
			if(NOT "${EP_${PROJNAME}_EXTRA_LDFLAGS}" STREQUAL "")
				set(CMAKE_EXE_LINKER_FLAGS${BUILD_CONFIG} "${CMAKE_EXE_LINKER_FLAGS${BUILD_CONFIG}} ${EP_${PROJNAME}_EXTRA_LDFLAGS}")
				set(CMAKE_MODULE_LINKER_FLAGS${BUILD_CONFIG} "${CMAKE_MODULE_LINKER_FLAGS${BUILD_CONFIG}} ${EP_${PROJNAME}_EXTRA_LDFLAGS}")
				set(CMAKE_SHARED_LINKER_FLAGS${BUILD_CONFIG} "${CMAKE_SHARED_LINKER_FLAGS${BUILD_CONFIG}} ${EP_${PROJNAME}_EXTRA_LDFLAGS}")
Ghislain MARY's avatar
Ghislain MARY committed
291
			endif()
Ghislain MARY's avatar
Ghislain MARY committed
292
		endforeach()
293
	endif()
Ghislain MARY's avatar
Ghislain MARY committed
294
endmacro()
295 296


297
macro(linphone_builder_set_ep_directories PROJNAME)
298 299 300 301 302
	if(EP_${PROJNAME}_SOURCE_DIR)
		set(ep_source "${EP_${PROJNAME}_SOURCE_DIR}")
	else()
		set(ep_source "${ep_base}/Source/EP_${PROJNAME}")
	endif()
303
	if(EP_${PROJNAME}_BUILD_IN_SOURCE)
304
		set(ep_build "${ep_source}")
Ghislain MARY's avatar
Ghislain MARY committed
305
	else()
306
		set(ep_build "${ep_base}/Build/${PROJNAME}")
Ghislain MARY's avatar
Ghislain MARY committed
307 308
	endif()
endmacro()
309

310 311

macro(linphone_builder_create_autogen_command PROJNAME)
312 313
	if(EP_${PROJNAME}_USE_AUTOGEN)
		if(EP_${PROJNAME}_CONFIGURE_OPTIONS_PASSED_TO_AUTOGEN)
314 315 316
			set(ep_autogen_options "")
			foreach(OPTION ${EP_${PROJNAME}_CROSS_COMPILATION_OPTIONS} ${EP_${PROJNAME}_LINKING_TYPE} ${EP_${PROJNAME}_CONFIGURE_OPTIONS})
				set(ep_autogen_options "${ep_autogen_options} \"${OPTION}\"")
Ghislain MARY's avatar
Ghislain MARY committed
317
			endforeach()
318
		endif()
319
		set(ep_autogen_command "${ep_source}/autogen.sh ${ep_autogen_options}")
320
	else()
321
		set(ep_autogen_command "")
322
	endif()
Ghislain MARY's avatar
Ghislain MARY committed
323
endmacro()
324 325 326


macro(linphone_builder_create_configure_command PROJNAME)
327
	if(EP_${PROJNAME}_CONFIGURE_OPTIONS_PASSED_TO_AUTOGEN)
328
		set(ep_configure_command "")
329
	else()
330 331 332
		set(ep_configure_options "")
		foreach(OPTION ${EP_${PROJNAME}_CROSS_COMPILATION_OPTIONS} ${EP_${PROJNAME}_LINKING_TYPE} ${EP_${PROJNAME}_CONFIGURE_OPTIONS})
			set(ep_configure_options "${ep_configure_options} \"${OPTION}\"")
Ghislain MARY's avatar
Ghislain MARY committed
333
		endforeach()
334
		set(ep_configure_env "${EP_${PROJNAME}_CONFIGURE_ENV}")
335
		set(ep_configure_command "${ep_source}/configure ${ep_configure_options}")
336
	endif()
Ghislain MARY's avatar
Ghislain MARY committed
337
endmacro()
338 339


Ghislain MARY's avatar
Ghislain MARY committed
340 341 342 343 344
macro(linphone_builder_create_build_command PROJNAME)
	set(ep_make_options "${EP_${PROJNAME}_MAKE_OPTIONS}")
endmacro()


345
# this function invokes configure_file() for the project, using the default file if
346 347 348
# the specific file is not defined
function(linphone_builder_configure_file_for_project PROJNAME CMD DEFAULT_CONF_FILE OUTPUT)
	if("${EP_${PROJNAME}_${CMD}_COMMAND_SOURCE}" STREQUAL "")
349
		message(STATUS "Using default file ${DEFAULT_CONF_FILE} for ${CMD} step of ${PROJNAME}")
350 351
		configure_file(${DEFAULT_CONF_FILE} ${OUTPUT})
	else()
352
		message(STATUS "Using specific file ${EP_${PROJNAME}_${CMD}_COMMAND_SOURCE} for ${CMD} step of ${PROJNAME}")
353
		configure_file(${EP_${PROJNAME}_${CMD}_COMMAND_SOURCE} ${OUTPUT})
354 355 356
	endif()
endfunction()

357 358 359 360 361 362
macro(linphone_builder_filter_out_inexistent_dependencies PROJNAME)
	if(EP_${PROJNAME}_DEPENDENCIES)
		set(_new_deps )
		message("EP_${PROJNAME}_DEPENDENCIES: ${EP_${PROJNAME}_DEPENDENCIES}")
		message("LINPHONE_BUILDER_EXTERNAL_SOURCE_PATH_BUILDERS: ${LINPHONE_BUILDER_EXTERNAL_SOURCE_PATH_BUILDERS}")
		foreach(_dep ${EP_${PROJNAME}_DEPENDENCIES})
363 364 365 366
			string(REGEX REPLACE "^EP_" "" _dep2 ${_dep})
			list(FIND LINPHONE_BUILDER_INCLUDED_BUILDERS ${_dep2} _found)
			list(FIND LINPHONE_BUILDER_EXTERNAL_SOURCE_PATH_BUILDERS ${_dep2} _external_source_path_found)
			message("_dep: ${_dep2} _found: ${_found} _external_source_path_found: ${_external_source_path_found}")
367
			if(_found GREATER -1 AND _external_source_path_found EQUAL -1)
368 369 370 371 372 373 374 375 376 377 378 379
				list(APPEND _new_deps ${_dep})
			endif()
		endforeach()
		unset(_dep)
		unset(_found)
		unset(_external_source_path_found)
		message("_new_deps: ${_new_deps}")
		set(EP_${PROJNAME}_DEPENDENCIES ${_new_deps})
		unset(_new_deps)
	endif()
endmacro()

380
function(linphone_builder_add_external_project PROJNAME)
381 382 383 384 385 386 387 388 389 390
	if(LINPHONE_BUILDER_EXTERNAL_SOURCE_PATH)
		foreach(SUBDIR ${EP_${PROJNAME}_EXTERNAL_SOURCE_PATHS})
			if(NOT EP_${PROJNAME}_SOURCE_DIR)
				if(EXISTS "${LINPHONE_BUILDER_EXTERNAL_SOURCE_PATH}/${SUBDIR}")
					set(EP_${PROJNAME}_SOURCE_DIR "${LINPHONE_BUILDER_EXTERNAL_SOURCE_PATH}/${SUBDIR}")
				endif()
			endif()
		endforeach()
	endif()

391
	linphone_builder_set_ep_directories(${PROJNAME})
Ghislain MARY's avatar
Ghislain MARY committed
392 393 394
	if(NOT EP_${PROJNAME}_DO_NOT_USE_CMAKE_FLAGS)
		linphone_builder_apply_cmake_flags_to_autotools_project(${PROJNAME})
	endif()
395
	linphone_builder_apply_extra_flags(${PROJNAME})
396 397
	linphone_builder_expand_external_project_vars()

398 399 400 401 402 403 404 405
	if("${EP_${PROJNAME}_BUILD_METHOD}" STREQUAL "prebuilt")
		message("Using prebuilt ${PROJNAME}")
		set(BUILD_COMMANDS
			CONFIGURE_COMMAND ${CMAKE_COMMAND} -E echo ""
			BUILD_COMMAND ${CMAKE_COMMAND} -E echo ""
			INSTALL_COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=<SOURCE_DIR> -DINSTALL_DIR=${CMAKE_INSTALL_PREFIX} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/install_prebuilt.cmake
		)
	elseif("${EP_${PROJNAME}_BUILD_METHOD}" STREQUAL "custom")
406
		set(ep_redirect_to_file "2>&1 >> ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}.log")
407 408 409 410 411 412 413 414 415 416 417 418
		configure_file(${EP_${PROJNAME}_CONFIGURE_COMMAND_SOURCE} ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_configure.sh)
		configure_file(${EP_${PROJNAME}_BUILD_COMMAND_SOURCE} ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_build.sh)
		configure_file(${EP_${PROJNAME}_INSTALL_COMMAND_SOURCE} ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_install.sh)
		if(WIN32)
			set(SCRIPT_EXTENSION bat)
			set(MSVC_PROJNAME ${PROJNAME})
			configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/mingw_configure.bat.cmake ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_configure.bat)
			configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/mingw_build.bat.cmake ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_build.bat)
			configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/mingw_install.bat.cmake ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_install.bat)
		else()
			set(SCRIPT_EXTENSION sh)
		endif()
419
		set(BUILD_COMMANDS
420 421 422
			CONFIGURE_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_configure.${SCRIPT_EXTENSION}
			BUILD_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_build.${SCRIPT_EXTENSION}
			INSTALL_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_install.${SCRIPT_EXTENSION}
423 424
		)
	elseif("${EP_${PROJNAME}_BUILD_METHOD}" STREQUAL "autotools")
425 426
		linphone_builder_create_autogen_command(${PROJNAME})
		linphone_builder_create_configure_command(${PROJNAME})
Ghislain MARY's avatar
Ghislain MARY committed
427
		linphone_builder_create_build_command(${PROJNAME})
428 429
		if("${EP_${PROJNAME}_CONFIG_H_FILE}" STREQUAL "")
			set(ep_config_h_file config.h)
Ghislain MARY's avatar
Ghislain MARY committed
430
		else()
431
			set(ep_config_h_file ${EP_${PROJNAME}_CONFIG_H_FILE})
Ghislain MARY's avatar
Ghislain MARY committed
432
		endif()
433 434
		if("${EP_${PROJNAME}_INSTALL_TARGET}" STREQUAL "")
			set(ep_install_target "install")
Ghislain MARY's avatar
Ghislain MARY committed
435
		else()
436
			set(ep_install_target "${EP_${PROJNAME}_INSTALL_TARGET}")
Ghislain MARY's avatar
Ghislain MARY committed
437
		endif()
438

439
		set(ep_redirect_to_file "2>&1 >> ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}.log")
440
		if(WIN32)
441 442 443 444 445 446 447
			set(SCRIPT_EXTENSION bat)
			set(MSVC_PROJNAME ${PROJNAME})
			configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/mingw_configure.bat.cmake ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_configure.bat)
			configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/mingw_build.bat.cmake ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_build.bat)
			configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/mingw_install.bat.cmake ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_install.bat)
			# Build in source with MinGW as build out-of-source does not work
			set(ep_build ${ep_source})
448 449 450 451 452 453
			if(NOT "${ep_autogen_command}" STREQUAL "")
				set(ep_autogen_redirect_to_file ${ep_redirect_to_file})
			endif()
			if(NOT "${ep_configure_command}" STREQUAL "")
				set(ep_configure_redirect_to_file ${ep_redirect_to_file})
			endif()
454
		else()
455
			set(SCRIPT_EXTENSION sh)
456
		endif()
457

458
		if("${EP_${PROJNAME}_PKG_CONFIG}" STREQUAL "")
459
			set(LINPHONE_BUILDER_PKG_CONFIG "${PKG_CONFIG_PROGRAM}")
Ghislain MARY's avatar
Ghislain MARY committed
460
		else()
461
			set(LINPHONE_BUILDER_PKG_CONFIG "${EP_${PROJNAME}_PKG_CONFIG}")
Ghislain MARY's avatar
Ghislain MARY committed
462
		endif()
463

464 465 466
		configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/configure.sh.cmake ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_configure.sh)
		configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/build.sh.cmake ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_build.sh)
		configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/install.sh.cmake ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_install.sh)
Ghislain MARY's avatar
Ghislain MARY committed
467 468

		set(BUILD_COMMANDS
469 470 471
			CONFIGURE_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_configure.${SCRIPT_EXTENSION}
			BUILD_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_build.${SCRIPT_EXTENSION}
			INSTALL_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_install.${SCRIPT_EXTENSION}
Ghislain MARY's avatar
Ghislain MARY committed
472
		)
473
	elseif("${EP_${PROJNAME}_BUILD_METHOD}" STREQUAL "rpm")
474

475
		if(WIN32)
Ghislain MARY's avatar
Ghislain MARY committed
476
			message(SEND_ERROR "rpm build not supported on WIN32")
477 478 479 480
		endif()

		linphone_builder_create_autogen_command(${PROJNAME})
		linphone_builder_create_configure_command(${PROJNAME})
481

482 483 484 485 486
		if("${EP_${PROJNAME}_CONFIG_H_FILE}" STREQUAL "")
			set(ep_config_h_file config.h)
		else()
			set(ep_config_h_file ${EP_${PROJNAME}_CONFIG_H_FILE})
		endif()
487

488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506
		if("${EP_${PROJNAME}_INSTALL_TARGET}" STREQUAL "")
			set(ep_install_target "install")
		else()
			set(ep_install_target "${EP_${PROJNAME}_INSTALL_TARGET}")
		endif()

		if("${EP_${PROJNAME}_SPEC_FILE}" STREQUAL "")
			message( SEND_ERROR "rpm build requires EP_${PROJNAME}_SPEC_FILE to be defined")
		else()
			set(LINPHONE_BUILDER_SPEC_FILE "${EP_${PROJNAME}_SPEC_FILE}")
		endif()

		# a distinctive name of the generated RPM. It is used to find the rpms to install
		# in the install step. Defaults to $PROJNAME but could be something else
		if("${EP_${PROJNAME}_RPMBUILD_NAME}" STREQUAL "")
			set(LINPHONE_BUILDER_RPMBUILD_NAME "${PROJNAME}")
		else()
			set(LINPHONE_BUILDER_RPMBUILD_NAME "${EP_${PROJNAME}_RPMBUILD_NAME}")
		endif()
507

508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525
		# a distinctive name of the generated RPM. It is used to find the rpms to install
		# in the install step. Defaults to $PROJNAME but could be something else
		if(NOT "${EP_${PROJNAME}_RPMBUILD_OPTIONS}" STREQUAL "")
			set(LINPHONE_BUILDER_RPMBUILD_OPTIONS "${EP_${PROJNAME}_RPMBUILD_OPTIONS}")
		endif()

		set(LINPHONE_BUILDER_SPEC_PREFIX "${EP_${PROJNAME}_SPEC_PREXIX}")

		if("${EP_${PROJNAME}_PKG_CONFIG}" STREQUAL "")
			set(LINPHONE_BUILDER_PKG_CONFIG "${PKG_CONFIG_PROGRAM}")
		else()
			set(LINPHONE_BUILDER_PKG_CONFIG "${EP_${PROJNAME}_PKG_CONFIG}")
		endif()

		if(NOT "${EP_${PROJNAME}_CONFIGURE_EXTRA_CMD}" STREQUAL "")
			set(LINPHONE_BUILDER_CONFIGURE_EXTRA_CMD "${EP_${PROJNAME}_CONFIGURE_EXTRA_CMD}")
		endif()

526 527 528 529
		# allow to have special command steps
		linphone_builder_configure_file_for_project(${PROJNAME} CONFIGURE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/configure.rpm.sh.cmake ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_configure_rpm.sh)
		linphone_builder_configure_file_for_project(${PROJNAME} BUILD ${CMAKE_CURRENT_SOURCE_DIR}/cmake/build.rpm.sh.cmake ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_build_rpm.sh)
		linphone_builder_configure_file_for_project(${PROJNAME} INSTALL ${CMAKE_CURRENT_SOURCE_DIR}/cmake/install.rpm.sh.cmake ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_install_rpm.sh)
530 531 532 533 534 535

		set(BUILD_COMMANDS
			CONFIGURE_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_configure_rpm.sh
			BUILD_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_build_rpm.sh
			INSTALL_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_install_rpm.sh
		)
536 537
	else()
		# Use CMake build method
538 539 540 541
		set(BUILD_COMMANDS
			CMAKE_ARGS ${EP_${PROJNAME}_CMAKE_OPTIONS} ${EP_${PROJNAME}_LINKING_TYPE}
			CMAKE_CACHE_ARGS ${LINPHONE_BUILDER_EP_ARGS}
		)
542
	endif()
543

544
	if(LINPHONE_BUILDER_LATEST AND EP_${PROJNAME}_GIT_TAG_LATEST)
545
		set(DOWNLOAD_SOURCE GIT_REPOSITORY ${EP_${PROJNAME}_GIT_REPOSITORY} GIT_TAG ${EP_${PROJNAME}_GIT_TAG_LATEST})
546 547 548 549 550 551 552
	elseif(EP_${PROJNAME}_SOURCE_DIR)
		set(DOWNLOAD_SOURCE SOURCE_DIR ${EP_${PROJNAME}_SOURCE_DIR})
	elseif(EP_${PROJNAME}_URL)
		set(DOWNLOAD_SOURCE URL ${EP_${PROJNAME}_URL})
		if(EP_${PROJNAME}_URL_HASH)
			list(APPEND DOWNLOAD_SOURCE URL_HASH ${EP_${PROJNAME}_URL_HASH})
		endif()
553
	else()
554
		set(DOWNLOAD_SOURCE GIT_REPOSITORY ${EP_${PROJNAME}_GIT_REPOSITORY} GIT_TAG ${EP_${PROJNAME}_GIT_TAG})
555
	endif()
556

557 558 559
	linphone_builder_filter_out_inexistent_dependencies(${PROJNAME})

	message("EP_${PROJNAME}_DEPENDENCIES: ${EP_${PROJNAME}_DEPENDENCIES}")
560 561 562
	ExternalProject_Add(EP_${PROJNAME}
		DEPENDS ${EP_${PROJNAME}_DEPENDENCIES}
		BINARY_DIR ${ep_build}
563
		${DOWNLOAD_SOURCE}
564 565
		PATCH_COMMAND ${EP_${PROJNAME}_PATCH_COMMAND}
		CMAKE_GENERATOR ${CMAKE_GENERATOR}
Ghislain MARY's avatar
Ghislain MARY committed
566
		${BUILD_COMMANDS}
567
	)
568

569 570 571 572 573 574 575
	if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/builders/${PROJNAME}/postinstall.cmake)
		ExternalProject_Add_Step(EP_${PROJNAME} postinstall
			COMMAND ${CMAKE_COMMAND} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DINSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -P ${CMAKE_CURRENT_SOURCE_DIR}/builders/${PROJNAME}/postinstall.cmake
			COMMENT "Performing post-installation step"
			DEPENDEES mkdir update patch download configure build install
			WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
		)
576
	endif()
577 578 579 580 581 582 583 584 585
	if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/builders/${PROJNAME}/postconfig.cmake)
		ExternalProject_Add_Step(EP_${PROJNAME} postinstall
			COMMAND ${CMAKE_COMMAND} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DINSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -P ${CMAKE_CURRENT_SOURCE_DIR}/builders/${PROJNAME}/postinstall.cmake
			COMMENT "Performing post-installation step"
			DEPENDEES mkdir update patch download configure build install
			WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
		)
	endif()

Ghislain MARY's avatar
Ghislain MARY committed
586
endfunction()
Ghislain MARY's avatar
Ghislain MARY committed
587

588 589
macro(linphone_builder_add_grouped_external_source_path_project PROJNAME FILENAME)
	message("linphone_builder_add_grouped_external_source_path_project(${PROJNAME}): ${EP_${PROJNAME}_SOURCE_DIR}")
590 591
	linphone_builder_filter_out_inexistent_dependencies(${PROJNAME})
	message("EP_${PROJNAME}_DEPENDENCIES: ${EP_${PROJNAME}_DEPENDENCIES}")
592 593 594 595 596
	file(APPEND "${FILENAME}" "add_subdirectory(\"${EP_${PROJNAME}_SOURCE_DIR}\" \"${LINPHONE_BUILDER_WORK_DIR}/Build/${PROJNAME}\")\n")
	list(APPEND EP_linphone_builder_LINKING_TYPES "${EP_${PROJNAME}_LINKING_TYPE}")
	list(APPEND EP_linphone_builder_CMAKE_OPTIONS "${EP_${PROJNAME}_CMAKE_OPTIONS}")
	list(APPEND EP_linphone_builder_ADDITIONAL_CMAKE_OPTIONS "-DEP_${PROJNAME}_INCLUDE_DIR=${EP_${PROJNAME}_SOURCE_DIR}/include")
	list(APPEND EP_linphone_builder_ADDITIONAL_CMAKE_OPTIONS "-DEP_${PROJNAME}_CONFIG_DIR=${LINPHONE_BUILDER_WORK_DIR}/Build/${PROJNAME}")
597 598 599
	if(EP_${PROJNAME}_DEPENDENCIES)
		add_dependencies(EP_${PROJNAME} ${EP_${PROJNAME}_DEPENDENCIES})
	endif()
600
endmacro()
601

602
function(linphone_builder_add_external_projects)
603 604
	message("LINPHONE_BUILDER_INCLUDED_BUILDERS: ${LINPHONE_BUILDER_INCLUDED_BUILDERS}")
	message("LINPHONE_BUILDER_EXTERNAL_SOURCE_PATH_BUILDERS: ${LINPHONE_BUILDER_EXTERNAL_SOURCE_PATH_BUILDERS}")
605
	foreach(BUILDER ${LINPHONE_BUILDER_INCLUDED_BUILDERS})
606
		list(FIND LINPHONE_BUILDER_EXTERNAL_SOURCE_PATH_BUILDERS ${BUILDER} _found)
607
		if(found EQUAL -1 OR NOT LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
608 609 610 611 612
			linphone_builder_add_external_project(${BUILDER})
		endif()
	endforeach()
endfunction()

613 614
function(linphone_builder_add_grouped_external_source_path_projects)
	if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS AND LINPHONE_BUILDER_EXTERNAL_SOURCE_PATH_BUILDERS)
615 616 617 618 619 620 621
		make_directory("${LINPHONE_BUILDER_WORK_DIR}/Source/EP_linphone_builder")
		set(_linphone_builder_file "${LINPHONE_BUILDER_WORK_DIR}/Source/EP_linphone_builder/CMakeLists.txt")
		file(WRITE "${_linphone_builder_file}" "cmake_minimum_required(VERSION 3.0)\n")
		file(APPEND "${_linphone_builder_file}" "project(EP_linphone_builder)\n")
		set(EP_linphone_builder_CMAKE_OPTIONS )
		set(EP_linphone_builder_ADDITIONAL_CMAKE_OPTIONS "-DLINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS=ON")
		set(EP_linphone_builder_LINKING_TYPES )
622
		foreach(BUILDER ${LINPHONE_BUILDER_EXTERNAL_SOURCE_PATH_BUILDERS})
623
			linphone_builder_add_grouped_external_source_path_project(${BUILDER} "${_linphone_builder_file}")
624
		endforeach()
625 626 627 628 629 630 631 632 633 634 635 636 637 638
		list(REMOVE_DUPLICATES EP_linphone_builder_LINKING_TYPES)
		list(LENGTH EP_linphone_builder_LINKING_TYPES _conflicting_linking_types)
		if(_conflicting_linking_types GREATER 1)
			message(FATAL_ERROR "Conflicing linking types in grouped external source path projects: ${EP_linphone_builder_LINKING_TYPES}")
		else()
			set(EP_linphone_builder_LINKING_TYPE ${EP_linphone_builder_LINKING_TYPES})
		endif()
		list(REMOVE_DUPLICATES EP_linphone_builder_CMAKE_OPTIONS)
		# TODO: Check for conflicting CMAKE_OPTIONS
		list(APPEND EP_linphone_builder_CMAKE_OPTIONS ${EP_linphone_builder_ADDITIONAL_CMAKE_OPTIONS})
		linphone_builder_add_external_project("linphone_builder")
		add_dependencies(TARGET_linphone_builder EP_linphone_builder)
		unset(_conflicting_linking_types)
		unset(_linphone_builder_file)
639
	endif()
640 641 642 643
endfunction()

function(linphone_builder_add_projects)
	linphone_builder_add_external_projects()
644
	linphone_builder_add_grouped_external_source_path_projects()
Ghislain MARY's avatar
Ghislain MARY committed
645
endfunction()
646 647 648 649 650 651

macro(linphone_builder_add_dummy_libraries_generation)
	if(LINPHONE_BUILDER_DUMMY_LIBRARIES)
		linphone_builder_apply_flags()
		linphone_builder_set_ep_directories(dummy_libraries)
		linphone_builder_expand_external_project_vars()
652
		ExternalProject_Add(EP_dummy_libraries
653 654 655 656 657 658 659 660 661 662
			DEPENDS TARGET_linphone_builder
			TMP_DIR ${ep_tmp}
			BINARY_DIR ${ep_build}
			DOWNLOAD_COMMAND ""
			PATCH_COMMAND "${CMAKE_COMMAND}" "-E" "copy_directory" "${CMAKE_CURRENT_LIST_DIR}/cmake/dummy_libraries" "<SOURCE_DIR>"
			CMAKE_GENERATOR ${CMAKE_GENERATOR}
			CMAKE_ARGS ${LINPHONE_BUILDER_EP_ARGS} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DLINPHONE_BUILDER_DUMMY_LIBRARIES=${LINPHONE_BUILDER_DUMMY_LIBRARIES}
		)
	endif()
endmacro()