Skip to content

Commit

Permalink
Add options to disable compilation of parkind_(sp,dp)
Browse files Browse the repository at this point in the history
  • Loading branch information
wdeconinck committed Feb 5, 2024
1 parent ac9c2c3 commit 5402cb3
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 18 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ ecbuild_add_option( FEATURE DR_HOOK_MULTI_PRECISION_HANDLES
DESCRIPTION "[DEPRECATED] Support single precision handles for DR_HOOK"
DEFAULT OFF )

ecbuild_add_option( FEATURE DOUBLE_PRECISION
DEFAULT ON
DESCRIPTION "Compilation of parkind_dp" )

ecbuild_add_option( FEATURE SINGLE_PRECISION
DEFAULT ON
DESCRIPTION "Compilation of parkind_sp" )

ecbuild_add_option( FEATURE WARNINGS
DEFAULT ON
DESCRIPTION "Add warnings to compiler" )
Expand Down
14 changes: 14 additions & 0 deletions cmake/fiat-import.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ set( fiat_VERSION_STR @fiat_VERSION_STR@ )
set( fiat_HAVE_MPI @fiat_HAVE_MPI@ )
set( fiat_HAVE_OMP @fiat_HAVE_OMP@ )
set( fiat_HAVE_FCKIT @fckit_HAVE_FCKIT@ )
set( fiat_HAVE_SINGLE_PRECISION @fiat_HAVE_SINGLE_PRECISION@ )
set( fiat_HAVE_DOUBLE_PRECISION @fiat_HAVE_DOUBLE_PRECISION@ )
set( fiat_SOURCE_FILENAMES @fiat_SOURCE_FILENAMES@ )

if( fiat_HAVE_OMP AND NOT TARGET OpenMP::OpenMP_Fortran )
Expand All @@ -36,3 +38,15 @@ else()
set(_no_whole_archive "-Wl,--no-whole-archive")
endif()
set(MPI_SERIAL_LIBRARIES ${_whole_archive} mpi_serial ${_no_whole_archive})

##################################################################
## Handle components

set( ${CMAKE_FIND_PACKAGE_NAME}_single_FOUND ${fiat_HAVE_SINGLE_PRECISION} )
set( ${CMAKE_FIND_PACKAGE_NAME}_double_FOUND ${fiat_HAVE_DOUBLE_PRECISION} )

foreach( _component ${${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS} )
if( NOT ${CMAKE_FIND_PACKAGE_NAME}_${_component}_FOUND AND ${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED )
message( SEND_ERROR "fiat was not build with support for COMPONENT ${_component}" )
endif()
endforeach()
37 changes: 21 additions & 16 deletions src/parkind/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,30 @@
# granted to it by virtue of its status as an intergovernmental organisation
# nor does it submit to any jurisdiction.

foreach( target parkind_sp parkind_dp )
set( HAVE_dp ${HAVE_DOUBLE_PRECISION} )
set( HAVE_sp ${HAVE_SINGLE_PRECISION} )

ecbuild_add_library(
TARGET ${target}
SOURCES parkind1.F90
parkind2.F90
)
foreach( prec sp dp )
if( HAVE_${prec} )
set( target parkind_${prec} )
ecbuild_add_library(
TARGET ${target}
SOURCES parkind1.F90
parkind2.F90
)

fiat_target_fortran_module_directory(
TARGET ${target}
MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/module/${target}
INSTALL_DIRECTORY module/${target}
)
if( EC_OS_BITS EQUAL "64" )
target_compile_definitions( ${target} PRIVATE ADDRESS64 )
endif()

if( EC_OS_BITS EQUAL "64" )
target_compile_definitions( parkind_sp PRIVATE ADDRESS64 )
fiat_target_fortran_module_directory(
TARGET ${target}
MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/module/${target}
INSTALL_DIRECTORY module/${target}
)
endif()

endforeach()

target_compile_definitions( parkind_sp PRIVATE PARKIND1_SINGLE )

if( TARGET parkind_sp )
target_compile_definitions( parkind_sp PRIVATE PARKIND1_SINGLE )
endif()
8 changes: 6 additions & 2 deletions tests/test-install.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,12 @@ cmake $SOURCE \

make VERBOSE=1

bin/main_dp
bin/main_sp
if [ -f bin/main_dp ] ; then
bin/main_dp
fi
if [ -f bin/main_sp ] ; then
bin/main_sp
fi

{ set +ex; } 2>/dev/null
echo "+++++++++++++++++"
Expand Down
4 changes: 4 additions & 0 deletions tests/test_install/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ project( fiat_test_install VERSION 0.0.0 LANGUAGES Fortran )

find_package( fiat REQUIRED )

if( TARGET parkind_dp )
ecbuild_add_executable( TARGET main_dp
SOURCES main.F90
LIBS fiat parkind_dp )
endif()

if( TARGET parkind_sp )
ecbuild_add_executable( TARGET main_sp
SOURCES main.F90
LIBS fiat parkind_sp )
endif()

0 comments on commit 5402cb3

Please sign in to comment.