@@ -262,6 +262,33 @@ if(BUILD_TESTING)
262262 set (RTI_BIN_PATH "$ENV{RTI_OPENSSL_BIN} " )
263263 file (TO_CMAKE_PATH "${RTI_BIN_PATH} " RTI_BIN_PATH)
264264 set (TEST_PATH "${RTI_BIN_PATH} ;${ENV_PATH} " )
265+ if (WIN32 )
266+ string (REPLACE "\\ " "\\\\ " RTI_OPENSSL_LIBS "$ENV{RTI_OPENSSL_LIBS} " )
267+ set (append_library_dirs "${append_library_dirs} ;${RTI_OPENSSL_LIBS} " )
268+ else ()
269+ set (append_library_dirs "${append_library_dirs} :$ENV{RTI_OPENSSL_LIBS} " )
270+ endif ()
271+
272+ else ()
273+ # TODO(mikaelarguedas) Move this outside the 'if not connext' block once Connext supports OpenSSL 1.1.1
274+ if (APPLE )
275+ # connext need the openssl libraries to be on the DYLD_LIBRARY_PATH at runtime
276+ # as SIP strips these variables on recent MacOS we populate them here
277+ # see https://github.com/ros2/ros2/issues/409
278+ execute_process (
279+ COMMAND "brew" "--prefix" "openssl"
280+ RESULT_VARIABLE _retcode
281+ OUTPUT_VARIABLE _out_var
282+ ERROR_VARIABLE _error_var
283+ )
284+ if (NOT _retcode EQUAL 0)
285+ message (FATAL_ERROR "command 'brew --prefix openssl' failed with error code '${_retcode} ' and error message '${_error_var} '" )
286+ endif ()
287+ string (STRIP "${_out_var} " _out_var)
288+ set (openssl_lib_path "${_out_var} /lib" )
289+ file (TO_NATIVE_PATH "${openssl_lib_path} " openssl_lib_path)
290+ set (append_library_dirs "${append_library_dirs} ;${openssl_lib_path} " )
291+ endif ()
265292 endif ()
266293
267294 if (NOT WIN32 )
@@ -292,29 +319,6 @@ if(BUILD_TESTING)
292319 set (append_library_dirs "${CMAKE_CURRENT_BINARY_DIR} " )
293320 if (WIN32 )
294321 set (append_library_dirs "${append_library_dirs} /$<CONFIG>" )
295- string (REPLACE "\\ " "\\\\ " RTI_OPENSSL_LIBS "$ENV{RTI_OPENSSL_LIBS} " )
296- set (append_library_dirs "${append_library_dirs} ;${RTI_OPENSSL_LIBS} " )
297- # TODO(mikaelarguedas) uncomment this once Connext supports OpenSSL 1.1.1
298- # in the meantime use RTI_OPENSSL_LIBS
299- # elseif(APPLE)
300- # # connext need the openssl libraries to be on the DYLD_LIBRARY_PATH at runtime
301- # # as SIP strips these variables on recent MacOS we populate them here
302- # # see https://github.com/ros2/ros2/issues/409
303- # execute_process(
304- # COMMAND "brew" "--prefix" "openssl"
305- # RESULT_VARIABLE _retcode
306- # OUTPUT_VARIABLE _out_var
307- # ERROR_VARIABLE _error_var
308- # )
309- # if(NOT _retcode EQUAL 0)
310- # message(FATAL_ERROR "command 'brew --prefix openssl' failed with error code '${_retcode}' and error message '${_error_var}'")
311- # endif()
312- # string(STRIP "${_out_var}" _out_var)
313- # set(openssl_lib_path "${_out_var}/lib")
314- # file(TO_NATIVE_PATH "${openssl_lib_path}" openssl_lib_path)
315- # set(append_library_dirs "${append_library_dirs};${openssl_lib_path}")
316- else ()
317- set (append_library_dirs "${append_library_dirs} :$ENV{RTI_OPENSSL_LIBS} " )
318322 endif ()
319323
320324 # finding gtest once in the highest scope
0 commit comments