CMake updates from 1.10.4

This commit is contained in:
Shahram Najm 2013-04-23 10:04:23 +01:00
parent 119fbbeddf
commit f613b8f86c
1 changed files with 27 additions and 27 deletions

View File

@ -3,22 +3,22 @@ if( GRIB_API_PYTHON )
message( WARNING "support for Python with CMake needs testing" ) message( WARNING "support for Python with CMake needs testing" )
ecbuild_find_python( VERSION 2.5 ) ecbuild_find_python( VERSION 2.5 )
find_package( SWIG ) find_package( SWIG )
if( SWIG_FOUND ) if( SWIG_FOUND )
include( ${SWIG_USE_FILE} ) include( ${SWIG_USE_FILE} )
endif() endif()
# check for Numpy # check for Numpy
if(PYTHON_EXECUTABLE) if(PYTHON_EXECUTABLE)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/numpy_path.py "try: import numpy; print numpy.get_include()\nexcept: pass\n") file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/numpy_path.py "try: import numpy; print numpy.get_include()\nexcept: pass\n")
exec_program( ${PYTHON_EXECUTABLE} exec_program( ${PYTHON_EXECUTABLE}
ARGS "\"${CMAKE_CURRENT_BINARY_DIR}/determineNumpyPath.py\"" ARGS "\"${CMAKE_CURRENT_BINARY_DIR}/determineNumpyPath.py\""
OUTPUT_VARIABLE NUMPY_PATH ) OUTPUT_VARIABLE NUMPY_PATH )
endif() endif()
find_path( PYTHON_NUMPY_INCLUDE_DIR arrayobject.h find_path( PYTHON_NUMPY_INCLUDE_DIR arrayobject.h
"${NUMPY_PATH}/numpy/" "${NUMPY_PATH}/numpy/"
"${PYTHON_INCLUDE_PATH}/numpy/" "${PYTHON_INCLUDE_PATH}/numpy/"
@ -27,18 +27,18 @@ if( GRIB_API_PYTHON )
/usr/include/python2.4/numpy/ /usr/include/python2.4/numpy/
/usr/include/python2.3/numpy/ /usr/include/python2.3/numpy/
DOC "Directory where the arrayobject.h header file can be found. This file is part of the numpy package" ) DOC "Directory where the arrayobject.h header file can be found. This file is part of the numpy package" )
if( PYTHON_NUMPY_INCLUDE_DIR ) if( PYTHON_NUMPY_INCLUDE_DIR )
set(PYTHON_NUMPY_FOUND 1 CACHE INTERNAL "Python numpy development package is available") set(PYTHON_NUMPY_FOUND 1 CACHE INTERNAL "Python numpy development package is available")
endif() endif()
############################################################################### ###############################################################################
# swig python interface # swig python interface
if( GRIB_API_PYTHON AND SWIG_FOUND AND PYTHONLIBS_FOUND ) if( GRIB_API_PYTHON AND SWIG_FOUND AND PYTHONLIBS_FOUND )
# preparing for generating setup.py -- this may not be needed as cmake can do the swig + shared libs without libtool # preparing for generating setup.py -- this may not be needed as cmake can do the swig + shared libs without libtool
if( PYTHON_NUMPY_FOUND ) if( PYTHON_NUMPY_FOUND )
set( DATA_HANDLER "numpy" ) set( DATA_HANDLER "numpy" )
else() else()
@ -46,37 +46,37 @@ if( GRIB_API_PYTHON )
endif() endif()
set( BUILD_DIR "${PROJECT_SOURCE_DIR}" ) # setup.py assumes build_dir is same as source_dir -- not true for cmake builds set( BUILD_DIR "${PROJECT_SOURCE_DIR}" ) # setup.py assumes build_dir is same as source_dir -- not true for cmake builds
set( LIB_PNG "${HAVE_LIBPNG}" ) set( LIB_PNG "${HAVE_LIBPNG}" )
set( LIB_JASPER ${HAVE_LIBJASPER} ) set( LIB_JASPER ${HAVE_LIBJASPER} )
get_filename_component(JASPER_DIR ${JASPER_INCLUDE_DIR} PATH ) get_filename_component(JASPER_DIR ${JASPER_INCLUDE_DIR} PATH )
set( LIB_OPENJPEG ${HAVE_LIBOPENJPEG} ) set( LIB_OPENJPEG ${HAVE_LIBOPENJPEG} )
get_filename_component(OPENJPEG_DIR ${OPENJPEG_INCLUDE_DIR} PATH ) get_filename_component(OPENJPEG_DIR ${OPENJPEG_INCLUDE_DIR} PATH )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
configure_file( setup.py.in setup.py ) configure_file( setup.py.in setup.py )
# compile swig interface # compile swig interface
set(CMAKE_SWIG_FLAGS "") set(CMAKE_SWIG_FLAGS "")
include_directories( ${PYTHON_INCLUDE_PATH} ) include_directories( ${PYTHON_INCLUDE_PATH} )
set_source_files_properties( gribapi_swig.i PROPERTIES C ON ) set_source_files_properties( eccode_swig.i PROPERTIES C ON )
swig_add_module( gribapi_swig python gribapi_swig.i ) swig_add_module( eccode_swig python grib_interface.h grib_interface.c eccode_swig.i )
swig_link_libraries( gribapi_swig grib_api ${PYTHON_LIBRARIES} ) swig_link_libraries( eccode_swig grib_api ${PYTHON_LIBRARIES} )
set(PYTHON_DEST "lib/python${PYTHON_VERSION}/site-packages" ) set(PYTHON_DEST "lib/python${PYTHON_VERSION}/site-packages" )
install(TARGETS _gribapi_swig DESTINATION ${PYTHON_DEST} ) install(TARGETS _eccode_swig DESTINATION ${PYTHON_DEST} )
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gribapi_swig.py DESTINATION ${PYTHON_DEST}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/eccode_swig.py DESTINATION ${PYTHON_DEST})
endif() endif()
endif() endif()