CMake can not determine linker language for target

2019-08-07 01:39发布

问题:

I'm very new to C++ programming and having some trouble using CMake to add the azure-storage-cpp repository to my VS solution.

Here is the build error I am getting in VS, when I attempt to build the azure storage project.

CMake can not determine linker language for target: azurestorage

Here is my CMake entry:

ExternalProject_Add( azurestorage
  PREFIX azurestorage
  GIT_REPOSITORY https://github.com/Azure/azure-storage-cpp.git
  GIT_TAG master
  SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../azurestorage
  SOURCE_SUBDIR Microsoft.WindowsAzure.Storage)

I tried adding SET_TARGET_PROPERTIES(azurestorage PROPERTIES LINKER_LANGUAGE CXX) to my CMakeList.txt file but it doesn't help. I've also read on other forums that the repo needs to have a .cpp and .h file in the root directory for CMake to know which language. However since the azure-storage-cpp repo isn't mine, I don't have the ability to add such files.

I'm using VS2015 on Windows10

What am I doing wrong? Any and all help is appreciated.

回答1:

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"
)


标签: c++ azure cmake