Cmake Visual Studio 2015 Identification Unknown - c++

So basically i am trying to use Cmake to build a project i am working on, the project uses GLEW (as shared library). GLEW links to both glu32.lib and opengl32.lib. They are added to the CMakelists.txt of glew on the target_link_libraries call like:
target_link_libraries(glew PUBLIC opengl32 glu32)
When i try to generate code for using the viusal studio compiler (2015 Community). I get problems with CMake adding the link libraries to the Visual studio project with -lopengl32 and -lglue32. This is wrong since visual studio cant handle this and gives met the following error when trying to compile:
LINK : warning LNK4044: unrecognized option '/lglu32.lib';
LINK : warning LNK4044: unrecognized option '/lopengl32.lib';
The output of running the Visual Studio Generator is:
C:\Project\build>cmake .. -G "Visual Studio 14 2015 Win64"
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler using: Visual Studio 14 2015 Win64
-- Check for working C compiler using: Visual Studio 14 2015 Win64 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Visual Studio 14 2015 Win64
-- Check for working CXX compiler using: Visual Studio 14 2015 Win64 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found OpenGL: opengl32
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Project/build
The following two lines:
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
seem quite odd to me since it is able to run the Visual Studio compiler. I read something about this being the cause of the invalid -l addition to the linker.
Is there anyone that had this problem and knows how to solve it?
Thanks in advance
CMakeError.txt:
Compilation of the C compiler identification source "CMakeCCompilerId.c" did not produce an executable in "C:Project/build/CMakeFiles/3.5.2/CompilerIdC".
Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" did not produce an executable in "C:/Project/build/CMakeFiles/3.5.2/CompilerIdCXX".

After spending some time searching i fixed it! The actual path of the project i was trying to build contained a SPACE in its path. Appearantly CMake can't handle this.

Related

CMake cant find instance of Visual Studio 15 2017 generator, but works fine with Visual Studio 16 2019

Similar to CMake: Visual Studio 15 2017 could not find any instance of Visual Studio but in my case I've got my main installations version of MSVC generator working. It's the 2017 generator that doesn't seem to be working for me. Here is my installation setup:
My understanding is that this should work, I should have the appropriate tools.
When I run cmake -G "Visual Studio 16 2019" ../
I get
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
-- The C compiler identification is MSVC 19.28.29337.0
-- The CXX compiler identification is MSVC 19.28.29337.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/.../build
Looks good so far. But when I run cmake -G "Visual Studio 15 2017" ../
I get
CMake Error at CMakeLists.txt:2 (project):
Generator
Visual Studio 15 2017
could not find any instance of Visual Studio.
-- Configuring incomplete, errors occurred!
See also "C:/.../build/CMakeFiles/CMakeOutput.log".
I'm currently use this version of cmake:
cmake -version
cmake version 3.20.0-rc2
CMake suite maintained and supported by Kitware (kitware.com/cmake).
so I should have all the latest methods of using cmake.
I know I could manually configure the generators, but that sticks with the cmake cache and gets deleted constantly, and I was under the impression CMake could handle multiple visual studio instances with out such manual tuning, and that I should be able to use environment variables to point to each one at the very least, though that also doesn't appear to be working.
If you want to generate targeting the Visual Studio 2017 platform toolset (v141), but using Visual Studio 2019 as the generator, you'd use the following CMake generate command
cmake -G "Visual Studio 16 2019" -T v141 ..
I think this is a case of unfortunate naming. Installing the "VS 2017 C++ x64/x86 build tools" only installs the compiler, linker and standard libraries and not actually the entire "Visual Studio Build Tools 2017" which include MSBuild. But you need the latter to use the "Visual Studio 15 2017" generator. You can find the installer for the 2017 build tools at https://aka.ms/vs/15/release/vs_buildtools.exe

Qt Cmake error compilation "GuiSupportQt not found"

