From db33f237301f60e10ae1e1525df1102a53c23af4 Mon Sep 17 00:00:00 2001 From: James Hilliard Date: Sun, 29 Jan 2023 21:43:50 -0700 Subject: [PATCH] CMake: don't enable CXX unless building tests/benchmarks We only need CXX support when building tests/benchmarks. Fixes: CMake Error at CMakeLists.txt:6 (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: James Hilliard --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a405ea..088ba4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.16 FATAL_ERROR) # ---[ Project -PROJECT(FP16 C CXX) +PROJECT(FP16 C) # ---[ Options. OPTION(FP16_BUILD_TESTS "Build FP16 unit tests" ON) @@ -9,6 +9,10 @@ OPTION(FP16_BUILD_BENCHMARKS "Build FP16 micro-benchmarks" ON) OPTION(FP16_BUILD_COMPARATIVE_BENCHMARKS "Build FP16 micro-benchmarks comparing to alternatives" OFF) # ---[ CMake options +IF(FP16_BUILD_TESTS OR FP16_BUILD_BENCHMARKS) + ENABLE_LANGUAGE(CXX) +ENDIF() + IF(FP16_BUILD_TESTS) ENABLE_TESTING() ENDIF()