Fixed RPATH for installed examples and tests on Linux

0.8
Bruno Van de Velde 2018-12-09 11:52:16 +01:00
parent 5bbd751f9d
commit 1da27207ba
2 changed files with 31 additions and 4 deletions

View File

@ -31,10 +31,22 @@ macro(tgui_add_example target)
tgui_set_global_compile_flags(${target})
tgui_set_stdlib(${target})
set(target_install_dir ${TGUI_MISC_INSTALL_PREFIX}/examples/${target})
# Set the RPATH of the executable on Linux and BSD
if (TGUI_SHARED_LIBS AND (TGUI_OS_LINUX OR TGUI_OS_BSD))
file(RELATIVE_PATH rel_lib_dir
${CMAKE_INSTALL_PREFIX}/${target_install_dir}
${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
set_target_properties(${target} PROPERTIES
INSTALL_RPATH "$ORIGIN/${rel_lib_dir}")
endif()
# Add the install rule for the executable
install(TARGETS ${target}
RUNTIME DESTINATION ${TGUI_MISC_INSTALL_PREFIX}/examples/${target} COMPONENT examples
BUNDLE DESTINATION ${TGUI_MISC_INSTALL_PREFIX}/examples/${target} COMPONENT examples)
RUNTIME DESTINATION ${target_install_dir} COMPONENT examples
BUNDLE DESTINATION ${target_install_dir} COMPONENT examples)
endmacro()

View File

@ -115,15 +115,30 @@ add_custom_command(TARGET tests
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/themes/Black.png $<TARGET_FILE_DIR:tests>/resources
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/themes/Black.txt $<TARGET_FILE_DIR:tests>/resources)
set(target_install_dir ${TGUI_MISC_INSTALL_PREFIX}/tests/)
# Set the RPATH of the executable on Linux and BSD
if (TGUI_SHARED_LIBS AND (TGUI_OS_LINUX OR TGUI_OS_BSD))
file(RELATIVE_PATH rel_lib_dir
${CMAKE_INSTALL_PREFIX}/${target_install_dir}
${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
set_target_properties(tests PROPERTIES
INSTALL_RPATH "$ORIGIN/${rel_lib_dir}")
endif()
# Add the install rule for the executable
install(TARGETS tests
RUNTIME DESTINATION ${TGUI_MISC_INSTALL_PREFIX}/tests/ COMPONENT tests
BUNDLE DESTINATION ${TGUI_MISC_INSTALL_PREFIX}/tests/ COMPONENT tests)
RUNTIME DESTINATION ${target_install_dir} COMPONENT tests
BUNDLE DESTINATION ${target_install_dir} COMPONENT tests)
# Install the resources next to the test executable
install(DIRECTORY "${PROJECT_SOURCE_DIR}/tests/resources"
DESTINATION "${TGUI_MISC_INSTALL_PREFIX}/tests"
COMPONENT tests)
install(DIRECTORY "${PROJECT_SOURCE_DIR}/tests/expected"
DESTINATION "${TGUI_MISC_INSTALL_PREFIX}/tests"
COMPONENT tests)
install(DIRECTORY "${PROJECT_SOURCE_DIR}/themes/"
DESTINATION "${TGUI_MISC_INSTALL_PREFIX}/tests/resources"
COMPONENT tests)