CMake project in Visual Studio 2017 not rebuilding after first build - c++

I have a project of roughly 50 files that I build with the CMake integration in Visual Studio 2017 (latest release, version 15.0.0+26228.9).
If I regenerate my CMake cache and then build, my project is built normally. However, if I change something in one of my files, then try to rebuild without regenerating my CMake cache, nothing happens.
This is what the build window looks like:
Build started ...
========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
Nothing will be built until I regenerate my CMake cache, where I will only be able to build once before getting the same issue.
Same issue happens on any CMake project I try to build. This issue only started happening on the latest full release of Visual Studio 2017, this did not happen in the RC builds.

I ended up repairing the Visual Studio 2017 install from the Visual Studio installer and that fixed it. Everything works as intended now.

Related

Visual Studio 2022 "A task was cancelled" after build

I'm using Visual Studio Community 2022. Now I have a similar problem with Visual studio 2013 "A task was cancelled".
A few moments ago, everything went alright. However I suddenly found that when I try to build my cpp project, VS only output
1>----— Build started: Project: MyConsoleApp, Configuration: Release x64 —----
After about 5 minutes, it becomes
1>----— Build started: Project: MyConsoleApp, Configuration: Release x64 —----
1>A task was canceled.
1>A task was canceled.
========= Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
All my cpp projects have the same problem now. My time zone is correct. I have tried to reopen VS, restart my computer and reinstall Visual Studio, but this problem still exists.
I have the same problem as you, since February 28th, VS2022 could not build any project, until today, I uninstalled the anti-virus software (360 Security Guard) installed on my computer, it returned to normal work, I think this is due to the anti-virus software update caused by the incompatible VS2022, You can try uninstalling the anti-virus software installed on your computer, which may solve the problem

VSCode CMake Extension rebuild all project each time

I'm working on a project in C++ configured using CMake.
Each time I build the project, all files are recompiled, which is unbearable considering the time it takes.
With Visual Studio Code
I'm trying to use VSCode and the CMake Extension.
The CMake:Configure command works well and so does the CMake:Build command. It takes a lot of time to compile because I use highly templatized header-only libraries like Eigen3, Boost and CGAL, so I need to build a pre-compiled header. It build some librairies too. But it is normal that it takes time for a first compilation.
However, if I build the target again (without modifying anything in the code) the compilation is completely redone ! I just want the modified source files or librairies to be re-compiled. Or if a header in the list of pre-compiled headers is modified, only then should the pre-compiled headers be recompiled.
With Visual Studio 2019
I thought that VSCode didn't work with a concept of "project", and therefore had to reconfigure and recompile the whole project every time it was launched.
So I decided to generate a Visual Studio Solution with the CMake-GUI program and use Visual Studio 2019 instead of VSCode.
Now when I build a second time my project, nothing is recompiled and the program is directly lauched. Visual Studio say :
========== Build: 0 succeeded, 0 failed, 5 up-to-date, 0 skipped ==========
Wonderful!
Unfortunately not..., because if I modify a file, Visual Studio keeps telling me that everything is up-to-date and my modifications are not taken into account. I need to "Rebuild" the project so that everything will be recompiled, which does not solve my problem as it takes a lot of time.
Question
How to recompile only modified source files, librairies or pre-compiled headers (with VS Code, Visual Studio or both) ?
Plaform : Windows 10
Edit 15.04.21
I did some more methodical testing today to find out what the problem might be.
I used a very simple project to do the tests.
CMakeList.txt
cmake_minimum_required (VERSION 3.8)
project ("HelloCMake")
add_executable (HelloCMake "HelloCMake.cpp")
HelloCMake.cpp
#include <iostream>
int main() {
std::cout << "Hello CMake !" << std::endl;
return 0;
}
1. With VSCode and CMake Tools Extension
With the CMake Tools Extension, VSCode can configure and build a CMake project. It generate a Visual Studio Solution (.sln).
Build the target with CMake Tools Extension which makes VSCode to run the command :
cmake --build <PROJECT_DIR>/build --config Release --target HelloCMake --
/maxcpucount:14
The entire target is compiled
I build it again (without changes)
The target is completely recompiled again
The problem is that the target is completely recompiled, every time. I asked the question directly to the CMake Tools developers. GitHub Issue
2. .sln project generated by CMake (Visual Studio 2019)
I generated a Visual Studio Solution with CMake and open it.
I build my project HelloCMake
I do some modifications in source file
I build the project again, but Visual Studio never takes my modifications into account. The builds are always "up-to-date".
The problem is that Visual Studio does not take my changes into account. I have to rebuild the project, which takes too much time.
3. Directly open CMake project with Visual Studio 2019 (Ninja)
If you open a CMakeList.txt with Visual Studio 2019, it is not a Visual Studio Solution that is generated but a Ninja one.
It seems that this way the compilation works correctly !
According to this research, it is the CMake Tools Extension for VSCode as well as the Visual Studio Solution that cause problems.
I can't figure out why such a simple project doesn't compile properly with a Visual Studio Solution generated by CMake.

Compiling in VS 2013 Using compiler tools v90 error

