Skip to content

Commit 13dd79c

Browse files
Erik LindahlGerrit Code Review
Erik Lindahl
authored and
Gerrit Code Review
committed
Fix compiler warnings in cmake tests
This will not be visible to users, and it won't make it possible to run cmake with -Werror since lots of internal tests do not work, but since I fixed a couple of them we might as well put it in gerrit. Known remaining issues: - HAVE_LIBM Refs #1750. Change-Id: I734f83f229108e50e2914d455f4032137f924773
1 parent 536e65b commit 13dd79c

9 files changed

+30
-24
lines changed

CMakeLists.txt

+15-15
Original file line numberDiff line numberDiff line change
@@ -336,21 +336,21 @@ check_include_files(regex.h HAVE_POSIX_REGEX)
336336
# TODO: It could be nice to inform the user if no regex support is found,
337337
# as selections won't be fully functional.
338338

339-
include(CheckFunctionExists)
340-
check_function_exists(posix_memalign HAVE_POSIX_MEMALIGN)
341-
check_function_exists(memalign HAVE_MEMALIGN)
342-
check_function_exists(_aligned_malloc HAVE__ALIGNED_MALLOC)
343-
check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
344-
check_function_exists(fsync HAVE_FSYNC)
345-
check_function_exists(_fileno HAVE__FILENO)
346-
check_function_exists(fileno HAVE_FILENO)
347-
check_function_exists(_commit HAVE__COMMIT)
348-
check_function_exists(sigaction HAVE_SIGACTION)
349-
check_function_exists(sysconf HAVE_SYSCONF)
350-
check_function_exists(rsqrt HAVE_RSQRT)
351-
check_function_exists(rsqrtf HAVE_RSQRTF)
352-
check_function_exists(sqrtf HAVE_SQRTF)
353-
check_function_exists(nice HAVE_NICE)
339+
include(CheckCXXSymbolExists)
340+
check_cxx_symbol_exists(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
341+
check_cxx_symbol_exists(memalign stdlib.h HAVE_MEMALIGN)
342+
check_cxx_symbol_exists(_aligned_malloc stdlib.h HAVE__ALIGNED_MALLOC)
343+
check_cxx_symbol_exists(gettimeofday sys/time.h HAVE_GETTIMEOFDAY)
344+
check_cxx_symbol_exists(sysconf unistd.h HAVE_SYSCONF)
345+
check_cxx_symbol_exists(nice unistd.h HAVE_NICE)
346+
check_cxx_symbol_exists(fsync unistd.h HAVE_FSYNC)
347+
check_cxx_symbol_exists(_fileno stdio.h HAVE__FILENO)
348+
check_cxx_symbol_exists(fileno stdio.h HAVE_FILENO)
349+
check_cxx_symbol_exists(_commit io.h HAVE__COMMIT)
350+
check_cxx_symbol_exists(sigaction signal.h HAVE_SIGACTION)
351+
check_cxx_symbol_exists(rsqrt math.h HAVE_RSQRT)
352+
check_cxx_symbol_exists(rsqrtf math.h HAVE_RSQRTF)
353+
check_cxx_symbol_exists(sqrtf math.h HAVE_SQRTF)
354354

355355
include(CheckLibraryExists)
356356
check_library_exists(m sqrt "" HAVE_LIBM)

cmake/TestAVXMaskload.c

+1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ int main()
1313
#else
1414
a = _mm256_maskload_pd(d,mask);
1515
#endif
16+
return 0;
1617
}
1718

cmake/TestFileOffsetBits.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include <sys/types.h>
22

3-
int main(int argc, char **argv)
3+
int main()
44
{
55
/* Cause a compile-time error if off_t is smaller than 64 bits */
66
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
77
int off_t_is_large[ (LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1 ];
8-
return 0;
8+
return off_t_is_large[0];
99
}
1010

cmake/TestFloatFormat.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ volatile const double abc [10] = {
4848
(double) -5.22995989424860458374e+10, (double) 0.0,
4949
};
5050

51+
/* Check that a double is 8 bytes - compilation dies if it isnt */
52+
extern char xyz [sizeof(double) == 8 ? 1 : -1];
53+
5154
int
5255
main()
5356
{
54-
/* Check that a double is 8 bytes - compilation dies if it isnt */
55-
extern char xyz [sizeof(double) == 8 ? 1 : -1];
5657
int i;
5758
double d;
5859

cmake/TestLargeFiles.c.cmakein

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ int main(int argc, char **argv)
1919

2020
fseeko( fp, offset, SEEK_CUR );
2121
fclose(fp);
22-
return 0;
22+
return off_t_is_large[0] || argc;
2323
}
2424

cmake/TestPipes.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ main()
66
FILE *fp;
77

88
fp = popen("/tmp/xyz","r");
9-
return 0;
9+
return (fp==NULL);
1010
}

cmake/TestXDR.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
int
55
main()
66
{
7-
XDR *xd;
7+
/* This should only compile, not run, so set xd to NULL */
8+
XDR *xd = NULL;
89
float f;
910
xdr_float(xd,&f);
11+
return 0;
1012
}

cmake/gmxTestIsfinite.cmake

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# This file is part of the GROMACS molecular simulation package.
33
#
4-
# Copyright (c) 2012,2014, by the GROMACS development team, led by
4+
# Copyright (c) 2012,2014,2015, by the GROMACS development team, led by
55
# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
66
# and including many others, as listed in the AUTHORS file in the
77
# top-level source directory and at http://www.gromacs.org.
@@ -61,6 +61,7 @@ MACRO(gmx_test_isfinite VARIABLE)
6161
int main(void) {
6262
float f;
6363
isfinite(f);
64+
return 0;
6465
}" isfinite_compile_ok)
6566

6667
if(isfinite_compile_ok)

cmake/gmxTestdlopen.cmake

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# This file is part of the GROMACS molecular simulation package.
33
#
4-
# Copyright (c) 2012, by the GROMACS development team, led by
4+
# Copyright (c) 2012,2015, by the GROMACS development team, led by
55
# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
66
# and including many others, as listed in the AUTHORS file in the
77
# top-level source directory and at http://www.gromacs.org.
@@ -49,6 +49,7 @@ MACRO(GMX_TEST_DLOPEN VARIABLE)
4949
"#include <dlfcn.h>
5050
int main(void) {
5151
dlopen(0,0);
52+
return 0;
5253
}" ${VARIABLE})
5354

5455
IF(${VARIABLE})

0 commit comments

Comments
 (0)