CMake Error: CMake can not determine linker language for target: myapp
Solution 1
CMake probably can not determine linker language for target myapp
, because the target does not contain any source files with recognized extensions.
add_executable(myapp vmime)
should be probably replaced by
add_executable(myapp ${VerifyCXX})
Also this command
set_target_properties(${TARGET} PROPERTIES LINKER_LANGUAGE Cxx)
cannot be succesfull, because ${TARGET}
is used-before-set. You should call it after add_executable
set_target_properties(myapp PROPERTIES LINKER_LANGUAGE CXX)
Note that usually it is not needed at all.
Solution 2
For others' benefit, make sure you did not overlook an earlier error such as:
Cannot find source file: MyFirstSourceFile.cpp
Another way to cause CMake to give you the error, "CMake Error: CMake can not determine linker language for target: myapp", is if you mistakenly point it exclusively at sources that do not exist.
For instance: I'm moving files from one directory to another and had the pre-move files with the post-move paths in my CMakeLists.txt. My output window is not very tall and I focused too soon on the "can not determine linker language" error!

Ahsan Roy
Updated on July 23, 2022Comments
-
Ahsan Roy 10 months
I am trying to compile vMime by cmake, but I am getting error above, I am using graphical interface of cmake and my makefiles.txt is below. It configures properly but do not generate
cmake_minimum_required(VERSION 2.8) PROJECT(CXX)#vmime enable_language(CXX) set(VerifyCXX VerifyCXX.cxx) add_definitions(-DVERIFY_CXX) set_target_properties(${TARGET} PROPERTIES LINKER_LANGUAGE Cxx) add_executable(myapp vmime) install(TARGETS myapp DESTINATION bin)
Help will be highly appreciated as I am stuck at point for couple of days.
-
Ahsan Roy almost 8 yearsThankx, that was really useful .