CheckBuildTools.cmake 8.09 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
############################################################################
# CheckBuildTools.txt
# Copyright (C) 2015  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
19
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 21 22 23 24 25 26 27
#
############################################################################

find_package(PythonInterp)
if(NOT PYTHONINTERP_FOUND)
	message(FATAL_ERROR "Could not find python!")
endif()

28 29 30 31 32 33 34
if(CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" OR CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
	set(WINDOWS_UNIVERSAL TRUE)
else()
	set(WINDOWS_UNIVERSAL FALSE)
endif()

if(MSVC AND NOT WINDOWS_UNIVERSAL)
35 36 37 38 39 40 41 42
	find_program(SH_PROGRAM
		NAMES sh.exe
		HINTS "C:/MinGW/msys/1.0/bin"
	)
	if(NOT SH_PROGRAM)
		message(FATAL_ERROR "Could not find MinGW!")
	endif()

43 44 45 46 47 48 49 50 51 52
	find_file(GCC_LIBRARY
		NAMES libgcc.a
		HINTS "C:/MinGW/lib/gcc/mingw32/*"
	)
	execute_process(COMMAND "${CMAKE_COMMAND}" "-E" "copy" "${GCC_LIBRARY}" "${CMAKE_INSTALL_PREFIX}/lib/gcc.lib")
	find_file(MINGWEX_LIBRARY
		NAMES libmingwex.a
		HINTS "C:/MinGW/lib"
	)
	execute_process(COMMAND "${CMAKE_COMMAND}" "-E" "copy" "${MINGWEX_LIBRARY}" "${CMAKE_INSTALL_PREFIX}/lib/mingwex.lib")
53 54
endif()

55
set(CMAKE_PROGRAM_PATH "${CMAKE_BINARY_DIR}/programs")
56 57
string(REGEX REPLACE "^([a-zA-Z]):(.*)$" "/\\1\\2" AUTOTOOLS_PROGRAM_PATH "${CMAKE_PROGRAM_PATH}")
string(REPLACE "\\" "/" AUTOTOOLS_PROGRAM_PATH ${AUTOTOOLS_PROGRAM_PATH})
58 59
file(MAKE_DIRECTORY ${CMAKE_PROGRAM_PATH})
file(COPY "${CMAKE_CURRENT_LIST_DIR}/../scripts/gas-preprocessor.pl" DESTINATION "${CMAKE_PROGRAM_PATH}")
60 61 62
if(WIN32)
	if(NOT EXISTS "${CMAKE_BINARY_DIR}/linphone_builder_windows_tools.zip")
		message(STATUS "Installing windows tools")
63
		file(DOWNLOAD http://www.linphone.org/files/linphone_builder_windows_tools.zip "${CMAKE_BINARY_DIR}/linphone_builder_windows_tools.zip")
64 65
		execute_process(
			COMMAND "${CMAKE_COMMAND}" "-E" "tar" "x" "${CMAKE_BINARY_DIR}/linphone_builder_windows_tools.zip"
66
			WORKING_DIRECTORY ${CMAKE_PROGRAM_PATH}
67
		)
68 69
		if(NOT WINDOWS_UNIVERSAL)
			if(CMAKE_SIZEOF_VOID_P EQUAL 8)
70 71
				file(RENAME "${CMAKE_PROGRAM_PATH}/yasm-1.3.0-win64.exe" "${CMAKE_PROGRAM_PATH}/yasm.exe")
				file(REMOVE "${CMAKE_PROGRAM_PATH}/yasm-1.3.0-win32.exe")
72
			else()
73 74
				file(RENAME "${CMAKE_PROGRAM_PATH}/yasm-1.3.0-win32.exe" "${CMAKE_PROGRAM_PATH}/yasm.exe")
				file(REMOVE "${CMAKE_PROGRAM_PATH}/yasm-1.3.0-win64.exe")
75
			endif()
76 77 78 79 80
		endif()
	endif()
endif()

find_program(PATCH_PROGRAM
81 82
  NAMES patch patch.exe
  CMAKE_FIND_ROOT_PATH_BOTH
83 84 85 86 87 88 89 90 91 92
)
if(NOT PATCH_PROGRAM)
	if(WIN32)
		message(FATAL_ERROR "Could not find the patch.exe program. Please install it from http://gnuwin32.sourceforge.net/packages/patch.htm")
	else()
		message(FATAL_ERROR "Could not find the patch program.")
	endif()
endif()

find_program(SED_PROGRAM
93 94
  NAMES sed sed.exe
  CMAKE_FIND_ROOT_PATH_BOTH
95 96 97 98 99 100 101 102 103 104 105 106 107 108
)
if(NOT SED_PROGRAM)
	if(WIN32)
		message(FATAL_ERROR "Could not find the sed.exe program. Please install it from http://gnuwin32.sourceforge.net/packages/sed.htm")
	else()
		message(FATAL_ERROR "Could not find the sed program.")
	endif()
endif()

find_program(PKG_CONFIG_PROGRAM
	NAMES pkg-config pkg-config.exe
	HINTS "C:/MinGW/bin"
)

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
if(NOT WINDOWS_UNIVERSAL)
	if(NOT PKG_CONFIG_PROGRAM)
		if(WIN32)
			message(STATUS "Installing pkg-config to C:/MinGW/bin")
			set(_pkg_config_dir ${CMAKE_BINARY_DIR}/pkg-config)
			file(MAKE_DIRECTORY ${_pkg_config_dir})
			file(DOWNLOAD http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/pkg-config_0.26-1_win32.zip "${CMAKE_BINARY_DIR}/pkg-config.zip")
			execute_process(
				COMMAND "${CMAKE_COMMAND}" "-E" "tar" "x" "${CMAKE_BINARY_DIR}/pkg-config.zip"
				WORKING_DIRECTORY ${_pkg_config_dir}
			)
			file(DOWNLOAD http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/pkg-config-dev_0.26-1_win32.zip "${CMAKE_BINARY_DIR}/pkg-config-dev.zip")
			execute_process(
				COMMAND "${CMAKE_COMMAND}" "-E" "tar" "x" "${CMAKE_BINARY_DIR}/pkg-config-dev.zip"
				WORKING_DIRECTORY ${_pkg_config_dir}
			)
			file(DOWNLOAD http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/gettext-runtime_0.18.1.1-2_win32.zip "${CMAKE_BINARY_DIR}/gettext-runtime.zip")
			execute_process(
				COMMAND "${CMAKE_COMMAND}" "-E" "tar" "x" "${CMAKE_BINARY_DIR}/gettext-runtime.zip"
				WORKING_DIRECTORY ${_pkg_config_dir}
			)
			file(DOWNLOAD http://ftp.acc.umu.se/pub/gnome/binaries/win32/glib/2.28/glib_2.28.8-1_win32.zip "${CMAKE_BINARY_DIR}/glib.zip")
			execute_process(
				COMMAND "${CMAKE_COMMAND}" "-E" "tar" "x" "${CMAKE_BINARY_DIR}/glib.zip"
				WORKING_DIRECTORY ${_pkg_config_dir}
			)
			file(RENAME "${_pkg_config_dir}/bin/pkg-config.exe" "C:/MinGW/bin/pkg-config.exe")
			file(RENAME "${_pkg_config_dir}/share/aclocal/pkg.m4" "C:/MinGW/share/aclocal/pkg.m4")
			file(RENAME "${_pkg_config_dir}/bin/libglib-2.0-0.dll" "C:/MinGW/bin/libglib-2.0-0.dll")
			file(RENAME "${_pkg_config_dir}/bin/intl.dll" "C:/MinGW/bin/intl.dll")
			unset(_pkg_config_dir)
		endif()

		find_program(PKG_CONFIG_PROGRAM
			NAMES pkg-config pkg-config.exe
			HINTS "C:/MinGW/bin"
145 146 147
		)
	endif()

148 149
	if(NOT PKG_CONFIG_PROGRAM AND NOT MSVC)
		message(FATAL_ERROR "Could not find the pkg-config program.")
150 151
	endif()

152
	if(ENABLE_NLS)
153 154 155 156 157
		find_program(INTLTOOLIZE_PROGRAM
			NAMES intltoolize
			HINTS "C:/MinGW/msys/1.0/bin"
		)

158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
		if(NOT INTLTOOLIZE_PROGRAM)
			if(WIN32)
				message(STATUS "Installing intltoolize to C:/MinGW/bin")
				set(_intltoolize_dir ${CMAKE_BINARY_DIR}/intltoolize)
				file(MAKE_DIRECTORY ${_intltoolize_dir})
				file(DOWNLOAD http://ftp.gnome.org/pub/gnome/binaries/win32/intltool/0.40/intltool_0.40.4-1_win32.zip "${CMAKE_BINARY_DIR}/intltoolize.zip")
				execute_process(
					COMMAND "${CMAKE_COMMAND}" "-E" "tar" "x" "${CMAKE_BINARY_DIR}/intltoolize.zip"
					WORKING_DIRECTORY ${_intltoolize_dir}
				)
				execute_process(
					COMMAND "${SED_PROGRAM}" "-i" "s;/opt/perl/bin/perl;/bin/perl;g" "${_intltoolize_dir}/bin/intltool-extract"
					COMMAND "${SED_PROGRAM}" "-i" "s;/opt/perl/bin/perl;/bin/perl;g" "${_intltoolize_dir}/bin/intltool-merge"
					COMMAND "${SED_PROGRAM}" "-i" "s;/opt/perl/bin/perl;/bin/perl;g" "${_intltoolize_dir}/bin/intltool-prepare"
					COMMAND "${SED_PROGRAM}" "-i" "s;/opt/perl/bin/perl;/bin/perl;g" "${_intltoolize_dir}/bin/intltool-update"
				)
				file(RENAME "${_intltoolize_dir}/bin/intltoolize" "C:/MinGW/msys/1.0/bin/intltoolize")
				file(RENAME "${_intltoolize_dir}/bin/intltool-extract" "C:/MinGW/bin/intltool-extract")
				file(RENAME "${_intltoolize_dir}/bin/intltool-merge" "C:/MinGW/bin/intltool-merge")
				file(RENAME "${_intltoolize_dir}/bin/intltool-prepare" "C:/MinGW/bin/intltool-prepare")
				file(RENAME "${_intltoolize_dir}/bin/intltool-update" "C:/MinGW/bin/intltool-update")
				file(RENAME "${_intltoolize_dir}/share/aclocal/intltool.m4" "C:/MinGW/share/aclocal/intltool.m4")
				file(MAKE_DIRECTORY "C:/MinGW/msys/1.0/share/intltool")
				file(RENAME "${_intltoolize_dir}/share/intltool/Makefile.in.in" "C:/MinGW/msys/1.0/share/intltool/Makefile.in.in")
				unset(_intltoolize_dir)
			endif()

			find_program(INTLTOOLIZE_PROGRAM
				NAMES intltoolize
				HINTS "C:/MinGW/msys/1.0/bin"
			)
		endif()

		if(NOT INTLTOOLIZE_PROGRAM AND NOT MSVC)
			message(FATAL_ERROR "Could not find the intltoolize program.")
		endif()
194
	endif()
195 196
endif()

197
if(MSVC AND NOT WINDOWS_UNIVERSAL)
198 199 200 201 202
	# Install headers needed by MSVC
	file(GLOB MSVC_HEADER_FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/MSVC/*.h")
	file(MAKE_DIRECTORY "${CMAKE_INSTALL_PREFIX}/include/MSVC")
	file(INSTALL ${MSVC_HEADER_FILES} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/MSVC")
endif()