Skip to content

Commit

Permalink
Change project structure: tests as subdirectory, not as a separate pr…
Browse files Browse the repository at this point in the history
…oject

Also:
- Set `FETCHCONTENT_BASE_DIR` to default
  • Loading branch information
congard committed Sep 8, 2024
1 parent 44f540c commit d9133e0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}/tests
-S ${{ github.workspace }}
- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
Expand Down
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ project(tulz)

set(CMAKE_CXX_STANDARD 20)

option(TULZ_ENABLE_TESTS "Turn it off in order to disable tests" ON)

set(TULZ_OBSERVER_SOURCES
include/tulz/observer/Observer.h
include/tulz/observer/Subject.h
Expand Down Expand Up @@ -96,4 +98,9 @@ target_include_directories(tulz PUBLIC include)

if (ANDROID)
target_include_directories(tulz PUBLIC android/include)
endif()

if (TULZ_ENABLE_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
14 changes: 0 additions & 14 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
cmake_minimum_required(VERSION 3.14)
project(tulz-tests)

enable_testing()

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(FetchContent)

if (UNIX)
set(DEPS_DIR "deps")
elseif (WIN32)
set(DEPS_DIR "deps-win")
else()
message(FATAL_ERROR "Unsupported OS")
endif()

get_filename_component(FETCHCONTENT_BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${DEPS_DIR}" REALPATH)

FetchContent_Declare(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0)
Expand All @@ -27,8 +15,6 @@ set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)

FetchContent_MakeAvailable(googletest)

add_subdirectory(../ tulz)

include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})

function(add_gtest name src)
Expand Down

0 comments on commit d9133e0

Please sign in to comment.