Skip to content

Commit

Permalink
[Bugfix] three bugs related to using DGL as a subdirectory(third_part…
Browse files Browse the repository at this point in the history
…y) of another project. (dmlc#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.
  • Loading branch information
yuanzexi authored Oct 14, 2021
1 parent 5d4f6bc commit 1886306
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/")
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/runtime/shared_mem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

Expand All @@ -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
}

Expand Down

0 comments on commit 1886306

Please sign in to comment.