CMake unable to determine linker language with C++

后端 未结 10 1700
野趣味
野趣味 2020-11-28 06:41

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

10条回答
  •  死守一世寂寞
    2020-11-28 07:22

    I also got the error you mention:

    CMake Error: CMake can not determine linker language for target:helloworld
    CMake Error: Cannot determine link language for target "helloworld".
    

    In my case this was due to having C++ files with the .cc extension.

    If CMake is unable to determine the language of the code correctly you can use the following:

    set_target_properties(hello PROPERTIES LINKER_LANGUAGE CXX)
    

    The accepted answer that suggests appending the language to the project() statement simply adds more strict checking for what language is used (according to the documentation), but it wasn't helpful to me:

    Optionally you can specify which languages your project supports. Example languages are CXX (i.e. C++), C, Fortran, etc. By default C and CXX are enabled. E.g. if you do not have a C++ compiler, you can disable the check for it by explicitly listing the languages you want to support, e.g. C. By using the special language "NONE" all checks for any language can be disabled. If a variable exists called CMAKE_PROJECT__INCLUDE_FILE, the file pointed to by that variable will be included as the last step of the project command.

提交回复
热议问题