cmake: add warnings for MSVC static runtime option
authorMarc-André Moreau <marcandre.moreau@gmail.com>
Sat, 22 Sep 2012 21:10:08 +0000 (17:10 -0400)
committerMarc-André Moreau <marcandre.moreau@gmail.com>
Sat, 22 Sep 2012 21:10:08 +0000 (17:10 -0400)
CMakeLists.txt
cmake/MSVCRuntime.cmake
libfreerdp/crypto/tls.c

index d851982..1d94a63 100644 (file)
@@ -65,6 +65,11 @@ if(MSVC)
        if(NOT DEFINED MSVC_RUNTIME)
                set(MSVC_RUNTIME "dynamic")
        endif()
+       if(${MSVC_RUNTIME} STREQUAL "static")
+               message(STATUS "Use the MSVC static runtime option carefully!")
+               message(STATUS "OpenSSL uses /MD by default, and is very picky")
+               message(STATUS "Random freeing errors are a common sign of runtime issues")
+       endif()
        configure_msvc_runtime()
 endif()
 
index d659708..c71a750 100644 (file)
@@ -17,23 +17,22 @@ macro(configure_msvc_runtime)
                        CMAKE_CXX_FLAGS_RELWITHDEBINFO
                )
                if(${MSVC_RUNTIME} STREQUAL "static")
-                       message(STATUS
-                               "MSVC: using statically-linked runtime (/MT and /MTd)."
-                       )
+                       message(STATUS "MSVC: using statically-linked runtime (/MT and /MTd).")
                        foreach(variable ${variables})
                                if(${variable} MATCHES "/MD")
                                        string(REGEX REPLACE "/MD" "/MT" ${variable} "${${variable}}")
                                endif()
                        endforeach()
                else()
-                       message(STATUS
-                               "MSVC: using dynamically-linked runtime (/MD and /MDd)."
-                       )
+                       message(STATUS "MSVC: using dynamically-linked runtime (/MD and /MDd).")
                        foreach(variable ${variables})
                                if(${variable} MATCHES "/MT")
                                        string(REGEX REPLACE "/MT" "/MD" ${variable} "${${variable}}")
                                endif()
                        endforeach()
                endif()
+               foreach(variable ${variables})
+                       set(${variable} "${${variable}}" CACHE STRING "MSVC_${variable}" FORCE)
+               endforeach()
        endif()
 endmacro(configure_msvc_runtime)
index b4e8720..896653e 100644 (file)
@@ -52,7 +52,6 @@ static CryptoCert tls_get_certificate(rdpTls* tls, boolean peer)
 
 static void tls_free_certificate(CryptoCert cert)
 {
-
        X509_free(cert->px509);
        xfree(cert);
 }