CMake: Build valgrindtest only if Autoconf would. [skip ci]

In partucular, MATRIX_CMAKE=yes subset on Solaris 10 always failed
trying to compile valgrindtest.c without <net/bpf.h>.

(cherry picked from commit 127424a53cc7a0b5c7389068ebb08fa0cd81d436)
diff --git a/testprogs/CMakeLists.txt b/testprogs/CMakeLists.txt
index bf57361..567f42a 100644
--- a/testprogs/CMakeLists.txt
+++ b/testprogs/CMakeLists.txt
@@ -41,7 +41,10 @@
 
 add_test_executable(threadsignaltest ${CMAKE_THREAD_LIBS_INIT})
 
-if(NOT WIN32)
+# Same as in configure.ac.
+if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
+   CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR
+   CMAKE_SYSTEM_NAME STREQUAL "Linux")
   add_test_executable(valgrindtest)
 endif()