From d8147392218c9a0a40f25e39d47d0360b6b4500b Mon Sep 17 00:00:00 2001 From: Darth Vader Date: Tue, 11 Feb 2025 18:06:23 +0000 Subject: [PATCH] Squashed 'src/phast/PhreeqcRM/' changes from 9b9ddd9c..ac03301a ac03301a Closes #193 (#194) git-subtree-dir: src/phast/PhreeqcRM git-subtree-split: ac03301a13683f153565df35fdc98e001f890f6a --- CMakeLists.txt | 33 ++++----------------------------- Tests/CMakeLists.txt | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e5c2f528..b28b2a12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -577,41 +577,16 @@ else() endif() endif() -if(STANDALONE_BUILD EQUAL 1 AND MSVC) +if(WIN32) # PHREEQCRM_STATIC_RUNTIME (VCOMP???.dll) cannot be made static - option(PHREEQCRM_STATIC_RUNTIME "Build with a static runtime (excluding VCOMP???.DLL)" OFF) + option(PHREEQCRM_STATIC_RUNTIME "Build with a static runtime (excluding OpenMP dlls)" OFF) if(PHREEQCRM_STATIC_RUNTIME) # compile with static runtime - - set(CompilerFlags - CMAKE_CXX_FLAGS - CMAKE_CXX_FLAGS_DEBUG - CMAKE_CXX_FLAGS_RELEASE - CMAKE_CXX_FLAGS_MINSIZEREL - CMAKE_CXX_FLAGS_RELWITHDEBINFO - CMAKE_C_FLAGS - CMAKE_C_FLAGS_DEBUG - CMAKE_C_FLAGS_RELEASE - CMAKE_C_FLAGS_MINSIZEREL - CMAKE_C_FLAGS_RELWITHDEBINFO - ) - - 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() + set_property(TARGET PhreeqcRM PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif() endif() +# TODO PHREEQCRM_ENABLE_TESTING if(STANDALONE_BUILD EQUAL 1) # tests enable_testing() diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 9f6ab131..d095d841 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -62,6 +62,10 @@ if(PHREEQCRM_FORTRAN_TESTING) source_group("Source Files" FILES "../src/BMI_not_implemented.inc") source_group("Source Files" FILES "../src/IPhreeqcPhast/IPhreeqc/IPhreeqc_interface.F90") source_group("Source Files" FILES "../src/RM_interface.F90") + + if(PHREEQCRM_STATIC_RUNTIME) + set_property(TARGET FortranAdvect PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + endif() endif() @@ -163,6 +167,10 @@ if(PHREEQCRM_FORTRAN_TESTING) target_link_libraries(TestRM FortranAdvect) endif() +if(PHREEQCRM_STATIC_RUNTIME) + set_property(TARGET TestRM PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +endif() + #-----------------------------------------------------------------------------# # test PhreeqcRM dtor @@ -181,6 +189,10 @@ target_link_libraries(TestRMdtor PhreeqcRM::PhreeqcRM) add_test(TestRMdtor TestRMdtor) +if(PHREEQCRM_STATIC_RUNTIME) + set_property(TARGET TestRMdtor PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +endif() + #-----------------------------------------------------------------------------# # test BMIPhreeqcRM dtor @@ -201,6 +213,10 @@ target_link_libraries(TestBMIdtor PhreeqcRM::PhreeqcRM) add_test(TestBMIdtor TestBMIdtor) +if(PHREEQCRM_STATIC_RUNTIME) + set_property(TARGET TestBMIdtor PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +endif() + #-----------------------------------------------------------------------------# # test compile and run @@ -274,6 +290,16 @@ set_property(TARGET TestRM APPEND TestAllMethods_py.log.txt ) +if(WIN32 AND PHREEQCRM_FORTRAN_TESTING) + # this attempts to find the location of libiomp5md.dll to add it to the path + # this should work for the most recent versions of oneAPI (ifort and ifx) + get_filename_component(FORTRAN_COMPILER_DIR ${CMAKE_Fortran_COMPILER} DIRECTORY) + file(TO_NATIVE_PATH "${FORTRAN_COMPILER_DIR}" FORTRAN_COMPILER_DIR_NATIVE) + set_tests_properties(TestRM PROPERTIES + ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:${FORTRAN_COMPILER_DIR_NATIVE}" + ) +endif() + if(MSVC AND BUILD_SHARED_LIBS) # copy PhreeqcRM dll add_custom_command(TARGET TestRM POST_BUILD