diff --git a/CMakeLists.txt b/CMakeLists.txt index 17dd33363..8c1ea82c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,9 @@ set(MODEL_DIR set(CORE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/core" CACHE PATH "Path to core") +set(DEPENDENT_DLLS + "" + CACHE INTERNAL "Dependent DLLs of core.dll") set(CMAKE_POSITION_INDEPENDENT_CODE ON) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index a91d86253..bd8d97412 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -27,6 +27,7 @@ message("core will be installed to: ${CMAKE_INSTALL_PREFIX}") file(GLOB_RECURSE core_sources "src/*.cpp") # coreライブラリのビルド設定 +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) add_library(core SHARED ${core_sources} ${EMBED_YUKARIN_S_OUTPUTS} @@ -51,6 +52,9 @@ if(NOT DIRECTML) "${ONNXRUNTIME_DIR}/lib/*.lib" "${ONNXRUNTIME_DIR}/lib/*.so" "${ONNXRUNTIME_DIR}/lib/*.so.*") + file(GLOB ONNXRUNTIME_DLLS + "${ONNXRUNTIME_DIR}/lib/*.dll") + set(DEPENDENT_DLLS "${DEPENDENT_DLLS};${ONNXRUNTIME_DLLS}" PARENT_SCOPE) target_include_directories(core PRIVATE ${ONNXRUNTIME_DIR}/include) target_link_directories(core PUBLIC ${ONNXRUNTIME_DIR}/lib) @@ -79,6 +83,9 @@ else() file(GLOB DIRECTML_LIBS "${DIRECTML_DIR}/bin/${DML_ARCH}-win/*.dll" "${DIRECTML_DIR}/bin/${DML_ARCH}-win/*.lib") + file(GLOB DIRECTML_DLLS + "${DIRECTML_DIR}/bin/${DML_ARCH}-win/*.dll") + set(DEPENDENT_DLLS "${DEPENDENT_DLLS};${DIRECTML_DLLS}" PARENT_SCOPE) target_include_directories(core PRIVATE ${DIRECTML_DIR}/include) target_link_directories(core PUBLIC ${DIRECTML_DIR}/bin/${DML_ARCH}-win/) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index db512192b..1e013a3df 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -19,6 +19,12 @@ target_include_directories(unit_test PRIVATE ${Catch2_SOURCE_DIR}/src) target_include_directories(unit_test PRIVATE ${CORE_DIR}/src) target_link_libraries(unit_test PRIVATE Catch2::Catch2WithMain) target_link_libraries(unit_test PRIVATE core) +if (WIN32) + add_custom_command(TARGET unit_test POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "$;${DEPENDENT_DLLS}" $ + COMMAND_EXPAND_LISTS ) +endif (WIN32) list(APPEND CMAKE_MODULE_PATH ${Catch2_SOURCE_DIR}/extras) include(Catch) include(CTest)