1# Downloads the declared version of python-snappy source code and builds it.
2
3# First, download the dependency: snappy itself. Set CMAKE_INSTALL_PREFIX
4# to a local directory to dump in there, and add that directory to CMAKE_PREFIX_PATH.
5SET (_snappy_install "${CMAKE_CURRENT_BINARY_DIR}/dep-install")
6SET (_orig_install_prefix "${CMAKE_INSTALL_PREFIX}")
7SET (CMAKE_INSTALL_PREFIX "${_snappy_install}")
8IF (WIN32)
9  MESSAGE (FATAL_ERROR "python-snappy > 1.1.1 cannot be built on Windows")
10ELSE ()
11  DECLARE_DEP (snappy VERSION 1.1.1-cb2 PLATFORMS centos6 centos7 debian8 debian9 macosx sunos suse11.2 suse12.2 ubuntu14.04 ubuntu16.04 freebsd)
12  DECLARE_DEP (snappy VERSION 1.1.1-cb6 PLATFORMS rhel8)
13ENDIF ()
14SET (CMAKE_INSTALL_PREFIX "${_orig_install_prefix}")
15
16include(ExternalProject)
17
18### Download, configure and build python-snappy ####################################
19ExternalProject_Add(python-snappy
20  GIT_REPOSITORY ${_git_repo}
21  GIT_TAG ${_git_rev}
22
23  CONFIGURE_COMMAND "${CMAKE_COMMAND}" -E echo Configuring python-snappy...
24
25  BUILD_COMMAND python setup.py build build_ext
26                -I "${CMAKE_CURRENT_BINARY_DIR}/snappy.exploded/include" -L "${_snappy_install}/lib"
27  BUILD_IN_SOURCE 1
28
29  INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install
30  INSTALL_COMMAND python setup.py install --install-lib <INSTALL_DIR>/lib/python/pysnappy2
31
32  COMMAND ${CMAKE_COMMAND} -E echo FILE "(COPY lib DESTINATION \"\${CMAKE_INSTALL_PREFIX}\")" > <INSTALL_DIR>/CMakeLists.txt
33)
34
35# cbdeps boilerplate
36_ADD_PACKAGE_STEP()
37