Commit e35e860a authored by Quan (Andy) Gan's avatar Quan (Andy) Gan Committed by Minjie Wang
Browse files

[Build] Support older CMake & OpenMP toggle (#619)

* cmake fixes for older systems

* allow specification of cuda path

* test script fixes to enable openmp & test

* update minigun; disable minigun partial frontier compile
parent 34dfaf75
cmake_minimum_required(VERSION 3.9) cmake_minimum_required(VERSION 3.5)
######################################## ########################################
# Borrowed and adapted from TVM project # Borrowed and adapted from TVM project
######################################## ########################################
...@@ -27,7 +27,7 @@ dgl_option(BUILD_CPP_TEST "Build cpp unittest executables" OFF) ...@@ -27,7 +27,7 @@ dgl_option(BUILD_CPP_TEST "Build cpp unittest executables" OFF)
if(USE_CUDA) if(USE_CUDA)
message(STATUS "Build with CUDA support") message(STATUS "Build with CUDA support")
project(dgl C CXX CUDA) project(dgl C CXX)
include(cmake/modules/CUDA.cmake) include(cmake/modules/CUDA.cmake)
endif(USE_CUDA) endif(USE_CUDA)
...@@ -70,13 +70,18 @@ else(MSVC) ...@@ -70,13 +70,18 @@ else(MSVC)
check_cxx_compiler_flag("-std=c++11" SUPPORT_CXX11) check_cxx_compiler_flag("-std=c++11" SUPPORT_CXX11)
set(CMAKE_C_FLAGS "-O2 -Wall -fPIC ${CMAKE_C_FLAGS}") set(CMAKE_C_FLAGS "-O2 -Wall -fPIC ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-O2 -Wall -fPIC -std=c++11 ${CMAKE_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "-O2 -Wall -fPIC -std=c++11 ${CMAKE_CXX_FLAGS}")
endif(MSVC)
if(USE_OPENMP)
include(FindOpenMP) include(FindOpenMP)
if(OPENMP_FOUND) if(OPENMP_FOUND)
set(CMAKE_C_FLAGS "${OpenMP_C_FLAGS} ${CMAKE_C_FLAGS}") set(CMAKE_C_FLAGS "${OpenMP_C_FLAGS} ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${OpenMP_CXX_FLAGS} ${CMAKE_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "${OpenMP_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
endif(OPENMP_FOUND) endif(OPENMP_FOUND)
endif(MSVC) endif(USE_OPENMP)
# configure minigun
add_definitions(-DENABLE_PARTIAL_FRONTIER=0) # disable minigun partial frontier compile
# Source file lists # Source file lists
file(GLOB DGL_SRC file(GLOB DGL_SRC
...@@ -93,6 +98,7 @@ file(GLOB_RECURSE DGL_SRC_1 ...@@ -93,6 +98,7 @@ file(GLOB_RECURSE DGL_SRC_1
list(APPEND DGL_SRC ${DGL_SRC_1}) list(APPEND DGL_SRC ${DGL_SRC_1})
# Configure cuda
if(USE_CUDA) if(USE_CUDA)
dgl_config_cuda(DGL_CUDA_SRC) dgl_config_cuda(DGL_CUDA_SRC)
list(APPEND DGL_SRC ${DGL_CUDA_SRC}) list(APPEND DGL_SRC ${DGL_CUDA_SRC})
......
...@@ -36,3 +36,6 @@ set(USE_CUDA OFF) ...@@ -36,3 +36,6 @@ set(USE_CUDA OFF)
#--------------------------------------------- #---------------------------------------------
# Whether to build cpp unittest executables # Whether to build cpp unittest executables
set(BUILD_CPP_TEST OFF) set(BUILD_CPP_TEST OFF)
# Whether to enable OpenMP
set(USE_OPENMP ON)
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
# find_cuda(${USE_CUDA}) # find_cuda(${USE_CUDA})
# #
# - When USE_CUDA=ON, use auto search # - When USE_CUDA=ON, use auto search
# - When USE_CUDA=/path/to/cuda-path, use the cuda path #
# Please use the CMAKE variable CUDA_TOOLKIT_ROOT_DIR to set CUDA directory
# #
# Provide variables: # Provide variables:
# #
...@@ -21,21 +22,7 @@ ...@@ -21,21 +22,7 @@
macro(find_cuda use_cuda) macro(find_cuda use_cuda)
set(__use_cuda ${use_cuda}) set(__use_cuda ${use_cuda})
if(__use_cuda STREQUAL "ON") if(__use_cuda STREQUAL "ON")
find_package(CUDA QUIET) include(FindCUDA)
elseif(IS_DIRECTORY ${__use_cuda})
set(CUDA_TOOLKIT_ROOT_DIR ${__use_cuda})
message(STATUS "Custom CUDA_PATH=" ${CUDA_TOOLKIT_ROOT_DIR})
set(CUDA_INCLUDE_DIRS ${CUDA_TOOLKIT_ROOT_DIR}/include)
set(CUDA_FOUND TRUE)
if(MSVC)
find_library(CUDA_CUDART_LIBRARY cudart
${CUDA_TOOLKIT_ROOT_DIR}/lib/x64
${CUDA_TOOLKIT_ROOT_DIR}/lib/Win32)
else(MSVC)
find_library(CUDA_CUDART_LIBRARY cudart
${CUDA_TOOLKIT_ROOT_DIR}/lib64
${CUDA_TOOLKIT_ROOT_DIR}/lib)
endif(MSVC)
endif() endif()
# additional libraries # additional libraries
......
...@@ -7,7 +7,7 @@ MD build ...@@ -7,7 +7,7 @@ MD build
PUSHD build PUSHD build
CALL "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat" CALL "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
cmake -DCMAKE_CXX_FLAGS="/DDGL_EXPORTS" -Dgtest_force_shared_crt=ON -DBUILD_CPP_TEST=1 -DCMAKE_CONFIGURATION_TYPES="Release" .. -G "Visual Studio 15 2017 Win64" || EXIT /B 1 cmake -DCMAKE_CXX_FLAGS="/DDGL_EXPORTS" -DUSE_OPENMP=ON -Dgtest_force_shared_crt=ON -DBUILD_CPP_TEST=1 -DCMAKE_CONFIGURATION_TYPES="Release" .. -G "Visual Studio 15 2017 Win64" || EXIT /B 1
msbuild dgl.sln || EXIT /B 1 msbuild dgl.sln || EXIT /B 1
COPY Release\dgl.dll . COPY Release\dgl.dll .
COPY Release\runUnitTests.exe . COPY Release\runUnitTests.exe .
......
...@@ -6,9 +6,10 @@ if [ $# -ne 1 ]; then ...@@ -6,9 +6,10 @@ if [ $# -ne 1 ]; then
exit -1 exit -1
fi fi
CMAKE_VARS="-DBUILD_CPP_TEST=ON -DUSE_OPENMP=ON"
if [ "$1" == "gpu" ]; then if [ "$1" == "gpu" ]; then
cp cmake/config.cmake config.cmake CMAKE_VARS="-DUSE_CUDA=ON $CMAKE_VARS"
sed -i -e 's/USE_CUDA OFF/USE_CUDA ON/g' config.cmake
fi fi
if [ -d build ]; then if [ -d build ]; then
...@@ -19,7 +20,7 @@ mkdir build ...@@ -19,7 +20,7 @@ mkdir build
rm -rf _download rm -rf _download
pushd build pushd build
cmake .. -DBUILD_CPP_TEST=1 cmake $CMAKE_VARS ..
make -j4 make -j4
popd popd
......
Subproject commit bcf5f041dde6ce43264dd10159677eb81bd2eed9 Subproject commit e77ce949601570980f76630862ee838cf8bbc96a
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