Setting MSVC runtime type on CMake command line?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Setting MSVC runtime type on CMake command line?

Osman Zakir
I tried to set the runtime to static by passing the "-DMSVC_RUNTIME_TYPE=/MT" argument when running CMake, but it generated a warning saying that that option was ignored by the project (Zlib in this case).  So what's the correct way to do this?

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Setting MSVC runtime type on CMake command line?

Mateusz Loskot
On Sat, 12 Jan 2019 at 14:20, Osman Zakir <[hidden email]> wrote:
>
> I tried to set the runtime to static by passing the "-DMSVC_RUNTIME_TYPE=/MT"
> argument when running CMake, but it generated a warning

Could you paste link to the CMake docs page where this variable is described?

> So what's the correct way to do this?

Modify C/C++ flags. For example, something along these lines

string(REGEX REPLACE "/MD" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
string(REGEX REPLACE "-MT" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
target_compile_options(myexe PRIVATE $<$<CXX_COMPILER_ID:MSVC>:-MT>)

Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
--
Mateusz Loskot
http://mateusz.loskot.net