[llvm] r194596 - CMake: make building with /MT an option instead of always forcing it

Aaron Ballman aaron at aaronballman.com
Wed Nov 13 11:17:07 PST 2013


Thanks Hans!

~Aaron

On Wed, Nov 13, 2013 at 2:12 PM, Hans Wennborg <hans at hanshq.net> wrote:
> Author: hans
> Date: Wed Nov 13 13:12:02 2013
> New Revision: 194596
>
> URL: http://llvm.org/viewvc/llvm-project?rev=194596&view=rev
> Log:
> CMake: make building with /MT an option instead of always forcing it
> for release builds.
>
> This is a follow-up to r194589. Aaron pointed out that building
> libraries with /MT and using them in an application that uses a
> different run-time library can be a bad idea.
>
> Move the option to build with /MT behind a CMake option so it can be
> turned on selectively, such as when building the toolchain installer.
>
> Modified:
>     llvm/trunk/CMakeLists.txt
>     llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
>     llvm/trunk/docs/CMake.rst
>
> Modified: llvm/trunk/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=194596&r1=194595&r2=194596&view=diff
> ==============================================================================
> --- llvm/trunk/CMakeLists.txt (original)
> +++ llvm/trunk/CMakeLists.txt Wed Nov 13 13:12:02 2013
> @@ -17,6 +17,8 @@ set(PACKAGE_VERSION "${LLVM_VERSION_MAJO
>
>  option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF)
>
> +option(LLVM_STATIC_MSVC_RUNTIME "When using MSVC, link against the static run-time (/MT)" OFF)
> +
>  option(LLVM_USE_FOLDERS "Enable solution folders in Visual Studio. Disable for Express versions." ON)
>  if ( LLVM_USE_FOLDERS )
>    set_property(GLOBAL PROPERTY USE_FOLDERS ON)
>
> Modified: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMOptions.cmake?rev=194596&r1=194595&r2=194596&view=diff
> ==============================================================================
> --- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake (original)
> +++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake Wed Nov 13 13:12:02 2013
> @@ -41,13 +41,16 @@ else()
>    endif()
>  endif()
>
> -if(MSVC)
> -  # Link release builds against the static runtime.
> +if(MSVC AND LLVM_STATIC_MSVC_RUNTIME)
> +  # Link against the static runtime.
>    foreach(flag CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO
>        CMAKE_C_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELEASE
>        CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_MINSIZEREL)
>      llvm_replace_compiler_option("${flag}" "/MD" "/MT")
>    endforeach()
> +  foreach(flag CMAKE_C_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG)
> +    llvm_replace_compiler_option("${flag}" "/MDd" "/MTd")
> +  endforeach()
>  endif()
>
>  if(WIN32)
>
> Modified: llvm/trunk/docs/CMake.rst
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CMake.rst?rev=194596&r1=194595&r2=194596&view=diff
> ==============================================================================
> --- llvm/trunk/docs/CMake.rst (original)
> +++ llvm/trunk/docs/CMake.rst Wed Nov 13 13:12:02 2013
> @@ -280,6 +280,11 @@ LLVM-specific variables
>    are ``Address``, ``Memory`` and ``MemoryWithOrigins``. Defaults to empty
>    string.
>
> +**LLVM_STATIC_MSVC_RUNTIME**:BOOL
> +  When building with MSVC, link against the static runtime library (/MT or /MTd
> +  for release and debug builds, respectively) instead of the dynamic one.
> +  Defaults to OFF.
> +
>  Executing the test suite
>  ========================
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list