I'm trying to compile instant-ngp, but there are bugs building on Windows that require you to force MSVC to 14.25 (Documented in this GitHub issue.)
I'm trying to override this with -T version=14.25 or -DCMAKE_GENERATOR_TOOLSET=version=14.25, but they just don't work.
> cmake . -B build -T 'version=14.25'
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044.
-- The C compiler identification is MSVC 19.29.30146.0
-- The CXX compiler identification is MSVC 19.29.30146.0
...
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
...
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
...
And it definitely builds with the 14.29 compiler.
14.25 is installed, and I know CMake can see it because if I try a version like 14.24 I get an error message about that not being installed, but 14.25 works.
How do I make CMake respect this setting instead of instantly ignoring it?
Related
I am new to Cmake and Boost. I am now working on a program using cmake and need help.
System: windows 7
Cmake version: 3.16.0-rc1
Boost version: boost_1_71_0. And boost is installed through .exe file.
Gcc version: 4.8.1(rev5, Built by MinGW-W64 project)
Visual studio: vs 2015
When I run cmake .. in build dir, no error occurs. The output is:
The C compiler identification is MSVC 19.0.24215.1
The CXX compiler identification is MSVC 19.0.24215.1
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/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: 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
Found Boost: C:/local/boost_1_71_0 (found version "1.71.0")
Boost_Found Success!
Found OpenCV: C:/Users/gph/opencv/binaries (found version "3.4.5")
Found OpenCV: C:/Users/gph/opencv/binaries (found version "3.4.5") found components: core highgui imgproc videoio
Configuring done
But I want to use minGW to compile, so When I rum cmake -G "MinGW Makefiles", error occured saying "Could NOT find Boost (missing: Boost_INCLUDE_DIR)". The output is:
The C compiler identification is GNU 4.8.1
The CXX compiler identification is GNU 4.8.1
Check for working C compiler: C:/MinGW/bin/gcc.exe
Check for working C compiler: C:/MinGW/bin/gcc.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: C:/MinGW/bin/g++.exe
Check for working CXX compiler: C:/MinGW/bin/g++.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
CMake Error at C:/Users/gph/cmake/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
Could NOT find Boost (missing: Boost_INCLUDE_DIR)
Call Stack (most recent call first):
C:/Users/gph/cmake/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
C:/Users/gph/cmake/share/cmake-3.16/Modules/FindBoost.cmake:2162 (find_package_handle_standard_args)
CMakeLists.txt:34 (find_package)
Configuring incomplete, errors occurred!
See also "C:/Users/gph/Desktop/libvibe++/build/CMakeFiles/CMakeOutput.log".
How to solve the error when running cmake -G "MinGW Makefiles"? Thanks guys!
I solved this by adding sentence set(BOOST_ROOT C:/local/boost_1_71_0) before find_package(Boost REQUIRED) LOL...
But I still wonder why I need to add this.
You can also set variables BOOST_ROOT during the creation of the cmake project (or CMake options in CLion and other IDE). For example:
mkdir buildtest; cd buildtest
cmake -DBOOST_ROOT=/you_path_to_boost/boost ..
cmake --build . -- -j 4
I had a similar problem on Linux/Manjaro. Make sure you have boost installed, more specifically the boost development headers. I had the boost runtime libraries installed but not the headers. I installed those sudo pacman -S boost and it fixed the problem for me.
After I solved this problem, thanks to ToughMind here, these problems occurred to me: _Boost_COMPONENT_DEPENDENCIES and _Boost_MISSING_DEPENDENCIES. What helped me was to update to the newest cmake verison and I got the answer from here: CMake finds Boost but the imported targets not available for Boost version
I have seen tons of posts on this particular issue and I have tried about every one that I could find. I am completely lost and stuck on this issue now and I don't really know where to turn.
I get the following error when I run my cmake file:
The C compiler identification is unknown
The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:9 (project):
No CMAKE_C_COMPILER could be found.
CMake Error at CMakeLists.txt:9 (project):
No CMAKE_CXX_COMPILER could be found.
Which is super confusing to me, since I have built a cmake project, using the same compiler with Cmake before with no errors. I even copied the elements from their cmake file into mine to see if it would make a difference but I always end up with the same error. I have even sent the test project I made to another coworker and their cmake compiled my program just fine and created a visual studio project solution with no issues.
Which makes me believe that there is something going on my end that is causing it to fail to find my compilers. Steps that I have taken:
I have added the Windows kits to my path
I have added the vcvashall.bat and cl.exe to my path
I have downloaded and installed individual plugins with Visual Studio such as:
Visual Studio C++ Core features
Visual C++ 2017 Redistributable Update
VC++ 2017 version 15.9 v14.16 latest v141 tools
Windows 10 SDK (10.0.17763.0)
Visual C++ runtime for UWP
Windows Universal C Runtime
Visual Studio SDK
Visual C++ tools for CMake and Linux
Visual C++ tools for CMake
I have tried the GUI, the Command Prompt, and Visual Studio Developer Command Prompt. All of which do not work. I have typed:
cmake --help and it automatically detects Visual Studio 15 2017 as the default compiler. I have tried cmake -G "Visual Studio 15 2017 Win64" and that also does not work.
I have since all of this, uninstalled Cmake and reinstalled it and the same issue still persists. What I haven't tried is uninstalling Visual Studio 2017 and reinstalling it again. It is also important to note, I do not have any other visual studio installations on my machine. This is the only one that I have. I do have MinGW, and I have used that successfully. However I am trying to build a Visual Studio solution.
As I have said, I am very stuck on this issue and I really do not understand why one cmake script detects and builds:
The C compiler identification is MSVC 19.16.27031.1
The CXX compiler identification is MSVC 19.16.27031.1
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/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: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
And then mine fails to find my compiler and aborts above. I can link the test project for those who want to try and compile my program. I know links are looked down on, so if it is requested I will make it available to download.
I am not an expert in cmake, and struggled through this error for weeks. I finally solved it by uninstalling cmake and installing a different version of cmake. I have no idea why that worked but it did.
I have visual studio 2017 and clang both installed in a 64-bit Windows 10 PC.
clang version 6.0.0 (tags/RELEASE_600/final)
Target: x86_64-pc-windows-msvc
Thread model: posix
I have tried running cmake with clang using:
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
but cmake always pick up visual studio instead of clang as the c++ compiler.
-- Building for: Visual Studio 15 2017
-- The C compiler identification is MSVC 19.13.26131.1
-- The CXX compiler identification is MSVC 19.13.26131.
Is there a way to ONLY use clang as my c++ compiler in cmake without other tools like visual studio?
If you wish to use VisualStudio 201x with clang/c2 compiler, forgot about linux/mac approach (it works for mingw/msys etc.). There is no need to use these CMAKE_C??_COMPILER variables.
Try e.g.
cd build
cmake -G"Visual Studio 15 2017" -T "v141_clang_c2" <SRC_DIR>
I list of available toolsets can be observed when you open any C++ project and then look to Propertiese menu -> General: "Platform toolsets" combobox-list
Or using LLVM snapshot build the page define toolset names to be used in above command e.g. LLVM-vs2013.
sample output:
C:\work\build>cmake -G"Visual Studio 15 2017" -T"v141_clang_c2" <SRC>
-- The C compiler identification is Clang 3.8.0
-- The CXX compiler identification is Clang 3.8.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/ClangC2/14.10.25903/bin/HostX86/clang.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/ClangC2/14.10.25903/bin/HostX86/clang.exe -- works
-- Detecting C compiler ABI info
....
I have Mingw64 GCC 6.3.0 (always in PATH) and Visual C++ compiler tools from Visual Studio 2017 RTM (not in PATH).
If I run cmake . -G "MinGW Makefiles", GCC 6.3.0 will be selected.
If I run cmake . -G "Ninja", GCC 6.3.0 will be selected.
My Visual C++ compiler tools is none standard, I only keep the parts I need and delete the rest (like MSBuild, IDE etc.). I use my own batch script to set up PATH, INCLUDE and LIB (works just fine).
If I run this batch script and run cmake ., MSVC will be selected and build with NMake.
With the same environment, cmake . -G "Ninja", GCC 6.3.0 is selected instead of MSVC.
So my question is, how to tell CMake I want to use MSVC + Ninja rather than GCC + Ninja when both are in PATH? Any environment variable I should set?
You can also use the inverted approach and exclude all compilers you don't want with CMAKE_IGNORE_PATH. It takes a list of paths to ignore, but be aware that it needs to be an exact string match. The advantage would be that you can declare those directly from the command line.
So what I did is to take the path from the compiler found but "not to be taken" into CMAKE_IGNORE_PATH.
And on my system there were actually three GCC compilers in my PATH (just make sure to start from an empty binary output directory with each try):
> cmake -G"Ninja" ..
...
-- Check for working C compiler: C:/MinGW/bin/cc.exe
...
> cmake -DCMAKE_IGNORE_PATH="C:/MinGW/bin" -G"Ninja" ..
...
-- Check for working C compiler: C:/Strawberry/c/bin/gcc.exe
...
> cmake -DCMAKE_IGNORE_PATH="C:/MinGW/bin;C:/Strawberry/c/bin" -G"Ninja" ..
...
-- Check for working C compiler: C:/Program Files (x86)/LLVM/bin/clang.exe
...
> cmake -DCMAKE_IGNORE_PATH="C:/MinGW/bin;C:/Strawberry/c/bin;C:/Program Files (x86)/LLVM/bin" -G"Ninja" ..
...
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
...
use a toolchain file
set(CMAKE_C_COMPILER cl.exe)
set(CMAKE_CXX_COMPILER cl.exe)
then build your cmake project with with -DCMAKE_TOOLCHAIN_FILE=toolchainfile
I'm developing a cross-platform (Linux/Windows) application in C. I've gotten tired of maintaining both a usable Makefile and the Visual Studio solution/projects so I wanted to transition to cmake. I'm using the Intel Compiler on both platforms.
I've downloaded cmake 3.0 on Windows and cmake 2.8 on Linux (it's the one in ubuntu 12.04 repositories). On Linux everything went smooth and the Makefiles were generated successfully. It was a simple matter of running: CC=icc CXX=icc cmake ...
On Windows, however, no matter what command I try I cannot use the Intel Compiler. The output vcxproj is always using the MSVC compiler.
I've tried the following command:
cmake -G "Visual Studio 11 2012 Win64" -D CMAKE_C_COMPILER="C:/Program Files (x86)/Intel/Composer XE/bin/intel64/icl.exe" -D CMAKE_CXX_COMPILER="C:/Program Files (x86)/Intel/Composer XE/bin/intel64/icl.exe" ..
The output is:
-- The C compiler identification is MSVC 17.0.61030.0
-- The CXX compiler identification is MSVC 17.0.61030.0
-- Check for working C compiler using: Visual Studio 11 2012 Win64
-- Check for working C compiler using: Visual Studio 11 2012 Win64 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Visual Studio 11 2012 Win64
-- Check for working CXX compiler using: Visual Studio 11 2012 Win64 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
When I change the generator to "NMake Makefiles" then icc is set as the compiler.
-- The C compiler identification is Intel 14.0.3.20140422
-- The CXX compiler identification is Intel 14.0.3.20140422
-- Check for working C compiler: C:/Program Files (x86)/Intel/Composer XE/bin/intel64/icl.exe
I'm testing this on a pretty basic project with only one source file, so my CMakeLists.txt file contains only:
project(dummy_cmake)
add_executable(hellonikola main.c)
Any help is greatly appreciated!
P.S.
cmake-gui behaves the same. I select to specify a different native compiler and give the path to icc and get the above outputs as well.
I've tried using cmake 2.8 on Windows as well and the behaviour is the same.
I've found the answer so I'm posting it in case anyone else has the same problem.
The solution was to add this line to the CMakeLists.txt
set(CMAKE_GENERATOR_TOOLSET "Intel C++ Compiler XE 14.0" CACHE STRING "Platform Toolset" FORCE)
I found this out on this blog and adapted it to use the Intel Compiler.