CMake: Fix running tests on MinGW

This commit is contained in:
مهدي شينون (Mehdi Chinoune) 2024-05-06 05:11:38 +01:00
parent f5c9183dd5
commit c5c2d931cc
9 changed files with 28 additions and 24 deletions

View File

@ -110,7 +110,7 @@ macro(add_bin_env_temp_large_test prefix F)
endif()
add_test(${prefix}_${F} bash "-c" "TEMP_LARGE=${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${prefix}_${F}")
if(MSVC)
if(WIN32)
set_property(TARGET ${prefix}_${F} PROPERTY FOLDER "tests")
set_target_properties(${prefix}_${F} PROPERTIES RUNTIME_OUTPUT_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR})
@ -163,7 +163,7 @@ endmacro()
macro(add_bin_test_no_prefix F)
build_bin_test(${F} ${ARGN})
add_test(${F} ${EXECUTABLE_OUTPUT_PATH}/${F})
if(MSVC)
if(WIN32)
set_property(TEST ${F} PROPERTY FOLDER "tests/")
set_target_properties(${F} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
@ -176,7 +176,7 @@ endmacro()
# Binary tests which are used by a script looking for a specific name.
macro(build_bin_test_no_prefix F)
build_bin_test(${F})
if(MSVC)
if(WIN32)
#SET_PROPERTY(TEST ${F} PROPERTY FOLDER "tests/")
set_target_properties(${F} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
@ -201,7 +201,7 @@ macro(add_bin_test prefix F)
add_test(${prefix}_${F}
${EXECUTABLE_OUTPUT_PATH}/${prefix}_${F}
)
if(MSVC)
if(WIN32)
set_property(TEST ${prefix}_${F} PROPERTY FOLDER "tests/")
set_target_properties(${prefix}_${F}
PROPERTIES

View File

@ -8,11 +8,11 @@
# Copy some test files from current source dir to out-of-tree build dir.
FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.sh ${CMAKE_CURRENT_SOURCE_DIR}/*.hdf4)
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
IF(MSVC)
IF(WIN32)
FILE(COPY ${COPY_FILES} DESTINATION ${RUNTIME_OUTPUT_DIRECTORY}/)
ENDIF()
IF(USE_HDF4_FILE_TESTS AND NOT MSVC)
IF(USE_HDF4_FILE_TESTS AND NOT WIN32)
build_bin_test_no_prefix(tst_interops2)
build_bin_test_no_prefix(tst_interops3)
add_bin_test(hdf4_test tst_chunk_hdf4)

View File

@ -50,7 +50,7 @@ set_property(TARGET nc_test PROPERTY UNITY_BUILD OFF)
# Some extra stand-alone tests
SET(TESTS t_nc tst_small tst_misc tst_norm tst_names tst_nofill tst_nofill2 tst_nofill3 tst_meta tst_inq_type tst_utf8_phrases tst_global_fillval tst_max_var_dims tst_formats tst_def_var_fill tst_err_enddef tst_default_format)
IF(NOT MSVC)
IF(NOT WIN32)
SET(TESTS ${TESTS} tst_utf8_validate)
ENDIF()
@ -77,7 +77,7 @@ ENDIF()
IF(LARGE_FILE_TESTS)
SET(TESTS ${TESTS} quick_large_files tst_big_var6 tst_big_var2 tst_big_rvar tst_big_var tst_large tst_large_cdf5)
IF(NOT MSVC)
IF(NOT WIN32)
SET(TESTS ${TESTS} large_files)
ENDIF()
@ -134,7 +134,7 @@ ENDIF(NETCDF_BUILD_UTILITIES)
# Copy some test files from current source dir to out-of-tree build dir.
FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.nc ${CMAKE_CURRENT_SOURCE_DIR}/*.sh)
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
IF(MSVC)
IF(WIN32)
#MESSAGE(STATUS "XXX")
#MESSAGE(STATUS "${COPY_FILES}")
#MESSAGE(STATUS "${RUNTIME_OUTPUT_DIRECTORY}")

View File

@ -49,7 +49,9 @@ IF(USE_HDF5 AND NETCDF_ENABLE_FILTER_TESTING)
build_bin_test(test_filter_order)
build_bin_test(test_filter_repeat)
build_bin_test(tst_filter_vlen)
ADD_SH_TEST(nc_test4 tst_filter)
if(NOT MINGW)
ADD_SH_TEST(nc_test4 tst_filter)
endif()
ADD_SH_TEST(nc_test4 tst_specific_filters)
ADD_SH_TEST(nc_test4 tst_bloscfail)
ADD_SH_TEST(nc_test4 tst_filter_vlen)
@ -78,7 +80,7 @@ ENDIF(${HDF5_VERSION} VERSION_GREATER "1.10.0")
BUILD_BIN_TEST(tst_empty_vlen_unlim)
ADD_SH_TEST(nc_test4 run_empty_vlen_test)
IF(NOT MSVC)
IF(NOT WIN32)
SET(NC4_TESTS ${NC4_TESTS} tst_interops5 tst_camrun)
ENDIF()
@ -104,7 +106,7 @@ ENDIF()
# Copy some test files from current source dir to out-of-tree build dir.
FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.nc ${CMAKE_CURRENT_SOURCE_DIR}/ref_bzip2.c ${CMAKE_CURRENT_SOURCE_DIR}/*.sh ${CMAKE_CURRENT_SOURCE_DIR}/*.h5 ${CMAKE_CURRENT_SOURCE_DIR}/*.cdl)
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
IF(MSVC)
IF(WIN32)
FILE(COPY ${COPY_FILES} DESTINATION ${RUNTIME_OUTPUT_DIRECTORY}/)
ENDIF()

View File

@ -33,7 +33,7 @@ IF(NETCDF_ENABLE_TESTS)
ENDIF(HAVE_BASH)
ENDIF()
IF(NOT MSVC)
IF(NOT WIN32)
add_bin_env_test(ncdap t_dap3a)
add_bin_env_test(ncdap test_cvt)
add_bin_env_test(ncdap test_vara)

View File

@ -71,11 +71,11 @@ endif(NETCDF_ENABLE_DAP)
####
# We have to do a little tweaking
# to remove the Release/ and Debug/ directories
# in MSVC builds. This is required to get
# in Windows builds. This is required to get
# test scripts to work.
####
if(MSVC)
if(WIN32)
macro(setbinprops name)
set_target_properties(${name}
PROPERTIES
@ -127,7 +127,7 @@ endif()
target_link_libraries(tst_fileinfo netcdf ${ALL_TLL_LIBS})
ENDIF()
IF(MSVC)
IF(WIN32)
set_target_properties(rewrite-scalar
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
@ -180,7 +180,7 @@ endif()
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_BINARY_DIR}
)
endif(USE_HDF5)
endif(MSVC)
endif(WIN32)
# Build support programs
build_bin_test_no_prefix(tst_utf8)

View File

@ -51,10 +51,10 @@ TARGET_LINK_LIBRARIES(ncgen netcdf ${ALL_TLL_LIBS})
####
# We have to do a little tweaking
# to remove the Release/ and Debug/ directories
# in MSVC builds. This is required to get
# in Windows builds. This is required to get
# test scripts to work.
####
IF(MSVC)
IF(WIN32)
SET_TARGET_PROPERTIES(ncgen PROPERTIES RUNTIME_OUTPUT_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR})
SET_TARGET_PROPERTIES(ncgen PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG

View File

@ -148,7 +148,7 @@ IF(NETCDF_ENABLE_TESTS)
TARGET_LINK_LIBRARIES(tst_pure_awssdk ${AWSSDK_CORE_LIB_FILE})
ADD_TEST(tst_pure_awssdk ${EXECUTABLE_PUTPUT_PATH}/tst_pure_awssdk)
SET(F tst_pure_awssdk)
IF(MSVC)
IF(WIN32)
SET_PROPERTY(TEST ${F} PROPERTY FOLDER "tests/")
SET_TARGET_PROPERTIES(${F} PROPERTIES RUNTIME_OUTPUT_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR})
@ -156,7 +156,7 @@ IF(NETCDF_ENABLE_TESTS)
${CMAKE_CURRENT_BINARY_DIR})
SET_TARGET_PROPERTIES(${F} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE
${CMAKE_CURRENT_BINARY_DIR})
ENDIF(MSVC)
ENDIF(WIN32)
SET(CMAKE_CXX_STANDARD ${TMP_CMAKE_CXX_STANDARD})
ENDIF(NETCDF_ENABLE_S3_AWS)
@ -210,7 +210,9 @@ IF(NETCDF_ENABLE_TESTS)
build_bin_test(testfilter_order)
build_bin_test(testfilter_repeat)
ADD_SH_TEST(nczarr_test run_nczfilter)
ADD_SH_TEST(nczarr_test run_filter)
if(NOT MINGW)
ADD_SH_TEST(nczarr_test run_filter)
endif()
ADD_SH_TEST(nczarr_test run_specific_filters)
ADD_SH_TEST(nczarr_test run_filter_vlen)
IF(FALSE)

View File

@ -20,10 +20,10 @@ IF(USE_X_GETOPT)
ENDIF()
IF(NETCDF_ENABLE_HDF5)
IF(NOT MSVC)
IF(NOT WIN32)
add_bin_test(unit_test tst_nclist)
add_bin_test(unit_test tst_nc4internal)
ENDIF(NOT MSVC)
ENDIF(NOT WIN32)
build_bin_test(tst_reclaim ${XGETOPTSRC})
add_sh_test(unit_test run_reclaim_tests)
ENDIF(NETCDF_ENABLE_HDF5)