Skip to content

Commit

Permalink
[misc] MoltenVK dynamic library & allow overriding CLANG_EXECUTABLE (t…
Browse files Browse the repository at this point in the history
…aichi-dev#3565)

* MoltenVK dynamic library & allow overriding CLANG_EXECUTABLE

* Auto Format

* Only copy in molten if we are building with vulkan

Co-authored-by: Taichi Gardener <[email protected]>
  • Loading branch information
bobcao3 and taichi-gardener authored Nov 22, 2021
1 parent 6a69df0 commit 504b3ba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ if (TI_WITH_CUDA)
set(CUDA_ARCH "cuda")
endif()

if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
if (CLANG_EXECUTABLE)
message("Clang executable ${CLANG_EXECUTABLE}")
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set (CLANG_EXECUTABLE ${CMAKE_CXX_COMPILER})
else()
find_program(CLANG_EXECUTABLE NAMES clang clang-10 clang-11 clang-9 clang-8 clang-7)
Expand Down
6 changes: 4 additions & 2 deletions cmake/TaichiCore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,10 @@ if (TI_WITH_VULKAN)
endif()

if (APPLE)
find_library(MOLTEN_VK libMoltenVK.a /opt/homebrew/Cellar/molten-vk)
target_link_libraries(${CORE_LIBRARY_NAME} ${MOLTEN_VK})
find_library(MOLTEN_VK libMoltenVK.dylib PATHS $HOMEBREW_CELLAR/molten-vk $VULKAN_SDK REQUIRED)
configure_file(${MOLTEN_VK} ${CMAKE_BINARY_DIR}/libMoltenVK.dylib COPYONLY)
target_link_directories(${CORE_LIBRARY_NAME} PUBLIC ${CMAKE_BINARY_DIR})
target_link_libraries(${CORE_LIBRARY_NAME} MoltenVK)
message(STATUS "MoltenVK library ${MOLTEN_VK}")
endif()
endif ()
Expand Down
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ def prepare_package(self):
shutil.copy(
os.path.join(self.build_temp, 'libtaichi_core.dylib'),
os.path.join(target, 'taichi_core.so'))
moltenvk_path = os.path.join(self.build_temp,
'libMoltenVK.dylib')
if os.path.exists(moltenvk_path):
shutil.copy(moltenvk_path,
os.path.join(target, 'libMoltenVK.dylib'))
else:
shutil.copy('runtimes/Release/taichi_core.dll',
os.path.join(target, 'taichi_core.pyd'))
Expand Down

0 comments on commit 504b3ba

Please sign in to comment.