|
| 1 | +cmake_minimum_required(VERSION 3.17) |
| 2 | + |
| 3 | +project(CastXMLPythonDistributions) |
| 4 | + |
| 5 | +list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) |
| 6 | + |
| 7 | +# Options |
| 8 | +set(ARCHIVE_DOWNLOAD_DIR "${CMAKE_BINARY_DIR}" CACHE PATH "Directory where to download archives") |
| 9 | + |
| 10 | +include(CastXMLUrls) |
| 11 | + |
| 12 | +#----------------------------------------------------------------------------- |
| 13 | +# Which archives ? |
| 14 | +#----------------------------------------------------------------------------- |
| 15 | +function(check_archive_var archive_var) |
| 16 | + if(NOT DEFINED "${archive_var}_url") |
| 17 | + message(FATAL_ERROR "Failed to determine which archive to download: '${archive_var}_url' variable is not defined") |
| 18 | + endif() |
| 19 | + if(NOT DEFINED "${archive_var}_sha512") |
| 20 | + message(FATAL_ERROR "Could you make sure variable '${archive_var}_sha512' is defined ?") |
| 21 | + endif() |
| 22 | +endfunction() |
| 23 | + |
| 24 | +set(binary_archive "linux32_binary") |
| 25 | +if(CMAKE_SIZEOF_VOID_P EQUAL 8) |
| 26 | + set(binary_archive "linux64_binary") |
| 27 | +endif() |
| 28 | +if(APPLE) |
| 29 | + set(binary_archive "macosx_binary") |
| 30 | +endif() |
| 31 | +if(WIN32) |
| 32 | + set(binary_archive "win32_binary") |
| 33 | + if(CMAKE_SIZEOF_VOID_P EQUAL 8) |
| 34 | + set(binary_archive "win64_binary") |
| 35 | + endif() |
| 36 | +endif() |
| 37 | +check_archive_var("${binary_archive}") |
| 38 | + |
| 39 | +#----------------------------------------------------------------------------- |
| 40 | +# Summary |
| 41 | +#----------------------------------------------------------------------------- |
| 42 | +message(STATUS "*********************************************") |
| 43 | +message(STATUS "CastXML Python Distribution") |
| 44 | +message(STATUS "") |
| 45 | +message(STATUS " ARCHIVE_DOWNLOAD_DIR : ${ARCHIVE_DOWNLOAD_DIR}") |
| 46 | +message(STATUS "") |
| 47 | +message(STATUS " src_archive : ${src_archive}") |
| 48 | +message(STATUS " <src_archive>_url : ${${src_archive}_url}") |
| 49 | +message(STATUS " <src_archive>_sha256 : ${${src_archive}_sha512}") |
| 50 | +message(STATUS "") |
| 51 | +message(STATUS "*********************************************") |
| 52 | + |
| 53 | +#----------------------------------------------------------------------------- |
| 54 | +# Download pre-built archive |
| 55 | +#----------------------------------------------------------------------------- |
| 56 | +include(FetchContent) |
| 57 | +FetchContent_Populate(castxmlrelease |
| 58 | + URL ${${binary_archive}_url} |
| 59 | + URL_HASH SHA512=${${binary_archive}_sha512} |
| 60 | + ) |
| 61 | +set(CASTXML_RELEASE_DIR ${castxmlrelease_SOURCE_DIR}) |
| 62 | + |
| 63 | +set(castxml_executable ${CASTXML_RELEASE_DIR}/bin/castxml${CMAKE_EXECUTABLE_SUFFIX}) |
| 64 | + |
| 65 | +install(PROGRAMS ${castxml_executable} DESTINATION castxml/data/bin) |
0 commit comments