Skip to content

Commit

Permalink
Try to Fix Paths in Tests and Putback MSVC_RUNTIME
Browse files Browse the repository at this point in the history
  • Loading branch information
iguessthislldo committed Oct 11, 2023
1 parent 2662c87 commit d2767ce
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 19 deletions.
39 changes: 24 additions & 15 deletions cmake/ace_group.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,30 @@ function(_opendds_vs_force_static)
# systems, is the same kind everywhere. Normally we shouldn't make global
# changes, but if we don't do this, MSVC won't link the programs if the
# runtimes of compiled objects are different.
# This is based on an old CMake FAQ:
# https://web.archive.org/web/20210319004154/https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#dynamic-replace
# At some point at or before CMake 3.26 these became cache variables.
# There are alternative methods of making this work, like
# MSVC_RUNTIME_LIBRARY, but this method seems like it works best for our
# purposes.
foreach(flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" new_value "${${flag_var}}")
set(${flag_var} "${new_value}" CACHE INTERNAL
"CXX Flags (Overridden by OpenDDS to match /MT* with ACE)")
endif()
endforeach()
# See the following for more info:
# https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html#variable:CMAKE_MSVC_RUNTIME_LIBRARY
# https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#how-can-i-build-my-msvc-application-with-a-static-runtime
cmake_policy(GET CMP0091 policy91)
if(policy91 STREQUAL NEW)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" CACHE STRING "" FORCE)
else()
foreach(flag_var
CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
string(REGEX REPLACE "/M[DT][d]? " "" value "${${flag_var}}")
string(REGEX REPLACE " /M[DT][d]?" "" value "${value}")
string(REGEX REPLACE "/M[DT][d]?" "" value "${value}")
if(value)
set(value "${value} ")
endif()
set(value "${value}/MT")
if(flag_var STREQUAL "CMAKE_CXX_FLAGS_DEBUG")
set(value "${value}d")
endif()
set(${flag_var} "${value}" CACHE STRING
"CXX Flags (Overridden by OpenDDS to match /MT* with ACE)" FORCE)
endforeach()
endif()
endfunction()

if(MSVC AND OPENDDS_STATIC)
Expand Down
8 changes: 7 additions & 1 deletion cmake/init.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,13 @@ function(_opendds_pop_list list_var)
endfunction()

function(_opendds_path_list path_list_var)
set(path_list)
if("APPEND" IN_LIST ARGN)
set(path_list "${${path_list_var}}")
list(REMOVE_ITEM ARGN APPEND)
else()
set(path_list)
endif()

if(WIN32)
set(delimiter ";")
else()
Expand Down
5 changes: 2 additions & 3 deletions cmake/opendds_testing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ function(opendds_add_test)
endif()
_opendds_path_list(lib_dir_list "$ENV{${env_var_name}}" "${TAO_LIB_DIR}")
foreach(lib_dir "${OPENDDS_LIB_DIR}" ${arg_EXTRA_LIB_DIRS})
_opendds_path_list(lib_dir_list "$ENV{${env_var_name}}" "${lib_dir}")
_opendds_path_list(lib_dir_list APPEND "${lib_dir}")
if(CMAKE_CONFIGURATION_TYPES)
_opendds_path_list(lib_dir_list
"$ENV{${env_var_name}}" "${lib_dir}$<$<BOOL:$<CONFIG>>:/$<CONFIG>>")
_opendds_path_list(lib_dir_list APPEND "${lib_dir}$<$<BOOL:$<CONFIG>>:/$<CONFIG>>")
endif()
endforeach()
if(WIN32)
Expand Down

0 comments on commit d2767ce

Please sign in to comment.