Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
adds check that downstream compiler match the ginkgo compiler
  • Loading branch information
MarcelKoch committed Aug 1, 2023
commit 99fbda3721c2c21d654e542cbc8b3c4c9afcdf92
33 changes: 31 additions & 2 deletions cmake/GinkgoConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ set(GINKGO_JACOBI_FULL_OPTIMIZATIONS @GINKGO_JACOBI_FULL_OPTIMIZATIONS@)

set(GINKGO_CUDA_ARCHITECTURES "@GINKGO_CUDA_ARCHITECTURES@")
set(GINKGO_CUDA_DEFAULT_HOST_COMPILER @GINKGO_CUDA_DEFAULT_HOST_COMPILER@)
set(GINKGO_CUDA_HOST_COMPILER "@CMAKE_CUDA_HOST_COMPILER@")
set(GINKGO_CUDA_ARCH_FLAGS "@GINKGO_CUDA_ARCH_FLAGS@")

set(GINKGO_HIP_COMPILER_FLAGS "@GINKGO_HIP_COMPILER_FLAGS@")
Expand Down Expand Up @@ -91,6 +90,15 @@ set(GINKGO_HAVE_HWLOC @GINKGO_HAVE_HWLOC@)

set(GINKGO_HAVE_ROCTX @GINKGO_HAVE_ROCTX@)

# Ginkgo compiler information
set(GINKGO_CXX_COMPILER "@CMAKE_CXX_COMPILER@")
set(GINKGO_CXX_COMPILER_SHORT "@CMAKE_CXX_COMPILER_ID@:@CMAKE_CXX_COMPILER_VERSION@")
set(GINKGO_CUDA_COMPILER "@CMAKE_CUDA_COMPILER@")
set(GINKGO_CUDA_COMPILER_SHORT "@CMAKE_CUDA_COMPILER_ID@:@CMAKE_CUDA_COMPILER_VERSION@")
set(GINKGO_CUDA_HOST_COMPILER "@CMAKE_CUDA_HOST_COMPILER@")
set(GINKGO_CUDA_HOST_COMPILER_SHORT "") # dummy value to stay consistent
set(GINKGO_HIP_COMPILER "@HIP_HIPCC@")

# Ginkgo installation configuration
set(GINKGO_INSTALL_PREFIX "@PACKAGE_CMAKE_INSTALL_PREFIX@")
set(GINKGO_INSTALL_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR@")
Expand All @@ -107,7 +115,6 @@ if(GINKGO_BUILD_HIP)
endif()
list(APPEND CMAKE_PREFIX_PATH "${GINKGO_INSTALL_PREFIX}")


set(GINKGO_INTERFACE_LINK_LIBRARIES "@GINKGO_INTERFACE_LINK_LIBRARIES@")
set(GINKGO_INTERFACE_LINK_FLAGS "@GINKGO_INTERFACE_LINK_FLAGS@")
set(GINKGO_INTERFACE_CXX_FLAGS "@GINKGO_INTERFACE_CXX_FLAGS@")
Expand Down Expand Up @@ -207,4 +214,26 @@ if((NOT GINKGO_BUILD_SHARED_LIBS) AND GINKGO_HAVE_TAU)
find_package(PerfStubs REQUIRED)
endif()

# Check that the same compilers as for Ginkgo are used
function(_ginkgo_check_compiler lang)
if(NOT ${CMAKE_${lang}_COMPILER} STREQUAL ${GINKGO_${lang}_COMPILER})
set(_compiler_short "${CMAKE_${lang}_COMPILER_ID}:${CMAKE_${lang}_COMPILER_VERSION}")
Comment thread
upsj marked this conversation as resolved.
if(NOT _compiler_short STREQUAL ${GINKGO_${lang}_COMPILER_SHORT})
message(WARNING "The currently used ${lang} compiler: ${CMAKE_${lang}_COMPILER} does not match the compiler used to "
"build Ginkgo: ${GINKGO_${lang}_COMPILER}. It is encouraged to use the same compiler as Ginkgo to prevent ABI mismatch.")
endif()
endif()
endfunction()
_ginkgo_check_compiler(CXX)
if(GINKGO_BUILD_CUDA)
_ginkgo_check_compiler(CUDA)
endif()
if(GINKGO_BUILD_HIP)
_ginkgo_check_compiler(HIP)
if(NOT HIP_HIPCC STREQUAL ${GINKGO_HIP_COMPILER})
message(WARNING "The currently used HIP compiler: ${HIP_HIPCC} does not match the compiler used to "
"build Ginkgo: ${GINKGO_HIP_COMPILER}. It is encouraged to use the same compiler as Ginkgo to prevent ABI mismatch.")
endif()
endif()

include(${CMAKE_CURRENT_LIST_DIR}/GinkgoTargets.cmake)