source: tol/TestCMake/TestFileDownload/CMakeLists.txt @ 1bcb3dd

1941-docker-image-to-testdevel
Last change on this file since 1bcb3dd was 1bcb3dd, checked in by Jorge Pérez <josp.jorge@…>, 11 years ago

correcciones al test, faltaba un PARENT_SCOPE, asegurar que tol_plat se limpie

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@7075 be4846ae-f051-483a-831f-b64e7d08527f

  • Property mode set to 100644
File size: 2.4 KB
Line 
1cmake_minimum_required(VERSION 2.8)
2project( TestDownload )
3
4function( get_tol_plat var )
5  if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
6    set( tol_ps 32 )
7  elseif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
8    set( tol_ps 64 )
9  else( )
10    message( WARNING "Could not determine pointer size because CMAKE_SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P}" )
11    set( ${var} "unknown" PARENT_SCOPE )
12    return()   
13  endif( )
14  string( TOUPPER ${CMAKE_SYSTEM_NAME} _system )
15  if( UNIX )
16    if( _system STREQUAL "LINUX" )
17      set( ${var} "Linux${tol_ps}GNU" PARENT_SCOPE )
18      return()
19    else( )
20      message( WARNING "Could not determine TOL platform for system ${CMAKE_SYSTEM_NAME}" )
21      set( ${var} "unknown" PARENT_SCOPE )
22      return()
23    endif( )
24  elseif( MINGW )
25    set( ${var} "Win${tol_ps}GNU" PARENT_SCOPE )
26  else( MINGW )
27    message( WARNING "Could not determine TOL platform for system ${CMAKE_SYSTEM_NAME}" )
28    set( ${var} "unknown" PARENT_SCOPE )
29    return()
30  endif( UNIX )
31endfunction( get_tol_plat )
32
33function( download_tol_package pkg bin )
34  set( url "http://packages.tol-project.org/OfficialTolArchiveNetwork/repository.php?action=download&format=attachment&tol_package_version=4&package=${pkg}" )
35  if ( WGET_FOUND )
36    if( ${bin} )
37      get_tol_plat( tol_plat )
38      set( url "${url}%23${tol_plat}" )
39    else( )
40      set( tol_plat "" )
41    endif( )
42    message( STATUS "going to download last version of ${pkg} for platform '${tol_plat}'..." )
43    execute_process(
44      COMMAND ${WGET_EXECUTABLE} --content-disposition "${url}"
45      OUTPUT_VARIABLE WGET_OUTPUT
46      ERROR_VARIABLE IGNORE_ERROR
47      OUTPUT_STRIP_TRAILING_WHITESPACE )
48  else( WGET_FOUND )
49    message( WARNING "Could not download package ${pkg} because wget command is not available" )
50  endif( WGET_FOUND )
51endfunction( download_tol_package )
52
53find_package( Wget )
54if ( WGET_FOUND )
55  download_tol_package( StdLib 0 )
56  download_tol_package( TclCore 1 )
57  message( "${CMAKE_CURRENT_BINARY_DIR}/*.zip.1" )
58  file( GLOB zip_copies "${CMAKE_CURRENT_BINARY_DIR}/*.zip.1" )
59  message( STATUS "zip_copies = ${zip_copies}" )
60  foreach( f ${zip_copies} )
61    string( REPLACE ".zip.1" ".zip" f_zip ${f} )
62    file( REMOVE ${f_zip} )
63    file( RENAME ${f} ${f_zip} )
64  endforeach( )
65else( )
66  message( WARNING "Could not download default packages 'StdLib' and 'TclCore' because wget command is not available. wget must be included in PATH in order to use it" )
67endif( WGET_FOUND )
68
Note: See TracBrowser for help on using the repository browser.