From b1964a37bf00d523f148b59d05070e880d18b52b Mon Sep 17 00:00:00 2001 From: Cong Date: Tue, 30 Apr 2024 21:02:48 +1000 Subject: [PATCH] Fix rpath --- src/CMakeLists.txt | 4 +-- src/tests/CMakeLists.txt | 57 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 275a0e5f4..261be6699 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -77,7 +77,7 @@ if(APPLE) set_target_properties(cdogs-sdl PROPERTIES MACOSX_RPATH 1 BUILD_WITH_INSTALL_RPATH 1 - INSTALL_RPATH "@loader_path/../Frameworks") + INSTALL_RPATH "@loader_path/../Frameworks;/Library/Frameworks") elseif(MSVC) set_target_properties(cdogs-sdl PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/src") endif() @@ -98,7 +98,7 @@ if(BUILD_EDITOR) set_target_properties(cdogs-sdl-editor PROPERTIES MACOSX_RPATH 1 BUILD_WITH_INSTALL_RPATH 1 - INSTALL_RPATH "@loader_path/../Frameworks") + INSTALL_RPATH "@loader_path/../Frameworks;/Library/Frameworks") elseif(MSVC) set_target_properties(cdogs-sdl-editor PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/src") endif() diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index ce4c22c32..36ed08bb5 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -24,6 +24,12 @@ target_link_libraries(animated_counter_test SDL2::SDL2 ${EXTRA_LIBRARIES}) add_test(NAME animated_counter_test COMMAND animated_counter_test) +if(APPLE) + set_target_properties(animated_counter_test PROPERTIES + MACOSX_RPATH 1 + BUILD_WITH_INSTALL_RPATH 1 + INSTALL_RPATH "@loader_path/../Frameworks;/Library/Frameworks") +endif() add_executable(actor_test actor_test.c @@ -36,6 +42,12 @@ target_link_libraries(actor_test SDL2::SDL2 ${EXTRA_LIBRARIES}) add_test(NAME actor_test COMMAND actor_test) +if(APPLE) + set_target_properties(actor_test PROPERTIES + MACOSX_RPATH 1 + BUILD_WITH_INSTALL_RPATH 1 + INSTALL_RPATH "@loader_path/../Frameworks;/Library/Frameworks") +endif() add_executable(autosave_test autosave_test.c @@ -48,6 +60,12 @@ target_link_libraries(autosave_test SDL2::SDL2 ${EXTRA_LIBRARIES}) add_test(NAME autosave_test COMMAND autosave_test) +if(APPLE) + set_target_properties(autosave_test PROPERTIES + MACOSX_RPATH 1 + BUILD_WITH_INSTALL_RPATH 1 + INSTALL_RPATH "@loader_path/../Frameworks;/Library/Frameworks") +endif() add_executable(c_hashmap_test c_hashmap_test.c @@ -79,6 +97,12 @@ target_link_libraries(config_test SDL2::SDL2 ${EXTRA_LIBRARIES}) add_test(NAME config_test COMMAND config_test) +if(APPLE) + set_target_properties(config_test PROPERTIES + MACOSX_RPATH 1 + BUILD_WITH_INSTALL_RPATH 1 + INSTALL_RPATH "@loader_path/../Frameworks;/Library/Frameworks") +endif() add_executable(json_test json_test.c) target_link_libraries(json_test @@ -88,6 +112,12 @@ target_link_libraries(json_test SDL2::SDL2 ${EXTRA_LIBRARIES}) add_test(NAME json_test COMMAND json_test) +if(APPLE) + set_target_properties(json_test PROPERTIES + MACOSX_RPATH 1 + BUILD_WITH_INSTALL_RPATH 1 + INSTALL_RPATH "@loader_path/../Frameworks;/Library/Frameworks") +endif() add_executable(minkowski_hex_test minkowski_hex_test.c) target_link_libraries(minkowski_hex_test @@ -97,6 +127,12 @@ target_link_libraries(minkowski_hex_test SDL2::SDL2 ${EXTRA_LIBRARIES}) add_test(NAME minkowski_hex_test COMMAND minkowski_hex_test) +if(APPLE) + set_target_properties(minkowski_hex_test PROPERTIES + MACOSX_RPATH 1 + BUILD_WITH_INSTALL_RPATH 1 + INSTALL_RPATH "@loader_path/../Frameworks;/Library/Frameworks") +endif() add_executable(pic_test pic_test.c) target_link_libraries(pic_test @@ -106,8 +142,13 @@ target_link_libraries(pic_test SDL2::SDL2 SDL2_image::SDL2_image ${EXTRA_LIBRARIES}) -# TODO: test disabled since Travis-CI fails with "No available video device" -#add_test(NAME pic_test COMMAND pic_test) +add_test(NAME pic_test COMMAND pic_test) +if(APPLE) + set_target_properties(pic_test PROPERTIES + MACOSX_RPATH 1 + BUILD_WITH_INSTALL_RPATH 1 + INSTALL_RPATH "@loader_path/../Frameworks;/Library/Frameworks") +endif() add_executable(player_test player_test.c) target_link_libraries(player_test @@ -117,6 +158,12 @@ target_link_libraries(player_test SDL2::SDL2 ${EXTRA_LIBRARIES}) add_test(NAME player_test COMMAND player_test) +if(APPLE) + set_target_properties(player_test PROPERTIES + MACOSX_RPATH 1 + BUILD_WITH_INSTALL_RPATH 1 + INSTALL_RPATH "@loader_path/../Frameworks;/Library/Frameworks") +endif() add_executable(utils_test utils_test.c) target_link_libraries(utils_test @@ -125,3 +172,9 @@ target_link_libraries(utils_test cdogs_proto SDL2::SDL2 ${EXTRA_LIBRARIES}) add_test(NAME utils_test COMMAND utils_test) +if(APPLE) + set_target_properties(utils_test PROPERTIES + MACOSX_RPATH 1 + BUILD_WITH_INSTALL_RPATH 1 + INSTALL_RPATH "@loader_path/../Frameworks;/Library/Frameworks") +endif()