[CMake] Visual Studio rebuilding ZERO_CHECK

Robert Carnecky crobi at inf.ethz.ch
Wed Jun 13 12:33:12 EDT 2012


On 6/13/2012 5:14 PM, J Decker wrote:
> On Wed, Jun 13, 2012 at 7:29 AM, Jonathan Romero <jonnyro at jonnyro.com> wrote:
>>
>> On Wed, Jun 13, 2012 at 10:04 AM, Micha Renner <Micha.Renner at t-online.de>
>> wrote:
>>> Am Mittwoch, den 13.06.2012, 14:51 +0200 schrieb Robert Carnecky:
>>>> Hello,
>>>>
>>>> My Visual Studio 2010 is constantly prompting me to build ZERO_CHECK
>>>> every time I try to run my program, even though nothing has changed. Is
>>>> there a workaround for this?
>>> No, that is the current situation. This problem and some others belong
>>> to a complex of problems which CMake has with Visual Studio since 2008.
>>> May be it becomes better with VS 2012.
>>>
>>> Micha
>>>
>>>
>>>> How to reproduce:
>>>> 1. Set up the simplest project possible (see below).
>>>> 2. Configure and generate using the CMake GUI.
>>>> 3. Open the project file and build the project. Project successfully
>>>> builds.
>>>> 4. Start the application from within Visual Studio (press F5). A message
>>>> box appears, saying "This project is out of date: ZERO_CHECK. Would you
>>>> like to build it?".
>>>> 5. Click on yes. ZERO_CHECK is built, no actual code gets compiled. The
>>>> application starts and exits.
>>>> 6. Go to step 4 (message box appears again).
>>>>
>>>> I do not want to enable automatic rebuilds without prompts, since I have
>>>> other projects where a build can take very long and I do not want to
>>>> start it when not necessary. Starting a build immediately deletes the
>>>> executable file and I would not be able to run the last version while
>>>> making changes to the code.
>>>>
>>>> Thanks in advance,
>>>> Robert
>>>>
>>>>
>>>> CMakeLists.txt:
>>>> project(test)
>>>> cmake_minimum_required (VERSION 2.8.8)
>>>> add_executable(main main.cpp)
>>>>
>>>> main.cpp:
>>>> int main() {return 0;}
>>>>
>>>> System:
>>>> CMake 2.8.8
>>>> Visual Studio 2010, 64bit compiler
>>>> Windows 7 64bit
>>>>
>>
>> Did you set your startup project?  ZERO_CHECK will be the default but you
>> can override it by right clicking on the actual project you wish to run and
>> choosing "Set as Startup Project" in visual studio.  I believe this is a
>> user specific setting in visual studio (not a project setting) so you always
>> have to do this through the GUI.  I dont think there is anything in your
>> CMakeLists.txt you can do to work around it.
>>
> It doesn't matter what project is startup, it's got an always-build
> sort of condition.  (but that's what catches changes if you modify
> cmakelists.txt and rebuild)

Thanks for the explanation! I had the startup project set up correctly, 
but every project within a solution has a non-removable dependency on 
ZERO_CHECK, so it always gets built (I can see that this is required for 
proper handling of changed cmakelists.txt). I guess I just have to learn 
to live with the auto-build before run option.

I'm still hoping one day Visual Studio will support CMake without the 
additional projects like ZERO_CHECK and ALL_BUILD. Out of curiosity, 
does anyone have link to a discussion of all the related problems of 
CMake with Visual Studio?


More information about the CMake mailing list