Skip to content

Commit

Permalink
Checking for nvcc 10 and gcc 8 and setting flags accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
khuck committed Feb 26, 2021
1 parent 351baa2 commit 855c0f9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
37 changes: 23 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,6 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
endif()
endif()

if(APEX_WITH_CUDA)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9)
message(INFO " Building CUPTI support, but GCC is too new for CUDA tests")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
message(INFO " Building CUPTI support, but Clang can't build CUDA tests")
else()
# OK to enable CUDA tests
enable_language(CUDA)
set(APEX_CUDA_TESTS TRUE)
endif()
find_package(CUDAToolkit REQUIRED QUIET COMPONENTS CUPTI)
endif(APEX_WITH_CUDA)

# if the user didn't specify, set the installation directory.
if(NOT DEFINED CMAKE_INSTALL_PREFIX OR CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
SET(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}" CACHE STRING "APEX Installation directory" FORCE)
Expand Down Expand Up @@ -118,6 +104,29 @@ IF("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
endif(NOT DEFINED APEX_BUILD_EXAMPLES)
endif()

if(APEX_WITH_CUDA)
# This is needed so that the nvcc compiler test passes, and we can use it to
# compile the test cases.
if(APEX_BUILD_TESTS)
if ( (CMAKE_CXX_COMPILER_ID MATCHES GNU) AND (CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64.*$") )
if ( (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0) AND (CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 11.0) )
set (CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler -std=c++11")
endif ()
endif ()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9)
message(INFO " Building CUPTI support, but GCC is too new for CUDA tests")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
message(INFO " Building CUPTI support, but Clang can't build CUDA tests")
else()
# OK to enable CUDA tests
enable_language(CUDA)
set(APEX_CUDA_TESTS TRUE)
endif()
endif()
find_package(CUDAToolkit REQUIRED QUIET COMPONENTS CUPTI)
endif(APEX_WITH_CUDA)

# set(APEX_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING "Configuration type (one of Debug, RelWithDebInfo, Release, MinSizeRel)" FORCE)

# Always force CMAKE_CONFIGURATION_TYPES to be the same as CMAKE_BUILD_TYPE
Expand Down
1 change: 1 addition & 0 deletions cmake/Modules/APEX_DefaultOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ option (APEX_WITH_TCMALLOC "Enable TCMalloc heap management" FALSE)
option (APEX_WITH_JEMALLOC "Enable JEMalloc heap management" FALSE)
option (APEX_WITH_LM_SENSORS "Enable LM Sensors support" FALSE)
option (APEX_BUILD_TESTS "Build APEX tests (for 'make test')" TRUE)
option (APEX_CUDA_TESTS "Build APEX CUDA tests (for 'make test')" FALSE)
option (APEX_BUILD_EXAMPLES "Build APEX examples" TRUE)
option (APEX_SANITIZE "Enable compiler sanitizer flags" FALSE)
option (APEX_BUILD_ACTIVEHARMONY "Build ActiveHarmony library if not found" FALSE)
Expand Down

0 comments on commit 855c0f9

Please sign in to comment.