Cmake changes from Tiago

This commit is contained in:
Shahram Najm 2013-05-14 17:38:40 +01:00
parent 91cac03025
commit 26b9da1f65
2 changed files with 42 additions and 49 deletions

View File

@ -53,11 +53,11 @@ find_package( CMath )
set( HAVE_LIBSZIP 0 ) set( HAVE_LIBSZIP 0 )
if( GRIB_API_SZIP ) if( GRIB_API_SZIP )
find_package( SZip ) find_package( SZip )
if( SZIP_FOUND ) if( SZIP_FOUND )
set( HAVE_LIBSZIP 1 ) set( HAVE_LIBSZIP 1 )
list( APPEND GRIB_API_EXTRA_LIBRARIES ${SZIP_LIBRARIES} )
list( APPEND GRIB_API_EXTRA_INCLUDE_DIRS ${SZIP_INCLUDE_DIRS} )
endif() endif()
endif() endif()
@ -75,15 +75,11 @@ if( GRIB_API_JPG )
if( JASPER_FOUND ) if( JASPER_FOUND )
set( HAVE_JPEG 1 ) set( HAVE_JPEG 1 )
set( HAVE_LIBJASPER 1 ) set( HAVE_LIBJASPER 1 )
list( APPEND GRIB_API_EXTRA_LIBRARIES ${JASPER_LIBRARIES} )
list( APPEND GRIB_API_EXTRA_INCLUDE_DIRS ${JASPER_INCLUDE_DIR} )
endif() endif()
if( OpenJPEG_FOUND ) if( OpenJPEG_FOUND )
set( HAVE_JPEG 1 ) set( HAVE_JPEG 1 )
set( HAVE_LIBOPENJPEG 1 ) set( HAVE_LIBOPENJPEG 1 )
list( APPEND GRIB_API_EXTRA_LIBRARIES ${OPENJPEG_LIBRARIES} )
list( APPEND GRIB_API_EXTRA_INCLUDE_DIRS ${OPENJPEG_INCLUDE_DIR} )
endif() endif()
endif() endif()
@ -98,9 +94,6 @@ if( GRIB_API_PNG )
if( PNG_FOUND ) if( PNG_FOUND )
set( HAVE_LIBPNG 1 ) set( HAVE_LIBPNG 1 )
list( APPEND GRIB_API_EXTRA_LIBRARIES ${PNG_LIBRARIES} )
list( APPEND GRIB_API_EXTRA_INCLUDE_DIRS ${PNG_INCLUDE_DIR} )
list( APPEND GRIB_API_EXTRA_DEFINITIONS ${PNG_DEFINITIONS} )
add_definitions( ${PNG_DEFINITIONS} ) add_definitions( ${PNG_DEFINITIONS} )
endif() endif()
@ -116,12 +109,11 @@ if( GRIB_API_NETCDF )
if( NETCDF_FOUND ) if( NETCDF_FOUND )
set( HAVE_NETCDF 1 ) set( HAVE_NETCDF 1 )
list( APPEND GRIB_API_EXTRA_LIBRARIES ${NETCDF_LIBRARIES} )
list( APPEND GRIB_API_EXTRA_INCLUDE_DIRS ${NETCDF_INCLUDE_DIR} )
endif() endif()
endif() endif()
###############################################################################
# other options # other options
if( GRIB_TIMER ) if( GRIB_TIMER )
@ -178,10 +170,27 @@ if( CMAKE_COMPILER_IS_GNUCC )
cmake_add_c_flags("-pedantic") cmake_add_c_flags("-pedantic")
endif() endif()
############################################################################################
# contents
### define dependencies
set( GRIB_API_TPLS SZip PNG NetCDF Jasper OpenJPEG CMath )
set( GRIB_API_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src )
set( GRIB_API_LIBRARIES grib_api )
get_directory_property( COMPILE_DEFINITIONS GRIB_API_DEFINITIONS )
foreach( _tpl ${GRIB_API_TPLS} )
string( TOUPPER ${_tpl} TPL )
list( APPEND GRIB_API_EXTRA_DEFINITIONS ${${TPL}_DEFINITIONS} )
list( APPEND GRIB_API_EXTRA_INCLUDE_DIRS ${${TPL}_INCLUDE_DIRS} )
list( APPEND GRIB_API_EXTRA_LIBRARIES ${${TPL}_LIBRARIES} )
endforeach()
### include directories ### include directories
include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) include_directories( ${GRIB_API_INCLUDE_DIRS} )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src )
add_subdirectory( src ) add_subdirectory( src )
add_subdirectory( tools ) add_subdirectory( tools )
@ -200,21 +209,16 @@ add_subdirectory( ifs_samples ) # must come after samples
############################################################################################ ############################################################################################
# export to other projects # export to other projects
# temporary -- for old ecbuild 1.0 # temporary -- add support for ecbuild 1.0.x sub-project inclusion
# to remove once mars server & client use eckit & ecbuild >= 1.1
if( NOT ${PROJECT_NAME} STREQUAL ${CMAKE_PROJECT_NAME} ) if( NOT ${PROJECT_NAME} STREQUAL ${CMAKE_PROJECT_NAME} )
set( GRIB_API_DEFINITIONS ${GRIB_API_EXTRA_DEFINITIONS} PARENT_SCOPE ) set( GRIB_API_DEFINITIONS ${GRIB_API_DEFINITIONS} PARENT_SCOPE )# includes already TPL definitions
set( GRIB_API_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src ${GRIB_API_EXTRA_INCLUDE_DIRS} PARENT_SCOPE ) set( GRIB_API_INCLUDE_DIRS ${GRIB_API_INCLUDE_DIRS} ${GRIB_API_EXTRA_INCLUDE_DIRS} PARENT_SCOPE )
set( GRIB_API_LIBRARIES grib_api ${GRIB_API_EXTRA_LIBRARIES} ${CMATH_LIBRARIES} PARENT_SCOPE ) set( GRIB_API_LIBRARIES ${GRIB_API_LIBRARIES} ${GRIB_API_EXTRA_LIBRARIES} ${CMATH_LIBRARIES} PARENT_SCOPE )
set( GRIB_API_FOUND TRUE PARENT_SCOPE ) set( GRIB_API_FOUND TRUE PARENT_SCOPE )
endif() endif()
# new -- for ecbuild >= 1.1
set( GRIB_API_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src ${GRIB_API_EXTRA_INCLUDE_DIRS} )
set( GRIB_API_DEFINITIONS ${GRIB_API_EXTRA_DEFINITIONS} )
set( GRIB_API_LIBRARIES grib_api ${GRIB_API_EXTRA_LIBRARIES} ${CMATH_LIBRARIES} )
############################################################################################ ############################################################################################
# finalize # finalize

