diff --git a/cmake/Utils.cmake b/cmake/Utils.cmake index 3c58241d..72e18778 100644 --- a/cmake/Utils.cmake +++ b/cmake/Utils.cmake @@ -49,3 +49,12 @@ function(UpdateConfigOption file_name old_option_name new_option_name) file(APPEND ${file_name} "\n" ${current_value}) endif() endfunction() + +function(DoAppleMariaDBCopy target location) +if(APPLE) + add_custom_command(TARGET ${target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${MARIADBCPP_SHARED_LIBRARY_LOCATION} + ${location}) + endif() +endfunction() diff --git a/dMasterServer/CMakeLists.txt b/dMasterServer/CMakeLists.txt index 260e4f16..e6d10867 100644 --- a/dMasterServer/CMakeLists.txt +++ b/dMasterServer/CMakeLists.txt @@ -18,3 +18,4 @@ target_link_libraries(MasterServer ${COMMON_LIBRARIES} bcrypt dMasterServer dSer if(WIN32) add_dependencies(MasterServer WorldServer AuthServer ChatServer) endif() +DoAppleMariaDBCopy(MasterServer ${CMAKE_BINARY_DIR}) diff --git a/tests/dCommonTests/CMakeLists.txt b/tests/dCommonTests/CMakeLists.txt index b90aa4c0..c38caa98 100644 --- a/tests/dCommonTests/CMakeLists.txt +++ b/tests/dCommonTests/CMakeLists.txt @@ -22,16 +22,7 @@ if(MSVC) add_dependencies(dCommonTests zlib_tests) endif() # Apple needs some special linkage for the mariadb connector for tests. -if(APPLE) -add_custom_command(TARGET dCommonTests POST_BUILD - COMMAND otool ARGS -l dCommonTests - COMMAND otool ARGS -L dCommonTests - COMMAND ls - COMMAND otool ARGS -D libmariadbcpp.dylib - COMMAND install_name_tool ARGS -change libmariadbcpp.dylib @rpath/libmariadbcpp.dylib dCommonTests - COMMAND otool ARGS -L dCommonTests - WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) -endif() +DoAppleMariaDBCopy(dCommonTests ${CMAKE_CURRENT_BINARY_DIR}) # Link needed libraries target_link_libraries(dCommonTests ${COMMON_LIBRARIES} GTest::gtest_main) diff --git a/tests/dGameTests/CMakeLists.txt b/tests/dGameTests/CMakeLists.txt index 58f213e0..499363b9 100644 --- a/tests/dGameTests/CMakeLists.txt +++ b/tests/dGameTests/CMakeLists.txt @@ -15,12 +15,7 @@ add_executable(dGameTests ${DGAMETEST_SOURCES}) add_dependencies(dGameTests conncpp_tests) # Apple needs some special linkage for the mariadb connector for tests. -if(APPLE) -add_custom_command(TARGET dGameTests POST_BUILD - COMMAND install_name_tool ARGS -change libmariadbcpp.dylib @rpath/libmariadbcpp.dylib dGameTests - COMMAND otool ARGS -L dGameTests - WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) -endif() +DoAppleMariaDBCopy(dGameTests ${CMAKE_CURRENT_BINARY_DIR}) target_link_libraries(dGameTests ${COMMON_LIBRARIES} GTest::gtest_main dGame dScripts dPhysics Detour Recast tinyxml2 dWorldServer dZoneManager dChatFilter dNavigation)