From 6a6d3d7cd4ec0a71fbd8234c24aaf4b65d4be357 Mon Sep 17 00:00:00 2001 From: Scott R Charlton Date: Thu, 16 Jul 2015 05:05:39 +0000 Subject: [PATCH] added build with a static runtime option git-svn-id: svn://136.177.114.72/svn_GW/IPhreeqc/trunk@9999 1feff8c3-07ed-0310-ac33-dd36852eb9cd --- CMakeLists.txt | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d51cb91..ce353520 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -346,6 +346,37 @@ endif() ## ) ##ENDIF(MSVC) +if (STANDALONE_BUILD EQUAL 1 AND MSVC) + option (IPHREEQC_STATIC_RUNTIME "Build with a static runtime" OFF) + if (IPHREEQC_STATIC_RUNTIME) + # compile with static runtime + + set(CompilerFlags + CMAKE_CXX_FLAGS + CMAKE_CXX_FLAGS_DEBUG + CMAKE_CXX_FLAGS_RELEASE + CMAKE_C_FLAGS + CMAKE_C_FLAGS_DEBUG + CMAKE_C_FLAGS_RELEASE + ) + + foreach(CompilerFlag ${CompilerFlags}) + if(${CompilerFlag} MATCHES "/MD") + string(REGEX REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}") + endif() + endforeach() + + set(FortranCompilerFlags + CMAKE_Fortran_FLAGS + ) + + foreach(FortranCompilerFlags ${FortranCompilerFlags}) + if(${FortranCompilerFlags} MATCHES "/libs:dll") + string(REGEX REPLACE "/libs:dll" "/libs:static" ${FortranCompilerFlags} "${${FortranCompilerFlags}}") + endif() + endforeach() + endif() +endif() if (STANDALONE_BUILD EQUAL 1) # tests