<commit_before># CMakeLists.txt for the cuda-api-wrappers project
#
# Notes:
#
# CUDA is very picky about which compiler you can use.
# CUDA 7.x supports gcc up to version 4.9.x
# CUDA 8.x supports gcc up to version 5.x
# CUDA 9.x supports gcc up to version 6.x
#
# (and newer versions of clang seems to support CUDA compilation as well,
# although the API wrappers haven't been tested with those yet)
#
# One way to force the use of a different compiler with CMake is to run it as follows:
#
# cmake -D CMAKE_C_COMPILER=/path/to/your/cc -D CMAKE_CXX_COMPILER=/path/to/your/c++ your_project_dir
#
# and recall also that libraries must also have been built with a compatible compiler
#

# We need version 3.8 for native CUDA support in CMake
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")

# -----------------------------------
# Project name, version & build type
# -----------------------------------


if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
    set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif()

message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")

PROJECT(cuda-api-wrappers
	LANGUAGES CUDA CXX)

#	# No versioning for now
#
#	set(PROJECT_MAJOR_VERSION 0)
#	set(PROJECT_MINOR_VERSION 1)
#	set(PROJECT_PATCH_VERSION 0)
#	set(PROJECT_VERSION ${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION}.${PROJECT_PATCH_VERSION})


# ----------------------------
# General C++ build settings
# ----------------------------

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wpedantic -Werror=sign-compare" )
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

include_directories( "src/" )

# -------------
# CUDA
# -------------

#find_package(CUDA 7.0 REQUIRED) # Why do I to do this damn it ?!
#include_directories( "${CUDA_TOOLKIT_INCLUDE}" )
include_directories( ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES} )
include(HandleCUDAComputeCapability)

set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler -Wall" )
set(CMAKE_CUDA_STANDARD 11)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
set(CMAKE_CUDA_EXTENSIONS ON)

set(CUDA_SEPARABLE_COMPILATION ON) # Does this work with native CUDA support?
set(CUDA_PROPAGATE_HOST_FLAGS OFF) # Does this work with native CUDA support?

# This should really have been automatic...
#get_filename_component(CUDA_LIBRARY_DIR ${CUDA_CUDART_LIBRARY} DIRECTORY)
#set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} "-L${CUDA_LIBRARY_DIR}" )

#set(CUDA_LIBRARIES ${CUDA_LIBRARIES} ${CUDA_NVTX_LIBRARY} ${CUDA_cudadevrt_LIBRARY})

# The FindCUDA script forces the use of the libcublas library when perform device linkage;
# but on some systems and in certain situations, its inclusion on the command line
# triggers various kinds of errors; so - we ensure it is empty and unused
#set(CUDA_cublas_device_LIBRARY "" CACHE FILEPATH "Path of the CUBLAS library - unused dummy value" FORCE)



# -----------------------
# Main target(s)
# -----------------------

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "lib/")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "lib/")

add_library(
	cuda-api-wrappers
	src/cuda/api/device_properties.cpp
	src/cuda/api/profiling.cpp
	src/cuda/api/ipc.hpp
	src/cuda/api/event.hpp
	src/cuda/api/device_properties.hpp
	src/cuda/api/pointer.hpp
	src/cuda/api/multi_wrapper_impls.hpp
	src/cuda/api/current_device.hpp
	src/cuda/api/peer_to_peer.hpp
	src/cuda/api/device.hpp
	src/cuda/api/pci_id.hpp
	src/cuda/api/versions.hpp
	src/cuda/api/unique_ptr.hpp
	src/cuda/api/memory.hpp
	src/cuda/api/device_count.hpp
	src/cuda/api/stream.hpp
	src/cuda/api/error.hpp
	src/cuda/api/device_function.hpp
	src/cuda/api/miscellany.hpp
)

# -----------------------
# Examples / Tests<commit_msg>Drop the headers as dependencies from the `cuda-api-wrappers` library<commit_after># CMakeLists.txt for the cuda-api-wrappers project
#
# Notes:
#
# CUDA is very picky about which compiler you can use.
# CUDA 7.x supports gcc up to version 4.9.x
# CUDA 8.x supports gcc up to version 5.x
# CUDA 9.x supports gcc up to version 6.x
#
# (and newer versions of clang seems to support CUDA compilation as well,
# although the API wrappers haven't been tested with those yet)
#
# One way to force the use of a different compiler with CMake is to run it as follows:
#
# cmake -D CMAKE_C_COMPILER=/path/to/your/cc -D CMAKE_CXX_COMPILER=/path/to/your/c++ your_project_dir
#
# and recall also that libraries must also have been built with a compatible compiler
#

# We need version 3.8 for native CUDA support in CMake
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")

# -----------------------------------
# Project name, version & build type
# -----------------------------------


if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
    set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif()

message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")

PROJECT(cuda-api-wrappers
	LANGUAGES CUDA CXX)

#	# No versioning for now
#
#	set(PROJECT_MAJOR_VERSION 0)
#	set(PROJECT_MINOR_VERSION 1)
#	set(PROJECT_PATCH_VERSION 0)
#	set(PROJECT_VERSION ${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION}.${PROJECT_PATCH_VERSION})


# ----------------------------
# General C++ build settings
# ----------------------------

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wpedantic -Werror=sign-compare" )
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

include_directories( "src/" )

# -------------
# CUDA
# -------------

#find_package(CUDA 7.0 REQUIRED) # Why do I to do this damn it ?!
#include_directories( "${CUDA_TOOLKIT_INCLUDE}" )
include_directories( ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES} )
include(HandleCUDAComputeCapability)

set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler -Wall" )
set(CMAKE_CUDA_STANDARD 11)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
set(CMAKE_CUDA_EXTENSIONS ON)

set(CUDA_SEPARABLE_COMPILATION ON) # Does this work with native CUDA support?
set(CUDA_PROPAGATE_HOST_FLAGS OFF) # Does this work with native CUDA support?

# This should really have been automatic...
#get_filename_component(CUDA_LIBRARY_DIR ${CUDA_CUDART_LIBRARY} DIRECTORY)
#set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} "-L${CUDA_LIBRARY_DIR}" )

#set(CUDA_LIBRARIES ${CUDA_LIBRARIES} ${CUDA_NVTX_LIBRARY} ${CUDA_cudadevrt_LIBRARY})

# The FindCUDA script forces the use of the libcublas library when perform device linkage;
# but on some systems and in certain situations, its inclusion on the command line
# triggers various kinds of errors; so - we ensure it is empty and unused
#set(CUDA_cublas_device_LIBRARY "" CACHE FILEPATH "Path of the CUBLAS library - unused dummy value" FORCE)



# -----------------------
# Main target(s)
# -----------------------

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "lib/")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "lib/")

add_library(
	cuda-api-wrappers
	src/cuda/api/device_properties.cpp
	src/cuda/api/profiling.cpp
)

# -----------------------
# Examples / Tests
{'fraction_non_alphanumeric': 0.15221040850587578, 'fraction_numerical': 0.005595970900951315, 'mean_word_length': 3.859959211420802, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 2, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '710610', 'n_tokens_mistral': 2676, 'n_tokens_neox': 2495, 'n_words': 620}