2011-01-22 13:13:05 +01:00
|
|
|
# Usage: cmake -P Win32Depends.cmake
|
|
|
|
|
|
|
|
# Directories
|
|
|
|
set (working_dir ${CMAKE_CURRENT_BINARY_DIR}/win32-depends)
|
|
|
|
set (pkg_dir ${working_dir}/packages)
|
2012-10-10 20:31:27 +02:00
|
|
|
set (tools_dir ${working_dir}/tools)
|
|
|
|
set (sevenzip_executable ${tools_dir}/7za)
|
2011-01-22 13:13:05 +01:00
|
|
|
set (tmp_dir ${working_dir}/tmp)
|
|
|
|
file (MAKE_DIRECTORY ${working_dir})
|
|
|
|
file (MAKE_DIRECTORY ${pkg_dir})
|
|
|
|
|
|
|
|
# Cleanup
|
|
|
|
message (STATUS "Cleaning up...")
|
|
|
|
file (GLOB files ${working_dir}/*)
|
|
|
|
list (REMOVE_ITEM files ${pkg_dir})
|
|
|
|
if (files)
|
|
|
|
file (REMOVE_RECURSE ${files})
|
|
|
|
endif (files)
|
|
|
|
|
|
|
|
# Packages
|
2012-10-10 20:31:27 +02:00
|
|
|
set (pkg_list "7za" "gtk" "winlibs" "mingw_lua")
|
|
|
|
|
|
|
|
set (pkg_7za_root "http://sourceforge.net/projects/sevenzip/files")
|
|
|
|
set (pkg_7za_urls "${pkg_7z_root}/7-Zip/9.20/7za920.zip")
|
|
|
|
set (pkg_7za_md5 "2fac454a90ae96021f4ffc607d4c00f8")
|
2011-01-22 13:13:05 +01:00
|
|
|
|
|
|
|
set (pkg_gtk_root "http://ftp.gnome.org/pub/gnome/binaries/win32")
|
|
|
|
set (pkg_gtk_urls
|
2012-10-10 20:31:27 +02:00
|
|
|
"${pkg_gtk_root}/gtk+/2.24/gtk+-bundle_2.24.10-20120208_win32.zip"
|
2011-02-12 02:07:39 +01:00
|
|
|
"${pkg_gtk_root}/dependencies/gettext-tools-0.17.zip")
|
2011-02-04 18:40:27 +01:00
|
|
|
set (pkg_gtk_md5
|
2012-10-10 20:31:27 +02:00
|
|
|
"7ae20007b76e8099b05edc789bb23e54"
|
2011-02-12 02:07:39 +01:00
|
|
|
"09baff956ebd1c391c7f71e9bd768edd")
|
2011-01-22 13:13:05 +01:00
|
|
|
|
2012-10-10 20:31:27 +02:00
|
|
|
set (pkg_winlibs_root "http://sourceforge.net/projects/winlibs/files")
|
|
|
|
set (pkg_winlibs_urls "${pkg_winlibs_root}/GTK+/libjson-glib-1.0-1-mingw32.7z")
|
|
|
|
set (pkg_winlibs_md5 "f06e42c5998dae5fb6245fecc96a403e")
|
|
|
|
|
2011-01-22 13:13:05 +01:00
|
|
|
set (pkg_mingw_lua_root "http://sourceforge.net/projects/mingw-cross/files/%5BLIB%5D%20Lua")
|
|
|
|
set (pkg_mingw_lua_name "mingw32-lua-5.1.4-2")
|
2012-10-10 20:31:27 +02:00
|
|
|
set (pkg_mingw_lua_urls "${pkg_mingw_lua_root}/${pkg_mingw_lua_name}/${pkg_mingw_lua_name}.zip")
|
2011-01-22 13:13:05 +01:00
|
|
|
set (pkg_mingw_lua_strip ${pkg_mingw_lua_name})
|
2012-10-10 20:31:27 +02:00
|
|
|
set (pkg_mingw_lua_md5 "7deb1f62a9631871e9b90c0419c2e2bb")
|
|
|
|
|
|
|
|
# Stage 1: fetch missing packages
|
2011-01-22 13:13:05 +01:00
|
|
|
foreach (pkg_set ${pkg_list})
|
2011-02-04 18:40:27 +01:00
|
|
|
set (pkg_md5 ${pkg_${pkg_set}_md5})
|
|
|
|
|
2011-01-22 13:13:05 +01:00
|
|
|
foreach (url ${pkg_${pkg_set}_urls})
|
2011-02-04 18:40:27 +01:00
|
|
|
get_filename_component (basename ${url} NAME)
|
|
|
|
set (filename ${pkg_dir}/${basename})
|
|
|
|
|
|
|
|
if (NOT pkg_md5)
|
2011-06-09 20:46:32 +02:00
|
|
|
message (WARNING "MD5 checksum missing for ${basename}")
|
|
|
|
set (pkg_md5_sum)
|
2011-02-04 18:40:27 +01:00
|
|
|
set (pkg_md5_param)
|
|
|
|
else (NOT pkg_md5)
|
2011-06-09 20:46:32 +02:00
|
|
|
list (GET pkg_md5 0 pkg_md5_sum)
|
2011-02-04 18:40:27 +01:00
|
|
|
list (REMOVE_AT pkg_md5 0)
|
2011-06-09 20:46:32 +02:00
|
|
|
set (pkg_md5_param EXPECTED_MD5 ${pkg_md5_sum})
|
2011-02-04 18:40:27 +01:00
|
|
|
endif (NOT pkg_md5)
|
2011-01-22 13:13:05 +01:00
|
|
|
|
|
|
|
if (NOT EXISTS ${filename})
|
|
|
|
message (STATUS "Downloading ${url}...")
|
2011-02-04 18:40:27 +01:00
|
|
|
file (DOWNLOAD ${url} ${filename} STATUS status ${pkg_md5_param})
|
2011-01-22 13:13:05 +01:00
|
|
|
|
|
|
|
list (GET status 0 status_errno)
|
|
|
|
list (GET status 1 status_msg)
|
|
|
|
if (status_errno)
|
|
|
|
file (REMOVE ${filename})
|
|
|
|
message (FATAL_ERROR "Download failed: ${status_msg}")
|
|
|
|
endif (status_errno)
|
2011-06-09 20:46:32 +02:00
|
|
|
elseif (pkg_md5_sum)
|
|
|
|
execute_process (COMMAND ${CMAKE_COMMAND} -E md5sum ${filename}
|
|
|
|
OUTPUT_VARIABLE output)
|
|
|
|
if (NOT output MATCHES "^${pkg_md5_sum}")
|
|
|
|
message (FATAL_ERROR "MD5 mismatch for ${basename}")
|
|
|
|
endif (NOT output MATCHES "^${pkg_md5_sum}")
|
2011-01-22 13:13:05 +01:00
|
|
|
endif (NOT EXISTS ${filename})
|
|
|
|
endforeach (url)
|
|
|
|
endforeach (pkg_set)
|
|
|
|
|
|
|
|
if (NOT WIN32)
|
|
|
|
message (FATAL_ERROR "Must run on Windows to extract packages; aborting")
|
|
|
|
endif (NOT WIN32)
|
|
|
|
|
2012-10-10 20:31:27 +02:00
|
|
|
# Stage 2: setup 7za first
|
2011-01-22 13:13:05 +01:00
|
|
|
file (MAKE_DIRECTORY ${tmp_dir})
|
2012-10-10 20:31:27 +02:00
|
|
|
foreach (url ${pkg_7za_urls})
|
2011-01-22 13:13:05 +01:00
|
|
|
get_filename_component (filename ${url} NAME)
|
|
|
|
message (STATUS "Extracting ${filename}...")
|
|
|
|
|
2012-10-10 20:31:27 +02:00
|
|
|
set (filename ${pkg_dir}/${filename})
|
2011-01-22 13:13:05 +01:00
|
|
|
execute_process (COMMAND ${CMAKE_COMMAND} -E tar xf ${filename}
|
|
|
|
WORKING_DIRECTORY ${tmp_dir}
|
|
|
|
RESULT_VARIABLE status)
|
|
|
|
if (status)
|
|
|
|
message (FATAL_ERROR "Extraction failed: ${status}")
|
|
|
|
endif (status)
|
|
|
|
endforeach (url)
|
|
|
|
|
2012-10-10 20:31:27 +02:00
|
|
|
file (MAKE_DIRECTORY ${tools_dir})
|
|
|
|
file (COPY ${tmp_dir}/7za.exe DESTINATION ${tools_dir})
|
2011-01-22 13:13:05 +01:00
|
|
|
file (REMOVE_RECURSE ${tmp_dir})
|
2012-10-10 20:31:27 +02:00
|
|
|
list (REMOVE_ITEM pkg_list "7za")
|
2011-01-22 13:13:05 +01:00
|
|
|
|
2011-06-09 20:46:32 +02:00
|
|
|
# Stage 4: extract the rest of packages
|
2011-01-22 13:13:05 +01:00
|
|
|
foreach (pkg_set ${pkg_list})
|
|
|
|
foreach (url ${pkg_${pkg_set}_urls})
|
|
|
|
get_filename_component (filename ${url} NAME)
|
|
|
|
message (STATUS "Extracting ${filename}...")
|
|
|
|
|
2012-10-10 20:31:27 +02:00
|
|
|
if (filename MATCHES "7z$")
|
|
|
|
set (extract_command ${sevenzip_executable} x)
|
|
|
|
set (quiet OUTPUT_QUIET)
|
|
|
|
else (filename MATCHES "7z$")
|
|
|
|
set (extract_command ${CMAKE_COMMAND} -E tar xf)
|
|
|
|
set (quiet)
|
|
|
|
endif (filename MATCHES "7z$")
|
|
|
|
|
|
|
|
set (filename ${pkg_dir}/${filename})
|
2011-01-22 13:13:05 +01:00
|
|
|
if (pkg_${pkg_set}_strip)
|
|
|
|
file (MAKE_DIRECTORY ${tmp_dir})
|
2012-10-10 20:31:27 +02:00
|
|
|
execute_process (COMMAND ${extract_command} ${filename}
|
2011-01-22 13:13:05 +01:00
|
|
|
WORKING_DIRECTORY ${tmp_dir}
|
2012-10-10 20:31:27 +02:00
|
|
|
RESULT_VARIABLE status ${quiet})
|
2011-01-22 13:13:05 +01:00
|
|
|
file (COPY ${tmp_dir}/${pkg_${pkg_set}_strip}/
|
|
|
|
DESTINATION ${working_dir})
|
|
|
|
file (REMOVE_RECURSE ${tmp_dir})
|
|
|
|
else (pkg_${pkg_set}_strip)
|
2012-10-10 20:31:27 +02:00
|
|
|
execute_process (COMMAND ${extract_command} ${filename}
|
2011-01-22 13:13:05 +01:00
|
|
|
WORKING_DIRECTORY ${working_dir}
|
2012-10-10 20:31:27 +02:00
|
|
|
RESULT_VARIABLE status ${quiet})
|
2011-01-22 13:13:05 +01:00
|
|
|
endif (pkg_${pkg_set}_strip)
|
|
|
|
|
|
|
|
if (status)
|
|
|
|
message (FATAL_ERROR "Extraction failed: ${status}")
|
|
|
|
endif (status)
|
|
|
|
endforeach (url)
|
|
|
|
endforeach (pkg_set)
|
|
|
|
|
2011-06-09 20:46:32 +02:00
|
|
|
# Stage 5: final touches
|
2011-01-22 13:13:05 +01:00
|
|
|
file (WRITE ${working_dir}/etc/gtk-2.0/gtkrc
|
|
|
|
"gtk-theme-name = \"MS-Windows\"")
|