Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I disable cmake's Visual Studio macro which prompts the user to reload the solution when a CMakeLists.tx has changed

Because Visual Studio 2010 is broken and won't automatically reload a solution when it changed externally via CMake, the guys at kitware made this macro that prompts you to reload the whole solution instead of pressing reload for every project like Visual Studio does. This would be nice if it actually worked.

In VC 10 this macro is broken and further chokes the ide. I have another solution for automatically reloading externally changed projects/solutions (the VSCommands add-in) and would want to disable cmake's macro of doing so. Does anyone know a way?

like image 827
octi Avatar asked Nov 05 '11 05:11

octi


People also ask

Is CMake installed with Visual Studio?

The CMake support is directly integrated since Visual Studio 2017. This way, you can open folders with a CMakeLists. txt file directly via "File > Open > Folder". You will find more information at https://docs.microsoft.com/de-de/cpp/build/cmake-projects-in-visual-studio.

Is CMake better than Visual Studio?

CMake is a better build system than Visual Studio projects and solutions. It is compact and much more easier to maintain even for Windows only projects. See CMake for Visual Studio Developers for some reasons.


2 Answers

Here is what i found in LLVM' CMakeLists.txt:

# Workaround for MSVS10 to avoid the Dialog Hell
# FIXME: This could be removed with future version of CMake.
if(MSVC_VERSION EQUAL 1600)
  set(LLVM_SLN_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/LLVM.sln")
  if( EXISTS "${LLVM_SLN_FILENAME}" )
    file(APPEND "${LLVM_SLN_FILENAME}" "\n# This should be regenerated!\n")
  endif()
endif()

It seems, this code updates .sln file and forces Visual Studio to reload whole solution at once, instead of asking you about each project.

like image 97
arrowd Avatar answered Sep 28 '22 07:09

arrowd


To "disable" the CMake macro that runs to prompt for solution reloading, you could edit the macro labeled "DO NOT EDIT THIS MACRO"...

In Visual Studio, choose "Tools > Macros > Macros IDE..." from the menu, comment out the body of the "ReloadProjects" and "StopBuild" macros in the CMakeVSMacros2.Macros module, and then even when CMake calls those macros, they'll have no effect.

Perhaps you could do that, and also try the VS addin mentioned in this CMake bug report on the topic: http://public.kitware.com/Bug/view.php?id=11258#c27652

like image 25
DLRdave Avatar answered Sep 28 '22 07:09

DLRdave