<div dir="ltr"><div><div><div><div><div><div><div><br></div>Lets say you download a swanky open source project off the web and hook it into your project using he superbuild and externalproject_add.  You write some code that uses said OSS project and you get the error in visual studio 2012. <br>
<br></div>Error    52    error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in some.obj    C:\someloc\someoss.lib(someother.obj)    your_app<br>
<br>In the past this did work and compile but no longer due to migration to VS 2012 library updates and and fresh maintenance builds from git of OSS repo where before /MDd was used, but now /MTd is specified.  This is found by grep'ing the source tree and finding the offending file and there the following lines are found:<br>
<br> # these settings never change even for C or C++<br>SET(CMAKE_C_FLAGS_DEBUG "/MTd /Z7 /Od")<br>...<br>...<br></div><div>the rest of the CMAKE compile variables.<br></div><div><br></div>That's rich.  The first line especially because git says otherwise in released versions of said OSS software where that line has changed.  The only constant is change.<br>
<br></div>Then I think ok let's force it.  Where I think my options are:<br><br></div>1) patch<br></div><br>2) pass the following into ExternalProject_Add and hope that the documentation for cmake is correct (more on this later):  -DCMAKE_C_FLAGS_DEBUG:INTERNAL="/MDd /Z7 /Od"<br>
<br></div>3) use -C to cache string force the variables in as specified <a href="http://cmake.org/Wiki/CMake_FAQ#Make_Override_Files">http://cmake.org/Wiki/CMake_FAQ#Make_Override_Files</a><br><div><div><div><div><div><br>
</div><div>4) Something I had not thought of. Recommendations welcome<br></div><div><br><br></div><div>So 1 and 3 seem to go against my sensibilities (with my response to 2 being - is this seriously this is the recommended approach), but 2 seems reasonable except it does not appear :INTERNAL implies FORCE when using ExternalProject_Add.  I am into oriental cuisine just like the next guy and there are multiple ways to skin the cat, but it seems like 2 is least messy.<br>
<br>Also regarding 1, I too have used GNU Win32 Utils to use patch as CMake does not have patch on windows as it relies on system so I have felt the pain of the person who posted <a href="http://comments.gmane.org/gmane.comp.programming.tools.cmake.user/48648">http://comments.gmane.org/gmane.comp.programming.tools.cmake.user/48648</a> and I too agree that some more good bits should be included in CMake.  Of course once you go down that path then you might want svn, git, cvs, rcs, and tetris (heck emacs has it why not cmake)<br>
</div><div><br>From latest CMake documentation. <br><br>-D <var>:<type>=<value> <br><br>and<br><br>If <type> is INTERNAL, the cache variable is marked as internal, 
and will not be shown to the user in tools like cmake-gui. This is 
intended for values that should be persisted in the cache, but which 
users should not normally change. INTERNAL implies FORCE.<br><br><br></div><div>Is this a bug?  <br><br></div><div>I submitted to:<br><a href="http://public.kitware.com/Bug/view.php?id=14705">http://public.kitware.com/Bug/view.php?id=14705</a><br>
</div><div><br><br>Should/Does ExternalProject_Add allow a forced override using -D <var>:<type>=<value> with type being INTERNAL?<br><br></div><div>If internal truly implies force and using externalproject_add I should be able to use <br>
<br></div><div>-D VAR_NAME:INTERNAL="VALUE"<br><br></div><div>then why does it not override the internal setting of CMAKE_C_FLAGS_DEBUG in the CMake file being processed by ExternalProject_Add?<br><br>-DCMAKE_C_FLAGS_DEBUG:INTERNAL="/MDd /Z7 /Od"<br>
</div><div><br></div><div>I now this because I verify the project files are getting the parameter with grep:<br><br></div><div> find someooss_proj-prefix/* -type f -name '*' -exec grep 'INTERNAL' {} + | grep FLAGS | grep  C_FLAGS<br>
<br></div><div>and are promptly ignoring it due to the incessant linker error even after blasting away the project (build directory) and allowing external project add to pull new git repo and build from scratch.  For example see my submittal to mantis above.<br>
</div><div><br>
</div></div></div></div></div></div>