diff options
author | damageboy <125730+damageboy@users.noreply.github.com> | 2023-05-04 09:54:03 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-04 08:54:03 +0200 |
commit | 41e206e435b3c84a6fdd937dfe2a07e8ee73e611 (patch) | |
tree | baebbe2cbdf04e06dc81490aef7e59db27843774 | |
parent | 936b9ab5515dead115606559502e3864958f7f6e (diff) | |
download | cpu_features-41e206e435b3c84a6fdd937dfe2a07e8ee73e611.tar.gz |
cmake: make default test building dependent on being a main project build vs. being included into other projects (#290)
-rw-r--r-- | CMakeLists.txt | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index bcc9bb0..0967200 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,14 @@ project(CpuFeatures VERSION 0.8.0 LANGUAGES C) set(CMAKE_C_STANDARD 99) +# when cpu_features is included as subproject (i.e. using add_subdirectory(cpu_features)) +# in the source tree of a project that uses it, test rules are disabled. +if(NOT CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) + option(BUILD_TESTING "Enable test rule" OFF) +else() + option(BUILD_TESTING "Enable test rule" ON) +endif() + # Default Build Type to be Release if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release" CACHE STRING |