Unverified Commit 18863069 authored by zexi yuan's avatar zexi yuan Committed by GitHub
Browse files

[Bugfix] three bugs related to using DGL as a subdirectory(third_party) of another project. (#3379)

* [Bugfix] fix a compile error for Debug-BuildType on Windows Platform

When using CMakeLists.txt to build the "Debug" BuildType on the Windows Platform, it has three compile errors (C4716) in the file "dgl\src\runtime\shared_mem.cc":

'dgl::runtime::SharedMemory::CreateNew': must return a value
'dgl::runtime::SharedMemory::Open': must return a value
'dgl::runtime::SharedMemory::Exist': must return a value

* [Bugfix] cmake error "cannot find load file" when DGL as a sub_directory on Linux

When using DGL as a subdirectory in a CMake Project, the "CMAKE_SOURCE_DIR" here will return the parent cmake scope dir, which is not a expected dir.
Maybe it is better to use "CMAKE_CURRENT_SOURCE_DIR" to set "GKLIB_PATH".

* [Bugfix] cmd cmake error when DGL as a subdirectory

When DGL as a subdirectory of another project, the WORKING_DIRECTORY of "add_custom_command" will be incorrect at the line 255 of "CMakeLists.txt", such that making a cmake "setlocal" error.
parent 5d4f6bca
......@@ -220,7 +220,7 @@ set(GOOGLE_TEST 0) # Turn off dmlc-core test
# Compile METIS
if(NOT MSVC)
set(GKLIB_PATH "${CMAKE_SOURCE_DIR}/third_party/METIS/GKlib")
set(GKLIB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/third_party/METIS/GKlib")
include(${GKLIB_PATH}/GKlibSystem.cmake)
include_directories(${GKLIB_PATH})
include_directories("third_party/METIS/include/")
......@@ -259,7 +259,7 @@ target_link_libraries(dgl ${DGL_LINKER_LIBS} ${DGL_RUNTIME_LINKER_LIBS})
if(MSVC)
add_custom_command(
TARGET dgl POST_BUILD COMMAND
cmd.exe /c "COPY /Y Release\\dgl.dll .")
${CMAKE_COMMAND} -E copy "$<TARGET_FILE:dgl>" "$<TARGET_FILE_DIR:dgl>/..")
endif(MSVC)
# Tensor adapter libraries
......
......@@ -86,6 +86,7 @@ void *SharedMemory::CreateNew(size_t sz) {
return ptr_;
#else
LOG(FATAL) << "Shared memory is not supported on Windows.";
return nullptr;
#endif // _WIN32
}
......@@ -101,6 +102,7 @@ void *SharedMemory::Open(size_t sz) {
return ptr_;
#else
LOG(FATAL) << "Shared memory is not supported on Windows.";
return nullptr;
#endif // _WIN32
}
......@@ -115,6 +117,7 @@ bool SharedMemory::Exist(const std::string &name) {
}
#else
LOG(FATAL) << "Shared memory is not supported on Windows.";
return false;
#endif // _WIN32
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment