<div dir="ltr">Hello,<div><br></div><div>It has been a while since I've looked at this stuff, but I do use exceptions in my project. So I add the /EHsc: </div><div>SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:strict /EHsc ${WARNINGS_IGNORE}")<br>SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /fp:strict ${WARNINGS_IGNORE}")<br></div><div><br></div><div>and I also add a linker flag:</div><div>SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")<br></div><div>SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO /NODEFAULTLIB:python3")<br>SET (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO")<br></div><div><br></div><div>According to the M$ documentation, SAFESEH is relevant for x86, but not x64:</div><div><a href="https://docs.microsoft.com/en-us/cpp/build/reference/safeseh-image-has-safe-exception-handlers?view=vs-2019">https://docs.microsoft.com/en-us/cpp/build/reference/safeseh-image-has-safe-exception-handlers?view=vs-2019</a><br></div><div><br></div><div>In order to change runtimes, I have also had to enable defaultlib's in case they got in through other libraries or header files:</div><div>SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:LIBCMT")<br></div><div><br></div><div>According to this instruction you can disable all of the libraries you do not want:</div><div><a href="https://docs.microsoft.com/en-us/cpp/error-messages/tool-errors/linker-tools-warning-lnk4098?view=vs-2019">https://docs.microsoft.com/en-us/cpp/error-messages/tool-errors/linker-tools-warning-lnk4098?view=vs-2019</a><br></div><div><br></div><div>For example, above I had to do:</div><div>/NODEFAULTLIB:python3
</div><div><br></div><div>because the Python header files in my project were force linking the wrong library.</div><div><br></div><div>Regards</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Oct 28, 2019 at 6:02 AM Osman Zakir <<a href="mailto:osmanzakir90@hotmail.com">osmanzakir90@hotmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:12pt">
<span>Hi. </span></div>
<div style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:12pt">
<span><br>
</span></div>
<div style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:12pt">
<span>I'm trying to build LLVM 10.0.0 with CMake on the command line (Developer Command Prompt for VS2019) and I need to know how to switch to a static runtime. I've tried specifying LLVM's variable for this, but it didn't work. I still have a dynamic runtime.
Along with that, I also need to know how to enable C++ exceptions. </span></div>
<div style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:12pt">
<span><br>
</span></div>
<div style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:12pt">
<span>One thing I tried was to do "-DCMAKE_CXX_FLAGS="/std:c++17 /MT /EHsc /permissive-"" but this also didn't work. Specifying these on the CXXFLAGS environment variable didn't do anything either. I was using the same session of the Developer Command Prompt,
but I made sure to run "refreshenv" to take the new environment from the registry before continuing. </span></div>
<div style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:12pt">
<span><br>
</span></div>
<div style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:12pt">
<span>Note: I don't want to edit the CMakeLists.txt file because I want to be able to run "git pull" without having to stage any changes (I cloned the LLVM GitHub repository for the source code). </span></div>
<div style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:12pt">
<span><br>
</span></div>
<div style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:12pt">
<span>Any help is appreciated. Thanks in advance.</span></div>
</div>
-- <br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://cmake.org/mailman/listinfo/cmake" rel="noreferrer" target="_blank">https://cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div>