I ran into a problem which everytime i try to compile just a test project with windows 2013 using v90 compiler tools, i get this error:
1>------ Build started: Project: Test Console App, Configuration: Debug Win32 ------
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.targets(62,5): error : Required file "" is missing.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
It works fine if i compile it using VS 2008, but I feel more confortable with visual studio 2013 or 2012, Intellisence is much better, as well as the colors, etc...
I installed the windows 7.1 SDK, as well as the update pack with the 2010 Compiler tools. I have both VS 2008 and VS 2013, as well as all the C++ Redists.
I can't compile the projects I'm working on, since we have libs compiled with 2008 to which we don't have the sources to, giving us linker errors.
Thanks
The answer was to have visual studio 2010 installed. Express worked nicely.
Just for other people with the same problem, here is what you do:
Install VS 2013/2012 depending on which one you want.
Install VS 2008 and 2010 ( can be express ).
If that doesnt pick up your compiler tools v90/v100 then just follow these instructions:
-Uninstall all C++ 2010 Redists if any, or SDK 7.1 won't install.
-Install Windows SDK 7.1 and then download the Windows C++ Compiler Tools 2010 update for the SDK.
-Install the C++ Redists again.
-Reboot.
-Enjoy! :P

1 up-to-date issue with VisualStudio 2010 and Visual studio 2012

I am trying to generate an .exe using visual studio 2010, for the first it builds fine but if i delete the .exe and again if try to build without making any changes in file for the second time, its not generating the .exe again and it is just showing as follows even if the .exe is not present,
========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
On searching the internet, i found it may be possible to build again, by everytime using "rebuild" option of VS2010. But i dont want to use rebuild option as i am generating .exe via command prompt always using something like devenv /build "Debug|x64".....
I also Tried to build using Visual Studio 2012 and still facing the same problem for 2nd time generation.
Please suggest me with a solution. I am trying from two weeks and found no solution(except "rebuild" option) which works fine with this issue.
Project Properties -> Build Events -> Post-Build Events -> Command Line:
del /F /Q "$(IntDir)\$(MSBuildProjectName).lastbuildstate"
This will delete lastbuildstate file after every build, so .exe file will be regenerated every time.
Right click on the name of the project in the Solution Explorer window and then "Rebuild"

CUDA + Visual Studio = suppressed output window

Normally, when I use Visual Studio to do a build, I see warnings and errors shown in the output pane, e.g.
1>------ Build started: Project: pdcuda, Configuration: Release x64 ------
Compiling...
foo.cpp
Linking...
foo.obj : error LNK2001: unresolved external symbol "foo"
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I'm doing some GPU programming with CUDA. Upon upgrading to 2.1, I no longer get any useful output in Visual Studio. For example, all I now see is:
1>------ Build started: Project: pdcuda, Configuration: Release x64 ------
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
The other details can be found in BuildLog.htm, but it's inconvenient to hunt that file down all the time.
Does anyone know how to force Visual Studio to show the output in its output pane?
Things that don't help:
uninstalling CUDA: the problem persists in all projects
Tools > Options > Projects and Solutions > Build and Run > MSBuild project build output verbosity: changing this pulldown, even to "Diagnostic" has no discernable effect.
EDIT: Additional things that don't help:
devenv.exe /resetsettings
devenv.exe /resetuserdata
UPDATE (in response to Die in Sente): It's now working on one of the two machines (I'm not sure what I did to fix it though). The machine that's still having problems has a CUDA Visual Studio Wizard installed that has caused similar problems before. The still-broken machine had version 15.00.21022.8 of the compiler. The working machine has 15.00.30729.1. After making a backup, I transferred "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64" from the working to the broken machine. I observe no changes in behavior on the broken machine.
I have exactly the same problem, but without CUDA. Today Visual Studio just decided it wasn't going to show any build messages anymore. It was working fine, then one of my builds it just stopped working. The problem persists over all my projects now, and persists over reboots. I also see the correct messages in buildlog.htm. This is ridonkulous!
EDIT: Ooh, I used the add/remove programs to do a repair, and now it works again! Yeah!
did you tried to reset IDE
devenv.exe /resetsettings
or
devenv.exe /resetuserdata
I also recently install CUDA 2.1 (on top of 2.0 I believe). The default installation for CUDA 2.1 moved the SDK from
C:\Program Files\NVIDIA Corporation\NVIDIA CUDA SDK\
to
C:\Documents and Settings\All Users\Application Data\NVIDIA Corportation\NVIDIA CUDA SDK\
which initially caused me some problems. Are all of your paths resolving correctly?
This might sound like a far out suggestion. Get the CUDA SDK and try your code with the sample CUDA-C++ project in there. Maybe something changed in the build rules for CUDA v2.1.
If you go to Tools->Options->Projects and Solutions->Build and Run. Last property is "MSBuild Project build output verbosity". It defaults to Minimal, change it to normal and the build messages will show up in Output window.
This also enables any <Message Text="test message"></Message> output to show up in Visual Studio Build Output Window.
Final solution: reinstall the OS.