Skip to content

Commit

Permalink
Squashed 'src/phast/PhreeqcRM/' changes from 9b9ddd9c..ac03301a
Browse files Browse the repository at this point in the history
ac03301a Closes #193 (#194)

git-subtree-dir: src/phast/PhreeqcRM
git-subtree-split: ac03301a13683f153565df35fdc98e001f890f6a
  • Loading branch information
Darth Vader committed Feb 11, 2025
1 parent 4e0cbe1 commit d814739
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 29 deletions.
33 changes: 4 additions & 29 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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$<$<CONFIG:Debug>:Debug>")
endif()
endif()

# TODO PHREEQCRM_ENABLE_TESTING
if(STANDALONE_BUILD EQUAL 1)
# tests
enable_testing()
Expand Down
26 changes: 26 additions & 0 deletions Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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$<$<CONFIG:Debug>:Debug>")
endif()
endif()


Expand Down Expand Up @@ -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$<$<CONFIG:Debug>:Debug>")
endif()

#-----------------------------------------------------------------------------#

# test PhreeqcRM dtor
Expand All @@ -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$<$<CONFIG:Debug>:Debug>")
endif()

#-----------------------------------------------------------------------------#

# test BMIPhreeqcRM dtor
Expand All @@ -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$<$<CONFIG:Debug>:Debug>")
endif()

#-----------------------------------------------------------------------------#

# test compile and run
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d814739

Please sign in to comment.