title: CMake unable to determine linker language with C++
body: <p>I'm attempting to run a cmake hello world program on Windows 7 x64 with both Visual Studio 2010 and Cygwin, but can't seem to get either to work. My directory structure is as follows:</p>
  
  <pre><code>HelloWorld
  -- CMakeLists.txt
  -- src/
  -- -- CMakeLists.txt
  -- -- main.cpp
  -- build/
  </code></pre>
  
  <p>I do a <code>cd build</code> followed by a <code>cmake ..</code>, and get an error stating that </p>
  
  <pre><code>CMake Error: CMake can not determine linker language for target:helloworld
  CMake Error: Cannot determine link language for target "helloworld".
  </code></pre>
  
  <p>However, if I change the extension of main.cpp to main.c both on my filsystem and in <code>src/CMakeLists.txt</code> everything works as expected. This is the case running from both the Visual Studio Command Prompt (Visual Studio Solution Generator) and the Cygwin Terminal (Unix Makefiles Generator).</p>
  
  <p>Any idea why this code wouldn't work?</p>
  
  <p>CMakeLists.txt</p>
  
  <pre><code>PROJECT(HelloWorld C)
  cmake_minimum_required(VERSION 2.8)
  
  # include the cmake modules directory
  set(CMAKE_MODULE_PATH ${HelloWorld_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
  
  add_subdirectory(src)
  </code></pre>
  
  <p>src/CMakeLists.txt</p>
  
  <pre><code># Include the directory itself as a path to include directories
  set(CMAKE_INCLUDE_CURRENT_DIR ON)
  
  # Create a variable called helloworld_SOURCES containing all .cpp files:
  set(HelloWorld_SOURCES main.cpp)
  
  # Create an executable file called helloworld from sources:
  add_executable(hello ${HelloWorld_SOURCES })
  </code></pre>
  
  <p>src/main.cpp</p>
  
  <pre><code>int main()
  {
    return 0;
  }
  </code></pre>