1# ~~~ 2# Copyright (c) 2021 Valve Corporation 3# Copyright (c) 2021 LunarG, Inc. 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16# ~~~ 17 18add_library(testing_framework_util STATIC test_util.cpp) 19target_link_libraries(testing_framework_util PUBLIC loader_common_options Vulkan::Headers) 20 21if(UNIX OR APPLE) 22 target_link_libraries(testing_framework_util PUBLIC ${CMAKE_DL_LIBS}) 23endif() 24 25if(UNIX) 26 target_compile_options(testing_framework_util PUBLIC -fPIC) 27endif() 28# Gives access to all headers in the framework folder, in the framework binary, and in the whole project (mainly for loader/generated) 29target_include_directories(testing_framework_util PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}) 30 31if (UNIX) 32 if (LOADER_ENABLE_ADDRESS_SANITIZER) 33 target_compile_options(testing_framework_util PUBLIC -fsanitize=address) 34 target_link_options(testing_framework_util PUBLIC -fsanitize=address) 35 endif() 36 if (LOADER_ENABLE_THREAD_SANITIZER) 37 target_compile_options(testing_framework_util PUBLIC -fsanitize=thread) 38 target_link_options(testing_framework_util PUBLIC -fsanitize=thread) 39 target_compile_options(gtest PUBLIC -fsanitize=thread) 40 target_link_options(gtest PUBLIC -fsanitize=thread) 41 endif() 42 if (LOADER_ENABLE_UNDEFINED_BEHAVIOR_SANITIZER) 43 target_compile_options(testing_framework_util PUBLIC -fsanitize=undefined) 44 target_link_options(testing_framework_util PUBLIC -fsanitize=undefined) 45 endif() 46endif() 47 48if (MSVC) 49 # silence hidden class member warnings in test framework 50 target_compile_options(testing_framework_util PUBLIC /wd4458) 51 # Make sure exception handling is enabled for the test framework 52 target_compile_options(testing_framework_util PUBLIC /EHsc) 53endif() 54 55function(AddSharedLibrary LIBRARY_NAME) 56 set(singleValueArgs DEF_FILE) 57 set(multiValueArgs SOURCES DEFINITIONS) 58 cmake_parse_arguments(PARSED_ARGS "" "${singleValueArgs}" 59 "${multiValueArgs}" ${ARGN} ) 60 61 add_library(${LIBRARY_NAME} SHARED ${PARSED_ARGS_SOURCES}) 62 target_link_libraries(${LIBRARY_NAME} PUBLIC testing_framework_util) 63 target_compile_definitions(${LIBRARY_NAME} PRIVATE ${PARSED_ARGS_DEFINITIONS} VK_NO_PROTOTYPES) 64 # Windows requires export definitions for these libraries 65 if(WIN32) 66 target_sources(${LIBRARY_NAME} PRIVATE export_definitions/${PARSED_ARGS_DEF_FILE}.def) 67 endif() 68endfunction() 69 70add_subdirectory(data) 71add_subdirectory(shim) 72add_subdirectory(icd) 73add_subdirectory(layer) 74 75#configure the framework_config.h.in file - used to locate all the binaries generated so that it can be used in the tests 76#setup framework_config_temp.h.in in the current binary directory 77configure_file("${CMAKE_CURRENT_SOURCE_DIR}/framework_config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/framework_config_temp.h.in") 78 79# setup framework_config_$<CONFIG> using framework_config_temp.h.in as a source 80file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/framework_config_$<CONFIG>.h" INPUT "${CMAKE_CURRENT_BINARY_DIR}/framework_config_temp.h.in") 81 82# Add a compiler definition for the path to framework_config.h with the correct config 83target_compile_definitions(testing_framework_util PUBLIC FRAMEWORK_CONFIG_HEADER="framework_config_$<CONFIG>.h") 84 85add_library(testing_dependencies STATIC test_environment.cpp test_environment.h) 86target_link_libraries(testing_dependencies 87 PUBLIC gtest Vulkan::Headers testing_framework_util shim-library) 88target_include_directories(testing_dependencies PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) 89if (APPLE_STATIC_LOADER) 90 target_compile_definitions(testing_dependencies PUBLIC "APPLE_STATIC_LOADER=1") 91 target_link_libraries(testing_dependencies PUBLIC vulkan) 92endif() 93