@@ -343,7 +343,7 @@ foreach(kind ${kinds})
343343 amip_interp/include )
344344 target_compile_definitions (${libTgt} _f PRIVATE "${fms_defs} " )
345345 target_compile_definitions (${libTgt} _f PRIVATE "${${kind} _defs}" )
346- set_target_properties (${libTgt} _f PROPERTIES COMPILE_FLAGS ${${kind} _flags})
346+ set_target_properties (${libTgt} _f PROPERTIES COMPILE_FLAGS " ${${kind} _flags}" )
347347 set_target_properties (${libTgt} _f PROPERTIES Fortran_MODULE_DIRECTORY
348348 ${moduleDir} )
349349 target_link_libraries (${libTgt} _f PRIVATE NetCDF::NetCDF_Fortran
@@ -588,6 +588,14 @@ include(CTest)
588588set (MPI_LAUNCHER "mpirun" )
589589# used in the test-lib.sh.in to make it behave differently when parsed by cmake
590590set (USING_CMAKE "true" )
591+ # set the fms library to link tests with based on whats built
592+ if (NOT kinds)
593+ set (fmsLibraryName FMS::fms)
594+ elseif (64BIT)
595+ set (fmsLibraryName FMS::fms_r8)
596+ else ()
597+ set (fmsLibraryName FMS::fms_r4)
598+ endif ()
591599
592600# parse and add build info to test script util file
593601configure_file (${CMAKE_CURRENT_SOURCE_DIR} /test_fms/test -lib.sh.in ${CMAKE_CURRENT_SOURCE_DIR} /test -lib.sh
@@ -610,7 +618,7 @@ list(APPEND TEST_MODS_SRC
610618 test_fms/mpp/test_system_clock.F90)
611619
612620add_library (testLibs "${TEST_MODS_SRC} " )
613- target_link_libraries (testLibs FMS::fms )
621+ target_link_libraries (testLibs ${fmsLibraryName} )
614622target_compile_definitions (testLibs PRIVATE TEST_MOS_KIND_=r8_kind)
615623target_include_directories (testLibs PRIVATE ${CMAKE_CURRENT_BINARY_DIR} /include
616624 PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} /test_fms/fms/include
@@ -776,14 +784,17 @@ list(APPEND TEST_SRC_MULTI_TARGET
776784
777785# add all the test executables and set up linking + compile flags
778786foreach (testFile ${TEST_SRC_SINGLE_TARGET} )
779- get_filename_component (TName ${testFile} NAME_WE )
780787
788+ get_filename_component (TName ${testFile} NAME_WE )
781789 add_executable (${TName} ${testFile} )
782- target_compile_definitions (${TName} PRIVATE "${r8_defs} " )
783- set_target_properties (${TName} PROPERTIES COMPILE_FLAGS ${r8_flags} )
784- target_link_libraries (${TName} PUBLIC FMS::fms
785- PRIVATE testLibs
786- )
790+ target_link_libraries (${TName} PUBLIC ${fmsLibraryName}
791+ PRIVATE testLibs)
792+ if (32BIT)
793+ target_compile_definitions (${TName} PRIVATE "${r4_defs} " )
794+ else ()
795+ target_compile_definitions (${TName} PRIVATE "${r8_defs} " )
796+ set_target_properties (${TName} PROPERTIES COMPILE_FLAGS ${r8_flags} )
797+ endif ()
787798
788799 if (WITH_YAML)
789800 target_link_libraries (${TName} PRIVATE yaml ${LIBYAML_LIBRARIES} )
@@ -808,16 +819,14 @@ foreach (testFile ${TEST_SRC_MULTI_TARGET})
808819 add_executable (${TName} _r8 ${testFile} )
809820 target_compile_definitions (${TName} _r8 PRIVATE "${r8_defs} " )
810821 set_target_properties (${TName} _r8 PROPERTIES COMPILE_FLAGS ${r8_flags} )
811- target_link_libraries (${TName} _r8 PUBLIC FMS::fms
812- PRIVATE testLibs
813- )
814-
822+ target_link_libraries (${TName} _r8 PUBLIC ${fmsLibraryName}
823+ PRIVATE testLibs)
815824 add_executable (${TName} _r4 ${testFile} )
816825 target_compile_definitions (${TName} _r4 PRIVATE "${r4_defs} " )
817826 # seems counterintuitive but r4 tests use r8 default
818827 # they specify kind values explicitly with the preprocessor where needed (TEST_FMS_KIND_)
819828 set_target_properties (${TName} _r4 PROPERTIES COMPILE_FLAGS ${r8_flags} )
820- target_link_libraries (${TName} _r4 PUBLIC FMS::fms
829+ target_link_libraries (${TName} _r4 PUBLIC ${fmsLibraryName}
821830 PRIVATE testLibs
822831 )
823832
0 commit comments