I'm new to Qt and i already have a problem so i start to create a simple UI for my VTK project, first of all, i tested a sample project UI designed by Qt in Qt 5.5.0 and compiled in Cmake 3.10 and VS2013 programmed with C++, and i've got a line after compiling with Cmake before "Configuration done" saying that"GuiSupportQt not found." i ignored it and generated solution then i gone to VS2013 to compile the solution provided by Cmake , i didn't find my project after opening solution in VS2013, i found only the common 2 projects that are named ALL_BUILD and ZERO_CHECK.
For more info, i've compiled before a non Gui project (3d vtk visualisation with vtk rendered without Qt) which is my own homework project and i've got a successful results which means in my opinion that the problem appears exactly when i compile a project that uses Qt considering that my Qt-VTK are compiled before with Cmake and built with VS2013 without any errors.
This is the code of Qt project sample that i used to test :
https://vtk.org/Wiki/VTK/Examples/Cxx/Qt/RenderWindowUISingleInheritance
This is what i get when i try to compile it with Cmake :
The C compiler identification is MSVC 18.0.21005.1
The CXX compiler identification is MSVC 18.0.21005.1
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
VTK_VERSION: 7.1.1
GuiSupportQt not found.
Configuring done
Generating done
After looking a while i found out another tricky solution to evade problems since i had Vtk visualisation part work fine and i work on windows, so i just sent parameters via command in cmd using Qt gui and then Vtk project compiled exe file will take parameters in execution (iso-value,data folder name..ect) in argv[] array then launch it in a new window, so i didn't have to compile Qt project with Cmake.

AMQP-CPP RabbitMQ Build Integrating to CPP Project

Hi I currently try to integrate RabbitMQ via AMQPCPP into my VisualStudio Project. I am restricted to use a Windows PC which is a pain in the ass for the installation.
I think I was able to build the Project using CMAKE But I received some Error doing it . Now I am trying to include the build into the VS2017 Project. In the Readme https://github.com/CopernicaMarketingSoftware/AMQP-CPP this is done using
#include <amqpcpp.h>
But this header is not found in my build. I am not used to CPP so I hope I havent done some rudimental error. Thanks in advance!
Steps to build AMQP-CPP using CMake in Windows - Visual Studio 2017
Open command prompt and switch to AMQP-CPP git/source path.
1) >mkdir build
2) >cd build
3) >cmake -G "Visual Studio 15 2017 Win64" ..\
-- Selecting Windows SDK version 10.0.15063.0 to target Windows 6.1.7601.
-- The C compiler identification is MSVC 19.10.25019.0
-- The CXX compiler identification is MSVC 19.10.25019.0
-- Check for working C compiler: E:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.10.25017/bin/HostX86/x64/cl.exe
-- Check for working C compiler: E:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.10.25017/bin/HostX86/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: E:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.10.25017/bin/HostX86/x64/cl.exe
-- Check for working CXX compiler: E:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.10.25017/bin/HostX86/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Projects/AMQP-CPP/build
4) >cmake --build . --target ALL_BUILD --config RELEASE --clean-first -- /m
Build succeeded.
"D:\Projects\AMQP-CPP\build\ALL_BUILD.vcxproj" (default target) (1) -> "D:\Projects\AMQP-CPP\build\amqpcpp.vcxproj" (default target) (3) -> (ClCompile target) ->
D:\Projects\AMQP-CPP\src\deferredreceiver.cpp(48): warning C424
4: 'argument': conversion from 'uint64_t' to 'uint32_t', possible loss o
f data [D:\Projects\AMQP-CPP\build\amqpcpp.vcxproj]
1 Warning(s)
0 Error(s)
Time Elapsed 00:00:44.16
How to include amqpcpp in your project
Edit your project CMakeLists.txt file for adding amqpcpp include path and library path for linking.
include_directories(../include)
link_directories(../build/bin/Release)
Include and link directory path may differ based on actual location in your machine.

CMake: How to specify VS2015.3 toolset with VS2017 installed

