Unverified Commit 77968e30 authored by Minjie Wang's avatar Minjie Wang Committed by GitHub
Browse files

[Build] use different flags for NVCC and CC (#2342)

parent cb2bc69b
...@@ -89,9 +89,11 @@ if(MSVC) ...@@ -89,9 +89,11 @@ if(MSVC)
endif() endif()
else(MSVC) else(MSVC)
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++14" SUPPORT_CXX14) 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++14 ${CMAKE_CXX_FLAGS}") # We still use c++11 flag in CPU build because gcc5.4 (our default compiler) is
# not fully compatible with c++14 feature.
set(CMAKE_CXX_FLAGS "-O2 -Wall -fPIC -std=c++11 ${CMAKE_CXX_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--warn-common ${CMAKE_SHARED_LINKER_FLAGS}") set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--warn-common ${CMAKE_SHARED_LINKER_FLAGS}")
endif(MSVC) endif(MSVC)
......
...@@ -239,18 +239,30 @@ macro(dgl_config_cuda out_variable) ...@@ -239,18 +239,30 @@ macro(dgl_config_cuda out_variable)
src/geometry/cuda/*.cu src/geometry/cuda/*.cu
) )
# NVCC flags
# Manually set everything
set(CUDA_PROPAGATE_HOST_FLAGS OFF)
# 0. Add host flags
message(STATUS "${CMAKE_CXX_FLAGS}")
string(REGEX REPLACE "[ \t\n\r]" "," CXX_HOST_FLAGS "${CMAKE_CXX_FLAGS}")
list(APPEND CUDA_NVCC_FLAGS "-Xcompiler ,${CXX_HOST_FLAGS}")
# 1. Add arch flags
dgl_select_nvcc_arch_flags(NVCC_FLAGS_ARCH) dgl_select_nvcc_arch_flags(NVCC_FLAGS_ARCH)
string(REPLACE ";" " " NVCC_FLAGS_ARCH "${NVCC_FLAGS_ARCH}") list(APPEND CUDA_NVCC_FLAGS ${NVCC_FLAGS_ARCH})
set(NVCC_FLAGS_EXTRA ${NVCC_FLAGS_ARCH})
# for lambda support in moderngpu # 2. flags in third_party/moderngpu
set(NVCC_FLAGS_EXTRA "${NVCC_FLAGS_EXTRA} --expt-extended-lambda") list(APPEND CUDA_NVCC_FLAGS "--expt-extended-lambda;-Wno-deprecated-declarations")
# suppress deprecated warning in moderngpu
set(NVCC_FLAGS_EXTRA "${NVCC_FLAGS_EXTRA} -Wno-deprecated-declarations")
# for compile with c++14 # 3. CUDA 11 requires c++14 by default
set(NVCC_FLAGS_EXTRA "${NVCC_FLAGS_EXTRA} --expt-extended-lambda --std=c++14") include(CheckCXXCompilerFlag)
message(STATUS "NVCC extra flags: ${NVCC_FLAGS_EXTRA}") check_cxx_compiler_flag("-std=c++14" SUPPORT_CXX14)
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} ${NVCC_FLAGS_EXTRA}") string(REPLACE "-std=c++11" "" CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS}")
list(APPEND CMAKE_CUDA_FLAGS "${NVCC_FLAGS_EXTRA}") list(APPEND CUDA_NVCC_FLAGS "--std=c++14")
message(STATUS "CUDA flags: ${CUDA_NVCC_FLAGS}")
list(APPEND DGL_LINKER_LIBS list(APPEND DGL_LINKER_LIBS
${CUDA_CUDART_LIBRARY} ${CUDA_CUDART_LIBRARY}
......
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