Skip to content

Commit

Permalink
fix cmake install
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike-Leo-Smith committed Feb 7, 2024
1 parent a44879c commit cd181b8
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 1 deletion.
24 changes: 24 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,30 @@ else ()
endif ()
endif ()

# rpath
set(CMAKE_MACOSX_RPATH ON)
set(CMAKE_SKIP_BUILD_RPATH OFF)
set(CMAKE_BUILD_RPATH_USE_ORIGIN ON)
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)

if (APPLE)
set(CMAKE_INSTALL_RPATH "@loader_path;@loader_path/../bin;@loader_path/../lib")
elseif (UNIX)
set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../bin;$ORIGIN/../lib")
endif ()

if (NOT CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "dist")
endif ()

# set up install directories
include(GNUInstallDirs)
if (NOT WIN32)
# DLLs are installed in the same directory as executables
set(CMAKE_INSTALL_LIBDIR ${CMAKE_INSTALL_BINDIR})
endif ()

set(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL)
set(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC)

Expand Down
5 changes: 4 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ function(luisa_render_add_plugin name)
set_target_properties(${lib_name} PROPERTIES
UNITY_BUILD OFF
DEBUG_POSTFIX "")
install(TARGETS ${lib_name}
LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endfunction()

add_subdirectory(films)
Expand All @@ -74,8 +77,8 @@ add_subdirectory(environments)
add_subdirectory(lightsamplers)
add_subdirectory(phasefunctions)
add_subdirectory(texturemappings)
add_library(luisa-render INTERFACE)

add_library(luisa-render INTERFACE)
target_link_libraries(luisa-render INTERFACE
luisa-render-ext
luisa-render-sdl
Expand Down
3 changes: 3 additions & 0 deletions src/apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ function(luisa_render_add_application name)
cmake_parse_arguments(APP "" "" "SOURCES" ${ARGN})
add_executable(${name} ${APP_SOURCES})
target_link_libraries(${name} PRIVATE luisa::render)
install(TARGETS ${name}
LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endfunction()

luisa_render_add_application(luisa-render-cli SOURCES cli.cpp)
Expand Down
4 changes: 4 additions & 0 deletions src/base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ target_link_libraries(luisa-render-base PUBLIC
set_target_properties(luisa-render-base PROPERTIES
WINDOWS_EXPORT_ALL_SYMBOLS ON
UNITY_BUILD ${LUISA_RENDER_ENABLE_UNITY_BUILD})

install(TARGETS luisa-render-base
LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
4 changes: 4 additions & 0 deletions src/sdl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ target_link_libraries(luisa-render-sdl PUBLIC
set_target_properties(luisa-render-sdl PROPERTIES
WINDOWS_EXPORT_ALL_SYMBOLS ON
UNITY_BUILD ${LUISA_RENDER_ENABLE_UNITY_BUILD})

install(TARGETS luisa-render-sdl
LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3 changes: 3 additions & 0 deletions src/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ target_link_libraries(luisa-render-util PUBLIC
set_target_properties(luisa-render-util PROPERTIES
WINDOWS_EXPORT_ALL_SYMBOLS ON
UNITY_BUILD ${LUISA_RENDER_ENABLE_UNITY_BUILD})
install(TARGETS luisa-render-util
LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

0 comments on commit cd181b8

Please sign in to comment.