xref: /aosp_15_r20/external/vulkan-validation-layers/external/CMakeLists.txt (revision b7893ccf7851cd6a48cc5a1e965257d8a5cdcc70)
1*b7893ccfSSadaf Ebrahimi# ~~~
2*b7893ccfSSadaf Ebrahimi# Copyright (c) 2018 Valve Corporation
3*b7893ccfSSadaf Ebrahimi# Copyright (c) 2018 LunarG, Inc.
4*b7893ccfSSadaf Ebrahimi#
5*b7893ccfSSadaf Ebrahimi# Licensed under the Apache License, Version 2.0 (the "License");
6*b7893ccfSSadaf Ebrahimi# you may not use this file except in compliance with the License.
7*b7893ccfSSadaf Ebrahimi# You may obtain a copy of the License at
8*b7893ccfSSadaf Ebrahimi#
9*b7893ccfSSadaf Ebrahimi#     http://www.apache.org/licenses/LICENSE-2.0
10*b7893ccfSSadaf Ebrahimi#
11*b7893ccfSSadaf Ebrahimi# Unless required by applicable law or agreed to in writing, software
12*b7893ccfSSadaf Ebrahimi# distributed under the License is distributed on an "AS IS" BASIS,
13*b7893ccfSSadaf Ebrahimi# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14*b7893ccfSSadaf Ebrahimi# See the License for the specific language governing permissions and
15*b7893ccfSSadaf Ebrahimi# limitations under the License.
16*b7893ccfSSadaf Ebrahimi# ~~~
17*b7893ccfSSadaf Ebrahimi
18*b7893ccfSSadaf Ebrahimi# Add your optional dependencies in this "external" directory.
19*b7893ccfSSadaf Ebrahimi
20*b7893ccfSSadaf Ebrahimi# googletest is an optional external dependency for this repo.
21*b7893ccfSSadaf Ebrahimiif(BUILD_TESTS)
22*b7893ccfSSadaf Ebrahimi    # Attempt to enable googletest if available.
23*b7893ccfSSadaf Ebrahimi
24*b7893ccfSSadaf Ebrahimi    # Suppress all warnings from external projects (i.e.: in this directory's scope).
25*b7893ccfSSadaf Ebrahimi    if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
26*b7893ccfSSadaf Ebrahimi        set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "-w")
27*b7893ccfSSadaf Ebrahimi    endif()
28*b7893ccfSSadaf Ebrahimi
29*b7893ccfSSadaf Ebrahimi    if(TARGET gtest_main)
30*b7893ccfSSadaf Ebrahimi        # Already enabled as a target (perhaps by a project enclosing this one)
31*b7893ccfSSadaf Ebrahimi        message(STATUS "Vulkan-ValidationLayers/external: " "googletest already configured - using it")
32*b7893ccfSSadaf Ebrahimi    elseif(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/googletest")
33*b7893ccfSSadaf Ebrahimi        # The googletest directory exists, so enable it as a target.
34*b7893ccfSSadaf Ebrahimi        message(STATUS "Vulkan-ValidationLayers/external: " "googletest found - configuring it for tests")
35*b7893ccfSSadaf Ebrahimi        set(BUILD_GTEST ON CACHE BOOL "Builds the googletest subproject")
36*b7893ccfSSadaf Ebrahimi        set(BUILD_GMOCK OFF CACHE BOOL "Builds the googlemock subproject")
37*b7893ccfSSadaf Ebrahimi        set(gtest_force_shared_crt ON CACHE BOOL "Link gtest runtimes dynamically")
38*b7893ccfSSadaf Ebrahimi        set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries")
39*b7893ccfSSadaf Ebrahimi        # EXCLUDE_FROM_ALL keeps the install target from installing GTEST files.
40*b7893ccfSSadaf Ebrahimi        add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/googletest" EXCLUDE_FROM_ALL)
41*b7893ccfSSadaf Ebrahimi    else()
42*b7893ccfSSadaf Ebrahimi        message(SEND_ERROR "Vulkan-ValidationLayers/external: " "Google Test was not found.  "
43*b7893ccfSSadaf Ebrahimi                           "Provide Google Test in external/googletest or set BUILD_TESTS=OFF")
44*b7893ccfSSadaf Ebrahimi    endif()
45*b7893ccfSSadaf Ebrahimiendif()
46