I have VS2017 installed, with both VS2017 (v141) and VS2015.3 (v140) toolset installed. I need to generate a solution with CMake and I want CMake to be "fooled" as if VS2015 is installed, so I can build the project with v140 toolset.
I know this question is possibly a duplicate of:
How cmake specify "Platform Toolset" for a Visual Studio 2015 project?
But the solution it provides doesn't help me.
The error messages are:
Selecting Windows SDK version 10.0.14393.0 to target Windows 10.0.15063.
The C compiler identification is unknown
The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:18 (project):
No CMAKE_C_COMPILER could be found.
I tried installing both VS2017 and VS2015.3 (IDE), but VS2015.3 refused to create even a simple console program.
Is there another way to generate a solution with v140 toolset?
(P.S. Don't tell me that I should generate with v141 toolset first and modify the toolset option in Visual Studio. That makes a big difference. )
I've just ran a test and it works for me with the following settings in CMake's GUI (Version 3.10.0 RC4):
Then I get the following output:
The CXX compiler identification is MSVC 19.0.24215.1
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Configuring done
Generating done
And if I open the resulting solution it will - as expected - ask me:
Platform Toolset Mapping
From Marco Foco: Microsoft Visual C++ version Map:
If that don't work ...
First please check the CMakeError.log in your binary output directory. The error should give you a lead on what's wrong.
If that's not helping, you can try several things (besides re-installing VS, which I think won't solve the problem):
One of the Windows SDKs is not fully/correclty installed; Reinstall from Microsoft's web site
Try to give the cmake-gui administrative rights
Check if there is a GNU toolchain with GCC compiler in your PATH environment.
References
VS 2010 and CMake: 'rc' is not recognized as an internal or external command
MSBuild.exe has stopped cmake error
Environment variable used by CMake to detect Visual C++ compiler tools for Ninja

Cannot set toolset to the new v140_clang_3_7 in Visual Studio 2015 Update 1 CMake

So I just downloaded the new Visual Studio Update 1 and am trying to get CMake to generate the correct platform toolset.
New in Update 1 there is a new toolset: Clang 3.7 with Microsoft CodeGen
Pretty exciting, huh!
Anyway, I am trying to get CMake to generate the correct toolset here.
ASSUMPTION 1: The name of the toolset that CMake would accept is v140_clang_3_7. I assume this because that is what is in parenthesis, and that is what is used in other toolsets, like v120 etc.
So I setup a simple test case:
C:\Users\russe\Documents\TestCMAKECLANG>ls
CMakeLists.txt main.cpp
C:\Users\russe\Documents\TestCMAKECLANG>cat CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
add_executable(TestEXE main.cpp)
C:\Users\russe\Documents\TestCMAKECLANG>cat main.cpp
// use some fancy c++14 feature that VS doesn't have
template<typename T>
constexpr T doThing{};
int main(){}
C:\Users\russe\Documents\TestCMAKECLANG>
Next, I run CMake with the correct arguments:
ASSUMPTION 2: I have the correct arguments
C:\Users\russe\Documents\TestCMAKECLANG>cmake -G "Visual Studio 14 2015" -T "v140_clang_3_7"
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error in :
No CMAKE_C_COMPILER could be found.
CMake Error in :
No CMAKE_CXX_COMPILER could be found.
-- Configuring incomplete, errors occurred!
See also "C:/Users/russe/Documents/TestCMAKECLANG/CMakeFiles/CMakeOutput.log".
See also "C:/Users/russe/Documents/TestCMAKECLANG/CMakeFiles/CMakeError.log".
C:\Users\russe\Documents\TestCMAKECLANG>
Say WHAT! No CMAKE_C_COMPILER or CMAKE_CXX_COMPILER found.
So that doesn't work. Lets see, it could be just that -T isn't working properly. Lets test with v120
C:\Users\russe\Documents\TestCMAKECLANG>cmake -G "Visual Studio 14 2015" -T "v120"
-- The C compiler identification is MSVC 18.0.31010.0
-- The CXX compiler identification is MSVC 18.0.31010.0
-- Check for working C compiler using: Visual Studio 14 2015
-- Check for working C compiler using: Visual Studio 14 2015 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Visual Studio 14 2015
-- Check for working CXX compiler using: Visual Studio 14 2015 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/russe/Documents/TestCMAKECLANG
C:\Users\russe\Documents\TestCMAKECLANG>
Works like a newborn baby. Hmm.
Alright guys, whats next?
I've looked into this and it doesn't look too bad. I've pushed a first prototype that's able to compile a real simple program.
I'll keep working on fixing things, but hopefully it can be a start to figure out the rest of the work needed.
There are two ways to invoke Clang.
The first one is to specify the toolset from the command-line
cmake -G "Visual Studio 14 2015" -T v140_clang_3_7 ...
The second one is to set a target property on a project to have that one specifically use the Clang toolchain
set_property(TARGET ${project} PROPERTY VS_PLATFORM_TOOLSET_OVERRIDE "v140_clang_3_7")