Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions .github/workflows/win_msvc_dbg_x64_cmake.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ jobs:
shell: cmd
run: |
cd test
Debug\gpgmm_end2end_tests.exe 2>&1
bin\Debug\gpgmm_end2end_tests.exe 2>&1

- name: Run gpgmm_unittests (with patch)
shell: cmd
run: |
cd test
Debug\gpgmm_unittests.exe
bin\Debug\gpgmm_unittests.exe

- name: Run gpgmm_capture_replay_tests (with patch)
shell: cmd
run: |
cd test
Debug\gpgmm_capture_replay_tests.exe --log-level=DEBUG 2>&1
bin\Debug\gpgmm_capture_replay_tests.exe --log-level=DEBUG 2>&1
6 changes: 3 additions & 3 deletions .github/workflows/win_msvc_rel_x64_cmake.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ jobs:
shell: cmd
run: |
cd test
Release\gpgmm_end2end_tests.exe 2>&1
bin\Release\gpgmm_end2end_tests.exe 2>&1

- name: Run gpgmm_unittests (with patch)
shell: cmd
run: |
cd test
Release\gpgmm_unittests.exe
bin\Release\gpgmm_unittests.exe

- name: Run gpgmm_capture_replay_tests (with patch)
shell: cmd
run: |
cd test
Release\gpgmm_capture_replay_tests.exe
bin\Release\gpgmm_capture_replay_tests.exe
92 changes: 44 additions & 48 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -16,9 +16,9 @@
cmake_minimum_required(VERSION 3.14)

project(
GPGMM
DESCRIPTION "GPGMM, a General-Purpose GPU Memory Management Library"
LANGUAGES C CXX
GPGMM
DESCRIPTION "GPGMM, a General-Purpose GPU Memory Management Library"
LANGUAGES C CXX
)

# USE_FOLDERS allows organizing CMake into a hierarchy of folders using the
Expand All @@ -27,70 +27,66 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)

set(CMAKE_CXX_STANDARD 17)

# Always specify (aka initialize) the output directories.
# Otherwise, the runtime (exe) and library (DLL), could be built under different folders
# paths where running the executable directly could fail to find the DLL.
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR})

if(NOT CMAKE_BUILD_TYPE)
message(WARNING "CMAKE_BUILD_TYPE not set, forcing it to Debug")
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
"Build type (Debug, Release, RelWithDebInfo, MinSizeRel)" FORCE)
message(WARNING "CMAKE_BUILD_TYPE not set, forcing it to Debug")
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
"Build type (Debug, Release, RelWithDebInfo, MinSizeRel)" FORCE)
endif()

# Only <PROJECT-NAME>_SOURCE_DIR is created by the project() command above.
set(GPGMM_ROOT_DIR "${GPGMM_SOURCE_DIR}")
set(GPGMM_INCLUDE_DIR "${GPGMM_ROOT_DIR}/src/include")

################################################################################
# ###############################################################################
# Configuration options
################################################################################
# ###############################################################################

# option_if_not_defined(name description default)
# Behaves like:
# option(name description default)
# option(name description default)
# If a variable is not already defined with the given name, otherwise the
# function does nothing.
function (option_if_not_defined name description default)
if(NOT DEFINED ${name})
option(${name} ${description} ${default})
endif()
function(option_if_not_defined name description default)
if(NOT DEFINED ${name})
option(${name} ${description} ${default})
endif()
endfunction()

# set_if_not_defined(name value description)
# Behaves like:
# set(${name} ${value} CACHE STRING ${description})
# set(${name} ${value} CACHE STRING ${description})
# If a variable is not already defined with the given name, otherwise the
# function does nothing.
function (set_if_not_defined name value description)
if(NOT DEFINED ${name})
set(${name} ${value} CACHE STRING ${description})
endif()
function(set_if_not_defined name value description)
if(NOT DEFINED ${name})
set(${name} ${value} CACHE STRING ${description})
endif()
endfunction()

# Default values for the backend-enabling options
set(ENABLE_D3D12 OFF)
set(ENABLE_VK OFF)
if (WIN32)
set(ENABLE_D3D12 ON)
if (NOT WINDOWS_STORE)
# Enable Vulkan in win32 compilation only
# since UWP only supports d3d
set(ENABLE_VK ON)
endif()
elseif(UNIX)

if(WIN32)
set(ENABLE_D3D12 ON)

if(NOT WINDOWS_STORE)
# Enable Vulkan in win32 compilation only
# since UWP only supports d3d
set(ENABLE_VK ON)
endif()
elseif(UNIX)
set(ENABLE_VK ON)
endif()

# Uses our built version of the Vulkan loader on platforms where we can't
# assume to have one present at the system level.
set(ENABLE_VK_LOADER OFF)
if (APPLE OR (UNIX AND NOT ANDROID))
if (ENABLE_VK)
set(ENABLE_VK_LOADER ON)
endif()

if(APPLE OR(UNIX AND NOT ANDROID))
if(ENABLE_VK)
set(ENABLE_VK_LOADER ON)
endif()
endif()

option_if_not_defined(GPGMM_STANDALONE "When building from GPGMM's repository" ON)
Expand All @@ -116,22 +112,22 @@ option_if_not_defined(GPGMM_ENABLE_MEMORY_LEAK_CHECKS "Enables memory leak detec
option_if_not_defined(gpgmm_enable_resource_memory_align_checks "Enables checking of resource alignment." OFF)

# The Vulkan loader is an optional dependency.
if (GPGMM_ENABLE_VK)
if (GPGMM_ENABLE_VK_STATIC_FUNCTIONS OR GPGMM_ENABLE_VK_LOADER)
set(GPGMM_ENABLE_VK_LOADER ON)
endif()
if(GPGMM_ENABLE_VK)
if(GPGMM_ENABLE_VK_STATIC_FUNCTIONS OR GPGMM_ENABLE_VK_LOADER)
set(GPGMM_ENABLE_VK_LOADER ON)
endif()
endif()

if (GPGMM_ENABLE_TESTS)
enable_testing()
if(GPGMM_ENABLE_TESTS)
enable_testing()
endif()

################################################################################
# ###############################################################################
# GPGMM's public and common "configs"
################################################################################
# ###############################################################################
set(GPGMM_INCLUDE_DIRS
"${GPGMM_ROOT_DIR}/src"
"${GPGMM_INCLUDE_DIR}"
"${GPGMM_INCLUDE_DIR}"
)

# Where GPGMM public .h files can be found.
Expand All @@ -145,7 +141,7 @@ add_library(gpgmm_common_config INTERFACE)
target_link_libraries(gpgmm_common_config INTERFACE gpgmm_public_config)

# Compile definitions for the common config
if (GPGMM_ALWAYS_ASSERT)
if(GPGMM_ALWAYS_ASSERT)
target_compile_definitions(gpgmm_common_config INTERFACE "GPGMM_ENABLE_ASSERTS")
else()
target_compile_definitions(gpgmm_common_config INTERFACE
Expand Down