CMake: fortran and examples features

This commit is contained in:
Shahram Najm 2015-06-09 14:50:51 +01:00
parent 4a53d7cfa2
commit 76bd03e33a
6 changed files with 26 additions and 15 deletions

View File

@ -12,7 +12,6 @@ project( eccodes C )
set( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../ecbuild/cmake") set( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../ecbuild/cmake")
#set( ECCODES_INSTALL_INCLUDE_DIR include CACHE PATH "ecCodes override installation directory for header files")
include( ecbuild_system ) include( ecbuild_system )
@ -26,6 +25,11 @@ ecbuild_declare_project()
############################################################################### ###############################################################################
# some variables/options of this project # some variables/options of this project
ecbuild_add_option( FEATURE EXAMPLES
DESCRIPTION "Build the examples"
DEFAULT ON
)
ecbuild_add_option( FEATURE JPG ecbuild_add_option( FEATURE JPG
DESCRIPTION "support for JPG decoding/encoding" DESCRIPTION "support for JPG decoding/encoding"
DEFAULT ON DEFAULT ON
@ -59,17 +63,22 @@ ecbuild_add_option( FEATURE AEC
ecbuild_add_option( FEATURE PYTHON ecbuild_add_option( FEATURE PYTHON
DESCRIPTION "build the ecCodes Python interface" DESCRIPTION "build the ecCodes Python interface"
DEFAULT ON DEFAULT ON
# REQUIRED_LANGUAGES Python # TODO
) )
ecbuild_add_option( FEATURE FORTRAN ecbuild_add_option( FEATURE FORTRAN
DESCRIPTION "build the ecCodes Fortran interface" DESCRIPTION "build the ecCodes Fortran interface"
DEFAULT ON DEFAULT ON
# REQUIRED_LANGUAGES Fortran # TODO
) )
# TODO Remove this after REQUIRED_LANGUAGES
if( ENABLE_FORTRAN ) if( ENABLE_FORTRAN )
# will set EC_HAVE_FORTRAN with the result # will set EC_HAVE_FORTRAN with the result
ecbuild_enable_fortran( MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/fortran/modules ) ecbuild_enable_fortran( MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/fortran/modules )
set( HAVE_FORTRAN ${EC_HAVE_FORTRAN} ) set( HAVE_FORTRAN ${EC_HAVE_FORTRAN} )
else()
set( HAVE_FORTRAN 0 )
endif() endif()
# advanced options (not visible in cmake-gui ) # advanced options (not visible in cmake-gui )

View File

@ -1,4 +1,6 @@
add_subdirectory(C) if( HAVE_EXAMPLES )
add_subdirectory(F90) add_subdirectory(C)
add_subdirectory(python) add_subdirectory(F90)
add_subdirectory(python)
endif()

View File

@ -50,7 +50,7 @@ list( APPEND tests
# SOURCES samples.f90 # SOURCES samples.f90
# LIBS eccodes_f90 eccodes # LIBS eccodes_f90 eccodes
# COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/samples.sh # COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/samples.sh
# CONDITION EC_HAVE_FORTRAN # CONDITION HAVE_FORTRAN
# ) # )
foreach( tool ${tests} ) foreach( tool ${tests} )
@ -59,7 +59,7 @@ foreach( tool ${tests} )
ecbuild_add_executable( TARGET f_${tool} ecbuild_add_executable( TARGET f_${tool}
NOINSTALL NOINSTALL
SOURCES ${tool}.f90 SOURCES ${tool}.f90
CONDITION EC_HAVE_FORTRAN CONDITION HAVE_FORTRAN
LINKER_LANGUAGE Fortran LINKER_LANGUAGE Fortran
LIBS eccodes_f90 eccodes LIBS eccodes_f90 eccodes
) )
@ -67,7 +67,7 @@ foreach( tool ${tests} )
ecbuild_add_test( TARGET f_${tool}_test ecbuild_add_test( TARGET f_${tool}_test
TYPE SCRIPT TYPE SCRIPT
DEPENDS f_${tool} DEPENDS f_${tool}
CONDITION EC_HAVE_FORTRAN CONDITION HAVE_FORTRAN
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${tool}.sh COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${tool}.sh
RESOURCES include.sh RESOURCES include.sh
TEST_DEPENDS get_gribs get_bufrs TEST_DEPENDS get_gribs get_bufrs
@ -79,21 +79,21 @@ endforeach()
ecbuild_add_executable( TARGET f_new_from_file ecbuild_add_executable( TARGET f_new_from_file
NOINSTALL NOINSTALL
SOURCES new_from_file.f90 SOURCES new_from_file.f90
CONDITION EC_HAVE_FORTRAN CONDITION HAVE_FORTRAN
LINKER_LANGUAGE Fortran LINKER_LANGUAGE Fortran
LIBS eccodes_f90 eccodes LIBS eccodes_f90 eccodes
) )
ecbuild_add_executable( TARGET f_copy_namespace ecbuild_add_executable( TARGET f_copy_namespace
NOINSTALL NOINSTALL
SOURCES copy_namespace.f90 SOURCES copy_namespace.f90
CONDITION EC_HAVE_FORTRAN CONDITION HAVE_FORTRAN
LINKER_LANGUAGE Fortran LINKER_LANGUAGE Fortran
LIBS eccodes_f90 eccodes LIBS eccodes_f90 eccodes
) )
ecbuild_add_executable( TARGET f_set_gvc ecbuild_add_executable( TARGET f_set_gvc
NOINSTALL NOINSTALL
SOURCES set_gvc.f90 SOURCES set_gvc.f90
CONDITION EC_HAVE_FORTRAN CONDITION HAVE_FORTRAN
LINKER_LANGUAGE Fortran LINKER_LANGUAGE Fortran
LIBS eccodes_f90 eccodes LIBS eccodes_f90 eccodes
) )

View File

@ -1,4 +1,4 @@
if( EC_HAVE_FORTRAN ) if( HAVE_FORTRAN )
set( srcdir ${CMAKE_CURRENT_SOURCE_DIR} ) set( srcdir ${CMAKE_CURRENT_SOURCE_DIR} )
set( bindir ${CMAKE_CURRENT_BINARY_DIR} ) set( bindir ${CMAKE_CURRENT_BINARY_DIR} )

View File

@ -18,9 +18,9 @@ if( HAVE_PYTHON )
set(PYTHON_DEST "${INSTALL_LIB_DIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/eccodes" ) set(PYTHON_DEST "${INSTALL_LIB_DIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/eccodes" )
file( RELATIVE_PATH relative_rpath "${CMAKE_INSTALL_PREFIX}/${PYTHON_DEST}" "${${PNAME}_FULL_INSTALL_LIB_DIR}" ) file( RELATIVE_PATH relative_rpath "${CMAKE_INSTALL_PREFIX}/${PYTHON_DEST}" "${${PNAME}_FULL_INSTALL_LIB_DIR}" )
# debug_var( relative_rpath ) # debug_var( relative_rpath )
ecbuild_append_to_rpath( ${relative_rpath} ) ecbuild_append_to_rpath( ${relative_rpath} )
ecbuild_append_to_rpath( "../../lib" ) # for ctest to find the libs ecbuild_append_to_rpath( "../../lib" ) # for ctest to find the libs

View File

@ -13,5 +13,5 @@ set( ECCODES_SAMPLES_FILES ${ECCODES_SAMPLES_FILES} PARENT_SCOPE )
# copy the samples to the build directory # copy the samples to the build directory
file( COPY ${samples_files} file( COPY ${samples_files}
DESTINATION ${CMAKE_BINARY_DIR}/share/${PROJECT_NAME}/samples ) DESTINATION ${CMAKE_BINARY_DIR}/share/${PROJECT_NAME}/samples )