Skip to content

Commit

Permalink
Merge pull request #46 from stephenswat/build/top_level_only
Browse files Browse the repository at this point in the history
Allow tests, etc. only in top level builds
  • Loading branch information
stephenswat authored Nov 15, 2024
2 parents 9e64360 + bf083ea commit 934889a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 79 deletions.
23 changes: 22 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at http://mozilla.org/MPL/2.0/.

cmake_minimum_required(VERSION 3.18)
cmake_minimum_required(VERSION 3.21)

project("covfie" VERSION 0.10.0)

Expand Down Expand Up @@ -41,16 +41,37 @@ add_subdirectory(lib)

# The benchmarks should be build only if requested...
if(COVFIE_BUILD_BENCHMARKS)
if(NOT PROJECT_IS_TOP_LEVEL)
message(
FATAL_ERROR
"Build of benchmarks was requested, but covfie is not the top level project."
)
endif()

add_subdirectory(benchmarks)
endif()

# ...the same goes for the tests...
if(COVFIE_BUILD_TESTS)
if(NOT PROJECT_IS_TOP_LEVEL)
message(
FATAL_ERROR
"Build of tests was requested, but covfie is not the top level project."
)
endif()

add_subdirectory(tests)
endif()

# ...and the examples.
if(COVFIE_BUILD_EXAMPLES)
if(NOT PROJECT_IS_TOP_LEVEL)
message(
FATAL_ERROR
"Build of examples was requested, but covfie is not the top level project."
)
endif()

add_subdirectory(examples)
endif()

Expand Down
15 changes: 1 addition & 14 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,7 @@

# All the tests here will require Google Test, so we will go ahead and set it
# up.
# Set up GoogleTest.
option(COVFIE_SETUP_GOOGLETEST "Set up the GoogleTest targets explicitly" TRUE)
option(
COVFIE_USE_SYSTEM_GOOGLETEST
"Pick up an existing installation of GoogleTest from the build environment"
TRUE
)
if(COVFIE_SETUP_GOOGLETEST)
if(COVFIE_USE_SYSTEM_GOOGLETEST)
find_package(GTest CONFIG REQUIRED)
else()
add_subdirectory(googletest)
endif()
endif()
find_package(GTest CONFIG REQUIRED)

# Set up the C++ compiler flags for the tests.
include(covfie-compiler-options-cpp)
Expand Down
54 changes: 0 additions & 54 deletions tests/googletest/CMakeLists.txt

This file was deleted.

10 changes: 0 additions & 10 deletions tests/googletest/README.md

This file was deleted.

0 comments on commit 934889a

Please sign in to comment.