View File

@ -2,29 +2,18 @@ if( SWIG_FOUND )
message( STATUS " SWIG command : [${SWIG_EXECUTABLE}]" ) message( STATUS " SWIG command : [${SWIG_EXECUTABLE}]" )
endif() endif()
if(CMATH_FOUND) foreach( _tpl ${GRIB_API_TPLS} )
message( STATUS " CMath libs : [${CMATH_LIBRARIES}]" ) string( TOUPPER ${_tpl} TPL )
if( ${TPL}_FOUND )
message( STATUS " ${_tpl} ${${_tpl}_VERSION}" )
if( ${TPL}_INCLUDE_DIRS )
message( STATUS " includes : [${${TPL}_INCLUDE_DIRS}]" )
endif() endif()
if( ${TPL}_LIBRARIES )
if( PNG_FOUND ) message( STATUS " libs : [${${TPL}_LIBRARIES}]" )
message( STATUS " PNG libs : [${PNG_LIBRARIES}]" )
message( STATUS " includes : [${PNG_INCLUDE_DIR}]" )
endif() endif()
if( ${TPL}_DEFINITIONS )
if( JASPER_FOUND ) message( STATUS " defs : [${${TPL}_DEFINITIONS}]" )
message( STATUS " Jasper libs : [${JASPER_LIBRARIES}]" )
message( STATUS " includes : [${JASPER_INCLUDE_DIR}]" )
endif() endif()
if( OpenJPEG_FOUND )
message( STATUS " OpenJPEG libs : [${OPENJPEG_LIBRARIES}]" )
message( STATUS " includes : [${OPENJPEG_INCLUDE_DIR}]" )
endif() endif()
endforeach()
if( NETCDF_FOUND )
message( STATUS " NetCDF libs : [${NETCDF_LIBRARIES}]" )
message( STATUS " includes : [${NETCDF_INCLUDE_DIR}]" )
endif()