Skip to content

Commit

Permalink
Support unit-test builds under CMake. (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
bbernhar authored Jun 9, 2022
1 parent 2c5fb7a commit 522ed99
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/win_msvc_dbg_x64_cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,9 @@ jobs:
run: |
cd test
cmake --build .
- name: Run gpgmm_unittests (with patch)
shell: cmd
run: |
cd test
src\tests\Debug\gpgmm_unittests.exe
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ set(CMAKE_CXX_STANDARD "14")
################################################################################
add_subdirectory(third_party)
add_subdirectory(src/gpgmm)
add_subdirectory(src/tests)

################################################################################
# Install GPGMM
Expand Down
41 changes: 41 additions & 0 deletions src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2021 The GPGMM Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# 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
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

###############################################################################
# Unit tests
###############################################################################

add_executable(gpgmm_unittests)

target_sources(gpgmm_unittests PRIVATE
"DummyMemoryAllocator.h"
"unittests/BuddyBlockAllocatorTests.cpp"
"unittests/ConditionalMemoryAllocatorTests.cpp"
"unittests/FlagsTests.cpp"
"unittests/LinkedListTests.cpp"
"unittests/MathTests.cpp"
"unittests/MemoryAllocatorTests.cpp"
"unittests/MemoryCacheTests.cpp"
"unittests/MemoryPoolTests.cpp"
"unittests/PooledMemoryAllocatorTests.cpp"
"unittests/RefCountTests.cpp"
"unittests/SegmentedMemoryAllocatorTests.cpp"
"unittests/SlabBlockAllocatorTests.cpp"
"unittests/SlabMemoryAllocatorTests.cpp"
"unittests/UtilsTest.cpp"
"UnittestsMain.cpp"
)

target_include_directories(gpgmm_unittests PRIVATE "${GPGMM_ROOT_DIR}/src")
target_link_libraries(gpgmm_unittests gpgmm gtest)
8 changes: 8 additions & 0 deletions third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@
if (NOT TARGET Vulkan-Headers)
add_subdirectory(${GPGMM_VK_HEADERS_DIR} "${CMAKE_CURRENT_BINARY_DIR}/vulkan-headers")
endif()

################################################################################
# Build subdirectories
################################################################################

# Prevent overriding the GPGMM's compiler/linker settings (or "mismatch detected" LNK2005 errors result)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
add_subdirectory(googletest)

0 comments on commit 522ed99

Please sign in to comment.