<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>
<div><div><font class="Apple-style-span" face="Tahoma" size="2">Hi,</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><br></font></div><div style="text-align: left;"><font class="Apple-style-span" face="Tahoma" size="2">I'm trying to set up cmake for my visual studio project.. I' ve set it up so it works fine for make files, but got some problems setting it up as I want it for visual studio.</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="Apple-style-span" face="Tahoma" size="2">1.</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="Apple-style-span" face="Tahoma" size="2">I'm setting up different visual studio configurations so I have DebugOpenGL, DebugDirectX, ReleaseOpenGL and ReleaseDirectX. And I want to set special defines for each</font></div><div><font class="Apple-style-span" face="Tahoma" size="2">of the configurations, USE_OPENGL, USE_DIRECTX , but I cant figure out how to do it? I know for QMake you can do this:</font></div></div>
<br><span class="Apple-style-span" style="font-size: 10pt; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; line-height: 17px; background-color: rgb(255, 255, 255); ">!build_pass:addExclusiveBuilds(use_opengl, OpenGL , use_directx, DirectX)</span><br style="line-height: 17px; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; background-color: rgb(255, 255, 255); "><span class="Apple-style-span" style="font-size: 10pt; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; line-height: 17px; background-color: rgb(255, 255, 255); ">build_pass {</span><br style="line-height: 17px; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; background-color: rgb(255, 255, 255); "><span class="Apple-style-span" style="font-size: 10pt; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; line-height: 17px; background-color: rgb(255, 255, 255); ">&nbsp;&nbsp;&nbsp; CONFIG(use_opengl, use_opengl|use_directx):DEFINES+=USE_OPENGL</span><br style="line-height: 17px; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; background-color: rgb(255, 255, 255); "><span class="Apple-style-span" style="font-size: 10pt; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; line-height: 17px; background-color: rgb(255, 255, 255); ">&nbsp;&nbsp;&nbsp; else:DEFINES+=USE_DIRECTX</span><br style="line-height: 17px; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; background-color: rgb(255, 255, 255); "><span class="Apple-style-span" style="font-size: 10pt; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; line-height: 17px; background-color: rgb(255, 255, 255); ">}</span><div style="font-family: Tahoma; font-size: 10pt; "></div><div><span class="Apple-style-span" style="font-size: 10pt; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; line-height: 17px; background-color: rgb(255, 255, 255); "><br></span></div><div><span class="Apple-style-span" style="font-size: 10pt; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; line-height: 17px; background-color: rgb(255, 255, 255); ">Is it possible to do something similar with cmake? Note that this is not the normal debug/release flag you give to cmake, but different configurations in visual studio.</span></div><div><span class="Apple-style-span" style="font-size: 10pt; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; line-height: 17px; background-color: rgb(255, 255, 255); "><br></span></div><div><span class="Apple-style-span" style="font-size: 10pt; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; line-height: 17px; background-color: rgb(255, 255, 255); ">This is how I set up the configurations:</span></div><div><span class="Apple-style-span" style="font-size: 10pt; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; line-height: 17px; background-color: rgb(255, 255, 255); "><br></span></div><div><span class="Apple-style-span" style="background-color: rgb(255, 255, 255); line-height: 17px;"><font class="Apple-style-span" color="#2a2a2a" face="'Segoe UI', Tahoma, Verdana, Arial, sans-serif" size="2"><div>if(CMAKE_CONFIGURATION_TYPES AND MSVC)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>set(CMAKE_CONFIGURATION_TYPES "DebugOpenGL;ReleaseOpenGL;DebugDirectX;ReleaseDirectX")</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>"Reset the configurations to what we need"</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>FORCE)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>#DebugOpenGL flags</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>set(CMAKE_CXX_FLAGS_DEBUGOPENGL "/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1" CACHE STRING "Flags used by the C++ compiler during maintainer builds." FORCE)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>set(CMAKE_C_FLAGS_DEBUGOPENGL "/D_DEBUG /MDd /Zi &nbsp;/Ob0 /Od /RTC1" CACHE STRING "Flags used by the C compiler during maintainer builds." FORCE)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>set(CMAKE_EXE_LINKER_FLAGS_DEBUGOPENGL "/debug /INCREMENTAL" CACHE STRING "Flags used for linking binaries during maintainer builds." FORCE )</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>set(CMAKE_SHARED_LINKER_FLAGS_DEBUGOPENGL "/debug /INCREMENTAL" CACHE STRING "Flags used by the shared libraries linker during maintainer builds." FORCE )</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>#ReleaseOpenGL flags</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>set(CMAKE_CXX_FLAGS_RELEASEOPENGL "/MD /O2 /Ob2 /D NDEBUG" CACHE STRING "Flags used by the C++ compiler during maintainer builds." FORCE)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>set(CMAKE_C_FLAGS_RELEASEOPENGL "/MD /O2 /Ob2 /D NDEBUG" CACHE STRING "Flags used by the C compiler during maintainer builds." FORCE)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>set(CMAKE_EXE_LINKER_FLAGS_RELEASEOPENGL "/INCREMENTAL:NO" CACHE STRING "Flags used for linking binaries during maintainer builds." FORCE )</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>set(CMAKE_SHARED_LINKER_FLAGS_RELEASEOPENGL "/INCREMENTAL:NO" CACHE STRING "Flags used by the shared libraries linker during maintainer builds." FORCE )</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>#DebugDirectX flags</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>set(CMAKE_CXX_FLAGS_DEBUGDIRECTX "/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1" CACHE STRING "Flags used by the C++ compiler during maintainer builds." FORCE)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>set(CMAKE_C_FLAGS_DEBUGDIRECTX "/D_DEBUG /MDd /Zi &nbsp;/Ob0 /Od /RTC1" CACHE STRING "Flags used by the C compiler during maintainer builds." FORCE)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>set(CMAKE_EXE_LINKER_FLAGS_DEBUGDIRECTX "/debug /INCREMENTAL" CACHE STRING "Flags used for linking binaries during maintainer builds." FORCE )</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>set(CMAKE_SHARED_LINKER_FLAGS_DEBUGDIRECTX "/debug /INCREMENTAL" CACHE STRING "Flags used by the shared libraries linker during maintainer builds." FORCE )</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>#ReleaseDirectx flags</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>set(CMAKE_CXX_FLAGS_RELEASEDIRECTX "/MD /O2 /Ob2 /D NDEBUG" CACHE STRING "Flags used by the C++ compiler during maintainer builds." FORCE)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>set(CMAKE_C_FLAGS_RELEASEDIRECTX "/MD /O2 /Ob2 /D NDEBUG" CACHE STRING "Flags used by the C compiler during maintainer builds." FORCE)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>set(CMAKE_EXE_LINKER_FLAGS_RELEASEDIRECTX "/INCREMENTAL:NO" CACHE STRING "Flags used for linking binaries during maintainer builds." FORCE )</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>set(CMAKE_SHARED_LINKER_FLAGS_RELEASEDIRECTX "/INCREMENTAL:NO" CACHE STRING "Flags used by the shared libraries linker during maintainer builds." FORCE )</div><div>endif()</div></font></span></div><div><span class="Apple-style-span" style="font-size: 10pt; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; line-height: 17px; background-color: rgb(255, 255, 255); "><br></span></div><div><span class="Apple-style-span" style="font-size: 10pt; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; line-height: 17px; background-color: rgb(255, 255, 255); ">2.</span></div><div><span class="Apple-style-span" style="font-size: 10pt; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; line-height: 17px; background-color: rgb(255, 255, 255); "><br></span></div><div><span class="Apple-style-span" style="font-size: 10pt; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; line-height: 17px; background-color: rgb(255, 255, 255); ">I have been able to exclude .cpp files from the visual studio build by doing this:</span></div><div><span class="Apple-style-span" style="font-size: 10pt; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; line-height: 17px; background-color: rgb(255, 255, 255); "><br></span></div><div><span class="Apple-style-span" style="font-size: 10pt; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; line-height: 17px; background-color: rgb(255, 255, 255); "><div>set_source_files_properties(</div><div>${files}</div><div>PROPERTIES HEADER_FILE_ONLY true)</div><div><br></div><div>But in visual studio you can right click a file-&gt; properties and select exclude file from build.. this sets a red icon on the file. I want to do this for sepereate configurations as in question 1.</div></span></div>                                               </div></body>
</html>