Build pciutils only if neccesary
This commit is contained in:
@@ -10,9 +10,10 @@ set(CUDA_DIR "${SRC_DIR}/cuda")
|
|||||||
set(HSA_DIR "${SRC_DIR}/hsa")
|
set(HSA_DIR "${SRC_DIR}/hsa")
|
||||||
set(INTEL_DIR "${SRC_DIR}/intel")
|
set(INTEL_DIR "${SRC_DIR}/intel")
|
||||||
|
|
||||||
# Enable Intel backend by default
|
# Make sure that at least one backend is enabled.
|
||||||
if(NOT DEFINED ENABLE_INTEL_BACKEND)
|
# It does not make sense that the user has not specified any backend.
|
||||||
set(ENABLE_INTEL_BACKEND true)
|
if(NOT ENABLE_INTEL_BACKEND AND NOT ENABLE_CUDA_BACKEND AND NOT ENABLE_HSA_BACKEND)
|
||||||
|
message(FATAL_ERROR "No backend was enabled! Please enable at least one backend with -DENABLE_XXX_BACKEND")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_CUDA_BACKEND)
|
if(ENABLE_CUDA_BACKEND)
|
||||||
@@ -66,31 +67,51 @@ if(ENABLE_HSA_BACKEND)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
set(GPUFECH_COMMON
|
||||||
find_package(PCIUTILS)
|
${COMMON_DIR}/main.cpp
|
||||||
if(NOT ${PCIUTILS_FOUND})
|
${COMMON_DIR}/args.cpp
|
||||||
message(STATUS "${BoldYellow}pciutils not found, downloading and building a local copy...${ColorReset}")
|
${COMMON_DIR}/gpu.cpp
|
||||||
|
${COMMON_DIR}/sort.cpp
|
||||||
|
${COMMON_DIR}/global.cpp
|
||||||
|
${COMMON_DIR}/printer.cpp
|
||||||
|
${COMMON_DIR}/master.cpp
|
||||||
|
${COMMON_DIR}/uarch.cpp
|
||||||
|
)
|
||||||
|
|
||||||
# Download and build pciutils
|
if(NOT(ENABLE_HSA_BACKEND AND NOT ENABLE_CUDA_BACKEND AND NOT ENABLE_INTEL_BACKEND))
|
||||||
set(PCIUTILS_INSTALL_LOCATION ${CMAKE_BINARY_DIR}/pciutils-install)
|
# Look for pciutils only if not building HSA only.
|
||||||
ExternalProject_Add(pciutils
|
#
|
||||||
GIT_REPOSITORY https://github.com/pciutils/pciutils
|
# This has the (intented) secondary effect that if only HSA backend is enabled
|
||||||
CONFIGURE_COMMAND ""
|
# by the user, but ROCm cannot be found, pciutils will still be compiled in
|
||||||
BUILD_COMMAND make SHARED=no HWDB=no
|
# order to show the list of GPUs available on the system, so that the user will
|
||||||
BUILD_IN_SOURCE true
|
# get at least some feedback even if HSA is not found.
|
||||||
INSTALL_COMMAND make PREFIX=${PCIUTILS_INSTALL_LOCATION} install-lib
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
||||||
)
|
list(APPEND GPUFECH_COMMON ${COMMON_DIR}/pci.cpp)
|
||||||
|
find_package(PCIUTILS)
|
||||||
|
if(NOT ${PCIUTILS_FOUND})
|
||||||
|
message(STATUS "${BoldYellow}pciutils not found, downloading and building a local copy...${ColorReset}")
|
||||||
|
|
||||||
include_directories(${PCIUTILS_INSTALL_LOCATION}/include)
|
# Download and build pciutils
|
||||||
link_directories(${PCIUTILS_INSTALL_LOCATION}/lib)
|
set(PCIUTILS_INSTALL_LOCATION ${CMAKE_BINARY_DIR}/pciutils-install)
|
||||||
else()
|
ExternalProject_Add(pciutils
|
||||||
include_directories(${PCIUTILS_INCLUDE_DIR})
|
GIT_REPOSITORY https://github.com/pciutils/pciutils
|
||||||
link_libraries(${PCIUTILS_LIBRARIES})
|
CONFIGURE_COMMAND ""
|
||||||
# Needed for linking libpci in FreeBSD
|
BUILD_COMMAND make SHARED=no HWDB=no
|
||||||
link_directories(/usr/local/lib/)
|
BUILD_IN_SOURCE true
|
||||||
|
INSTALL_COMMAND make PREFIX=${PCIUTILS_INSTALL_LOCATION} install-lib
|
||||||
|
)
|
||||||
|
|
||||||
|
include_directories(${PCIUTILS_INSTALL_LOCATION}/include)
|
||||||
|
link_directories(${PCIUTILS_INSTALL_LOCATION}/lib)
|
||||||
|
else()
|
||||||
|
include_directories(${PCIUTILS_INCLUDE_DIR})
|
||||||
|
link_libraries(${PCIUTILS_LIBRARIES})
|
||||||
|
# Needed for linking libpci in FreeBSD
|
||||||
|
link_directories(/usr/local/lib/)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(gpufetch ${COMMON_DIR}/main.cpp ${COMMON_DIR}/args.cpp ${COMMON_DIR}/gpu.cpp ${COMMON_DIR}/pci.cpp ${COMMON_DIR}/sort.cpp ${COMMON_DIR}/global.cpp ${COMMON_DIR}/printer.cpp ${COMMON_DIR}/master.cpp ${COMMON_DIR}/uarch.cpp)
|
add_executable(gpufetch ${GPUFECH_COMMON})
|
||||||
set(SANITY_FLAGS -Wfloat-equal -Wshadow -Wpointer-arith -Wall -Wextra -pedantic -fstack-protector-all -pedantic)
|
set(SANITY_FLAGS -Wfloat-equal -Wshadow -Wpointer-arith -Wall -Wextra -pedantic -fstack-protector-all -pedantic)
|
||||||
target_compile_features(gpufetch PRIVATE cxx_std_11)
|
target_compile_features(gpufetch PRIVATE cxx_std_11)
|
||||||
target_compile_options(gpufetch PRIVATE ${SANITY_FLAGS})
|
target_compile_options(gpufetch PRIVATE ${SANITY_FLAGS})
|
||||||
|
|||||||
Reference in New Issue
Block a user