From 17509d2ef4ade40b84a969b810b92b77663cf101 Mon Sep 17 00:00:00 2001
From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Date: Sun, 26 Jun 2022 21:31:44 +0200
Subject: [PATCH] CMakeLists.txt: fix build without C++

Fix the following build failure without a C++ compiler:

CMake Error at CMakeLists.txt:24 (project):
  No CMAKE_CXX_COMPILER could be found.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
 CMakeLists.txt     | 2 +-
 src/CMakeLists.txt | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 19897c72..5efc8d45 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,7 +21,7 @@
 #     cmake --build build
 
 cmake_minimum_required(VERSION 3.12)
-project(avrdude VERSION 7.0)
+project(avrdude VERSION 7.0 LANGUAGES C)
 
 set(CMAKE_C_STANDARD 11)
 set(CMAKE_C_STANDARD_REQUIRED True)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index bd3c6dee..f2dfe9cc 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -56,6 +56,8 @@ if(WIN32)
 endif()
 
 if(MSVC)
+    enable_language(CXX)
+
     add_compile_definitions(_CRT_SECURE_NO_WARNINGS=1)
     add_compile_definitions(_CRT_NONSTDC_NO_WARNINGS=1)
     add_compile_definitions(_WINSOCK_DEPRECATED_NO_WARNINGS=1)