--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -614,6 +614,7 @@
 check_symbol_exists(backtrace execinfo.h HAVE_BACKTRACE)
 check_cxx_symbol_exists(abi::__cxa_demangle cxxabi.h HAVE_CXA_DEMANGLE)
 
+if(UNIX)
 # ELF header for ABI detection
 find_file(HAVE_ELF_H elf.h)
 find_file(HAVE_SYS_ELF_H sys/elf.h)
@@ -621,6 +622,7 @@
     set(HAVE_ELF TRUE)
 endif()
 add_feature_info("ELF ABI detection" HAVE_ELF "Automatic probe ABI detection on ELF-based systems. Requires elf.h.")
+endif()
 
 find_package(QmlLint)
 set_package_properties(
