Skip to content

Commit

Permalink
Windows環境でビルドできるように設定を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
qwerty2501 committed May 13, 2022
1 parent cb1595d commit 69c75b5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 7 additions & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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)
Expand Down Expand Up @@ -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/)
Expand Down
6 changes: 6 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
"$<TARGET_FILE:core>;${DEPENDENT_DLLS}" $<TARGET_FILE_DIR:unit_test>
COMMAND_EXPAND_LISTS )
endif (WIN32)
list(APPEND CMAKE_MODULE_PATH ${Catch2_SOURCE_DIR}/extras)
include(Catch)
include(CTest)
Expand Down

0 comments on commit 69c75b5

Please sign in to comment.