# Misleading error message in try\_run

**URL:** https://discourse.cmake.org/t/misleading-error-message-in-try-run/7831
**Category:** Usage
**Created:** [April 5, 2023, 7:21am UTC](https://discourse.cmake.org/t/misleading-error-message-in-try-run/7831 "2023-04-05T07:21:42Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![codeling](https://discourse.cmake.org/user_avatar/discourse.cmake.org/codeling/32/1700_2.png) [@codeling](https://discourse.cmake.org/u/codeling)
#### Post date: [April 5, 2023, 7:21am UTC](https://discourse.cmake.org/t/misleading-error-message-in-try-run/7831/1 "2023-04-05T07:21:43Z")

</div>

I am trying to run a very simple C++ program during configuration. My first attempt:

Test.cxx:

```auto
#include <iostream>

int main()
{
   std::cout << "test" << std::endl;
}

```

CMakeLists.txt

```auto
cmake_minimum_required(VERSION 3.14)

project(test LANGUAGES CXX)

try_run(
	RUN_RESULT
	COMPILE_RESULT
	${CMAKE_SOURCE_DIR}/Test.cxx
	COMPILE_OUTPUT_VARIABLE COMPILEOUT
	RUN_OUTPUT_VARIABLE RUNOUT
)

```

But got this:

```auto
CMake Error ...
  The test project needs language C which is not enabled.

```

I was confused by the message and first thought I needed to tell try\_run somehow which language it needs to compile, but couldn’t find any according information in the documentation…

I then realized that I had forgot to specify `SOURCES` in front of my .cxx file. I know it was my stupid mistake, but if possible, it might help future users to get a more meaningful error message, such as “No source files specified” in that case?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [April 24, 2023, 4:22am UTC](https://discourse.cmake.org/t/misleading-error-message-in-try-run/7831/2 "2023-04-24T04:22:39Z")

</div>

Cc: @Matthew_Woehlke
