From 7ec1cec6ba96cbfee0d5e5f7cd338491ec4b8d05 Mon Sep 17 00:00:00 2001 From: Bryan Bernhart Date: Mon, 18 Jul 2022 22:11:20 -0700 Subject: [PATCH] Remove CMAKE_*_OUTPUT_DIRECTORY from being specified as PROJECT_SOURCE_DIR. --- .github/workflows/win_msvc_dbg_x64_cmake.yaml | 6 +- .github/workflows/win_msvc_rel_x64_cmake.yaml | 6 +- CMakeLists.txt | 92 +++++++++---------- 3 files changed, 50 insertions(+), 54 deletions(-) diff --git a/.github/workflows/win_msvc_dbg_x64_cmake.yaml b/.github/workflows/win_msvc_dbg_x64_cmake.yaml index 3ea2d09b5..d2f1b834c 100644 --- a/.github/workflows/win_msvc_dbg_x64_cmake.yaml +++ b/.github/workflows/win_msvc_dbg_x64_cmake.yaml @@ -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 diff --git a/.github/workflows/win_msvc_rel_x64_cmake.yaml b/.github/workflows/win_msvc_rel_x64_cmake.yaml index 0c9162a46..6194223a3 100644 --- a/.github/workflows/win_msvc_rel_x64_cmake.yaml +++ b/.github/workflows/win_msvc_rel_x64_cmake.yaml @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 94a07d403..8b7287bbb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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, @@ -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 @@ -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 _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) @@ -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. @@ -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