Annotation of ChivanetAimPidgin/win32/purple-fetch.cmake, revision 1.1.1.1

1.1       snw         1: cmake_minimum_required(VERSION 3.18) # for file(ARCHIVE_EXTRACT ...)
                      2: 
                      3: if(NOT ${CMAKE_SIZEOF_VOID_P} EQUAL 4)
                      4:     message(FATAL_ERROR "On Windows, Pidgin 2 is 32 bit only.")
                      5: endif()
                      6: 
                      7: # Pidgin 2.14.12 is shipped with gtk+ 2.16.6 and glib 2.28.8
                      8: # NOTE: There is a purple-flavoured variant of the bundle at https://sourceforge.net/projects/pidgin/files/GTK%2B%20for%20Windows/2.16.6.3/, but the file is larger and less convenient to use
                      9: set(GTK_BUNDLE_ZIP gtk+-bundle_2.16.6-20100912_win32.zip) # NOTE: This contains glib 2.24.2
                     10: set(GTK_BUNDLE_URL "https://download.gnome.org/binaries/win32/gtk+/2.16/" CACHE STRING "Where to download ${GTK_BUNDLE_ZIP} from.")
                     11: IF(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/win32/${GTK_BUNDLE_ZIP})
                     12:     message(STATUS "Fetching ${GTK_BUNDLE_ZIP}...")
                     13:     file(DOWNLOAD ${GTK_BUNDLE_URL}${GTK_BUNDLE_ZIP} ${CMAKE_CURRENT_BINARY_DIR}/win32/${GTK_BUNDLE_ZIP} SHOW_PROGRESS EXPECTED_HASH SHA256=8742eeb383641aa8028d1af7fcfc16b164d8a17d4c8489f4e83ab881453eb847)
                     14: ENDIF()
                     15: IF(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/win32/gtk/include/gtk-2.0/gtk/gtk.h)
                     16:     file(ARCHIVE_EXTRACT INPUT ${CMAKE_CURRENT_BINARY_DIR}/win32/${GTK_BUNDLE_ZIP} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/win32/gtk)
                     17: ENDIF()
                     18: set(GTK_INCLUDE_DIRS 
                     19:     ${CMAKE_CURRENT_BINARY_DIR}/win32/gtk/include
                     20:     ${CMAKE_CURRENT_BINARY_DIR}/win32/gtk/include/glib-2.0
                     21:     ${CMAKE_CURRENT_BINARY_DIR}/win32/gtk/include/gtk-2.0/gtk
                     22:     ${CMAKE_CURRENT_BINARY_DIR}/win32/gtk/lib/glib-2.0/include
                     23: )
                     24: set(GTK_LIBRARY_DIRS 
                     25:     ${CMAKE_CURRENT_BINARY_DIR}/win32/gtk/lib
                     26: )
                     27: find_file(GLIB_LIB "glib-2.0.lib" PATHS ${GTK_LIBRARY_DIRS})
                     28: 
                     29: # not always strictly considered a part of gtk, but gdk-pixbuf is part of the bundle
                     30: set(PIXBUF_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/win32/gtk/include/gtk-2.0)
                     31: find_file(PIXBUF_LIB "gdk_pixbuf-2.0.lib" PATHS ${GTK_LIBRARY_DIRS})
                     32: set(PIXBUF_LIBRARIES ${PIXBUF_LIB})
                     33: 
                     34: set(PIDGIN_VERSION 2.14.13)
                     35: set(PIDGIN_DIRNAME pidgin-${PIDGIN_VERSION})
                     36: set(PIDGIN_SOURCE_ZIP ${PIDGIN_DIRNAME}.tar.bz2)
                     37: set(PIDGIN_BINARY_ZIP ${PIDGIN_DIRNAME}-win32-bin.zip)
                     38: set(PIDGIN_SOURCE_URL "http://prdownloads.sourceforge.net/pidgin/" CACHE STRING "Where to download ${PIDGIN_SOURCE_ZIP} and ${PIDGIN_BINARY_ZIP} from.")
                     39: IF(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/win32/${PIDGIN_SOURCE_ZIP})
                     40:     message(STATUS "Fetching ${PIDGIN_SOURCE_ZIP}...")
                     41:     file(DOWNLOAD ${PIDGIN_SOURCE_URL}${PIDGIN_SOURCE_ZIP} ${CMAKE_CURRENT_BINARY_DIR}/win32/${PIDGIN_SOURCE_ZIP} SHOW_PROGRESS EXPECTED_HASH SHA256=120049dc8e17e09a2a7d256aff2191ff8491abb840c8c7eb319a161e2df16ba8)
                     42: ENDIF()
                     43: IF(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/win32/${PIDGIN_DIRNAME}/libpurple/purple.h)
                     44:     file(ARCHIVE_EXTRACT INPUT ${CMAKE_CURRENT_BINARY_DIR}/win32/${PIDGIN_SOURCE_ZIP} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/win32)
                     45: ENDIF()
                     46: 
                     47: IF(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/win32/${PIDGIN_BINARY_ZIP})
                     48:     message(STATUS "Fetching ${PIDGIN_BINARY_ZIP}...")
                     49:     file(DOWNLOAD ${PIDGIN_SOURCE_URL}${PIDGIN_BINARY_ZIP} ${CMAKE_CURRENT_BINARY_DIR}/win32/${PIDGIN_BINARY_ZIP} SHOW_PROGRESS EXPECTED_HASH SHA256=f3667f3076bebdee8ae687dd694cd2a3a6dffef97c6889b2d14bee61c1c9fa91)
                     50: ENDIF()
                     51: IF(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/win32/${PIDGIN_DIRNAME}-win32bin/libpurple.dll)
                     52:     file(ARCHIVE_EXTRACT INPUT ${CMAKE_CURRENT_BINARY_DIR}/win32/${PIDGIN_BINARY_ZIP} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/win32)
                     53: ENDIF()
                     54: IF (MSVC)
                     55:     # MSVC needs a .lib file
                     56:     set(LIBPURPLE_LIB ${CMAKE_CURRENT_BINARY_DIR}/win32/${PIDGIN_DIRNAME}-win32bin/libpurple.lib)
                     57:     add_custom_target(
                     58:       libpurple_lib
                     59:       DEPENDS ${LIBPURPLE_LIB}
                     60:     )
                     61:     add_custom_command(
                     62:         OUTPUT ${LIBPURPLE_LIB}
                     63:         COMMAND cmd # this explicitly calls the "cmd" batch processor because the default shell could also be PowerShell or even bash
                     64:         ARGS /c ${CMAKE_CURRENT_LIST_DIR}/dll2lib.bat 32 ${CMAKE_CURRENT_BINARY_DIR}/win32/${PIDGIN_DIRNAME}-win32bin/libpurple.dll
                     65:         WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/win32/${PIDGIN_DIRNAME}-win32bin
                     66:         MAIN_DEPENDENCY ${CMAKE_CURRENT_BINARY_DIR}/win32/${PIDGIN_DIRNAME}-win32bin/libpurple.dll
                     67:         COMMENT "Generating .lib file from .dll..."
                     68:     )
                     69: ELSE()
                     70:     # MinGW GCC can use the .dll directly
                     71:     set(LIBPURPLE_LIB ${CMAKE_CURRENT_BINARY_DIR}/win32/${PIDGIN_DIRNAME}-win32bin/libpurple.dll)
                     72: ENDIF()
                     73: 
                     74: set(PURPLE_INCLUDE_DIRS
                     75:     ${GTK_INCLUDE_DIRS}
                     76:     ${CMAKE_CURRENT_BINARY_DIR}/win32/${PIDGIN_DIRNAME}/libpurple
                     77: )
                     78: set(PURPLE_LIBRARIES
                     79:     ${GLIB_LIB} ${LIBPURPLE_LIB} 
                     80: )
                     81: set(_PURPLE_DATA_DIR
                     82:     ${CMAKE_CURRENT_BINARY_DIR}/win32/${PIDGIN_DIRNAME}-win32bin
                     83: )
                     84: set(_PURPLE_PLUGIN_DIR
                     85:     ${CMAKE_CURRENT_BINARY_DIR}/win32/${PIDGIN_DIRNAME}-win32bin/plugins
                     86: )
                     87: set(PURPLE_VERSION
                     88:     ${PIDGIN_VERSION}
                     89: )
                     90: set(PURPLE_FOUND
                     91:     TRUE
                     92: )
                     93: 
                     94: set(PURPLE_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}/pidgin_config" CACHE PATH "The purple user configuration directory. For production, this is ~/.purple.")
                     95: add_custom_target(run
                     96:     COMMAND ${CMAKE_COMMAND} -E env "PATH=$ENV{PATH};${CMAKE_CURRENT_BINARY_DIR}/win32/gtk/bin;${CMAKE_CURRENT_BINARY_DIR}/win32/pidgin-${PIDGIN_VERSION}-win32bin" pidgin -d -c ${PURPLE_CONFIG_DIR}
                     97:     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
                     98: )

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>