Cmake Unable to Determine Linker Language with C++

CMake unable to determine linker language with C++

Try changing

PROJECT(HelloWorld C)

into

PROJECT(HelloWorld C CXX)

or just

PROJECT(HelloWorld)

See: https://cmake.org/cmake/help/latest/command/project.html

CMake Error: CMake can not determine linker language for target: myapp

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.

CMake cannot determine linker language for target

You have added target for creating container library. That target contains only header files. See CMake documentation

add_library: Add a library to the project using the specified source files.

add_library( [STATIC | SHARED | MODULE]
[EXCLUDE_FROM_ALL]
source1 source2 ... sourceN)

Adds a library target called to be built from the source files listed in the command invocation. The corresponds to the logical target name and must be globally unique within a project. The actual file name of the library built is constructed based on conventions of the native platform (such as lib.a or .lib).

But you can not build library just from header files without any cpp file. That's why you got such error.

CMake can not determine linker language for target: fileloader

Added:
SET_TARGET_PROPERTIES([some name] PROPERTIES LINKER_LANGUAGE C11)
to the end of my program and the error went away. After reading a million web pages I found https://kuniganotas.wordpress.com/2011/05/25/error-cmake-can-not-determine-linker-language-for-target/ and the solution was literally that simple! Hopefully this can help others with this error!

Android Studio Cmake cannot determine linker language for target

If CMakeLists.txt is in src/main/cpp directory (this is how the AS wizard generates a C++ project), then you should say

add_library( # Specifies the name of the library.
iob

# Sets the library as a shared library.
SHARED

# Provides a relative path to your source file(s).
iob.c )

Relative paths to source files are calculated relative to the CMakeLists.txt.

CMake Error: Cannot determine link language for target

Try this in your SmartSingleton/CMakeLists.txt file:

set_target_properties(SmartSingleton PROPERTIES LINKER_LANGUAGE CXX)

This will directly tell CMake which language to use for that target.

If your library is truly only header files though, you will likely receive the error you mention also. Consider making this library an INTERFACE library:

add_library(SmartSingleton INTERFACE)
target_include_directories(SmartSingleton INTERFACE include/)

Here are the docs for INTERFACE libraries.

CMake can not determine linker language for target: azurestorage error

I've given your example a try and the relevant error message is more to the top of CMake's output:

-- Unsupported Build Platform.

So if you want to add it, don't use ExternalProject_Add(). The library's included CMakeLists.txt is for Unix/Linux/OSX.

But it comes with an existing .vcproj for VS2015 which you can include into your project with include_external_msproject():

find_package(Git REQUIRED)
execute_process(
COMMAND "${GIT_EXECUTABLE}" clone https://github.com/Azure/azure-storage-cpp.git
)
set(NUGET_EXECUTABLE "${CMAKE_CURRENT_BINARY_DIR}/azure-storage-cpp/tools/NuGet.exe")
execute_process(
COMMAND "${NUGET_EXECUTABLE}" restore "azure-storage-cpp/Microsoft.WindowsAzure.Storage.v140.sln"
)
include_external_msproject(
azurestorage
"azure-storage-cpp/Microsoft.WindowsAzure.Storage/Microsoft.WindowsAzure.Storage.v140.vcxproj"
)


Related Topics



Leave a reply



Submit