2016-03-17 02:43:31 +00:00
|
|
|
# Copyright (c) 2015-2016 The Khronos Group Inc.
|
|
|
|
#
|
|
|
|
#
|
2016-09-01 19:33:59 +00:00
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
2016-03-17 02:43:31 +00:00
|
|
|
#
|
2016-09-01 19:33:59 +00:00
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
2016-03-17 02:43:31 +00:00
|
|
|
#
|
2016-09-01 19:33:59 +00:00
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
2016-03-17 02:43:31 +00:00
|
|
|
|
2016-04-14 18:05:53 +00:00
|
|
|
if (DEFINED SPIRV-Headers_SOURCE_DIR)
|
|
|
|
# This allows flexible position of the SPIRV-Headers repo.
|
|
|
|
set(SPIRV_HEADER_DIR ${SPIRV-Headers_SOURCE_DIR})
|
|
|
|
else()
|
2017-12-05 15:55:00 +00:00
|
|
|
if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/SPIRV-Headers)
|
|
|
|
set(SPIRV_HEADER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/SPIRV-Headers)
|
|
|
|
else()
|
|
|
|
set(SPIRV_HEADER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/spirv-headers)
|
|
|
|
endif()
|
2016-04-14 18:05:53 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (IS_DIRECTORY ${SPIRV_HEADER_DIR})
|
|
|
|
set(SPIRV_HEADER_INCLUDE_DIR ${SPIRV_HEADER_DIR}/include PARENT_SCOPE)
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR
|
|
|
|
"SPIRV-Headers was not found - please checkout a copy under external/.")
|
|
|
|
endif()
|
|
|
|
|
2017-11-08 05:23:42 +00:00
|
|
|
if (NOT ${SPIRV_SKIP_TESTS})
|
2016-03-17 02:43:31 +00:00
|
|
|
# Find gmock if we can. If it's not already configured, then try finding
|
|
|
|
# it in external/googletest.
|
|
|
|
if (TARGET gmock)
|
|
|
|
message(STATUS "Google Mock already configured")
|
|
|
|
else()
|
|
|
|
set(GMOCK_DIR ${CMAKE_CURRENT_SOURCE_DIR}/googletest/googlemock)
|
|
|
|
if(EXISTS ${GMOCK_DIR})
|
2017-12-11 17:05:04 +00:00
|
|
|
if(MSVC)
|
|
|
|
# Our tests use ::testing::Combine. Work around a compiler
|
|
|
|
# detection problem in googletest, where that template is
|
|
|
|
# accidentally disabled for VS 2017.
|
|
|
|
# See https://github.com/google/googletest/issues/1352
|
|
|
|
add_definitions(-DGTEST_HAS_COMBINE=1)
|
|
|
|
endif()
|
2016-03-17 02:43:31 +00:00
|
|
|
if(WIN32)
|
|
|
|
option(gtest_force_shared_crt
|
|
|
|
"Use shared (DLL) run-time lib even when Google Test is built as static lib."
|
|
|
|
ON)
|
|
|
|
endif()
|
2017-06-07 10:14:31 +00:00
|
|
|
add_subdirectory(${GMOCK_DIR} EXCLUDE_FROM_ALL)
|
2016-03-17 02:43:31 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2017-04-05 21:32:39 +00:00
|
|
|
if (TARGET gmock)
|
|
|
|
set(GTEST_TARGETS
|
|
|
|
gtest
|
|
|
|
gtest_main
|
|
|
|
gmock
|
|
|
|
gmock_main
|
|
|
|
)
|
|
|
|
foreach(target ${GTEST_TARGETS})
|
|
|
|
set_property(TARGET ${target} PROPERTY FOLDER GoogleTest)
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2017-11-08 05:23:42 +00:00
|
|
|
|
2018-10-04 14:00:11 +00:00
|
|
|
# Find Effcee and RE2, for testing.
|
2017-11-08 05:23:42 +00:00
|
|
|
|
2018-10-04 14:00:11 +00:00
|
|
|
# First find RE2, since Effcee depends on it.
|
|
|
|
# If already configured, then use that. Otherwise, prefer to find it under 're2'
|
|
|
|
# in this directory.
|
|
|
|
if (NOT TARGET re2)
|
|
|
|
# If we are configuring RE2, then turn off its testing. It takes a long time and
|
|
|
|
# does not add much value for us. If an enclosing project configured RE2, then it
|
|
|
|
# has already chosen whether to enable RE2 testing.
|
|
|
|
set(RE2_BUILD_TESTING OFF CACHE STRING "Run RE2 Tests")
|
|
|
|
if (NOT RE2_SOURCE_DIR)
|
|
|
|
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/re2)
|
|
|
|
set(RE2_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/re2" CACHE STRING "RE2 source dir" )
|
2017-11-08 05:23:42 +00:00
|
|
|
endif()
|
2018-02-06 16:13:39 +00:00
|
|
|
endif()
|
2018-10-04 14:00:11 +00:00
|
|
|
endif()
|
2018-02-06 16:13:39 +00:00
|
|
|
|
2018-10-04 14:00:11 +00:00
|
|
|
if (NOT TARGET effcee)
|
|
|
|
# Expect to find effcee in this directory.
|
|
|
|
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/effcee)
|
|
|
|
# If we're configuring RE2 (via Effcee), then turn off RE2 testing.
|
|
|
|
if (NOT TARGET re2)
|
|
|
|
set(RE2_BUILD_TESTING OFF)
|
2017-11-08 05:23:42 +00:00
|
|
|
endif()
|
2018-10-04 14:00:11 +00:00
|
|
|
if (MSVC)
|
|
|
|
# SPIRV-Tools uses the shared CRT with MSVC. Tell Effcee to do the same.
|
|
|
|
set(EFFCEE_ENABLE_SHARED_CRT ON)
|
|
|
|
endif()
|
|
|
|
add_subdirectory(effcee)
|
|
|
|
set_property(TARGET effcee PROPERTY FOLDER Effcee)
|
|
|
|
# Turn off warnings for effcee and re2
|
|
|
|
set_property(TARGET effcee APPEND PROPERTY COMPILE_OPTIONS -w)
|
|
|
|
set_property(TARGET re2 APPEND PROPERTY COMPILE_OPTIONS -w)
|
2017-11-08 05:23:42 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2016-03-17 02:43:31 +00:00
|
|
|
endif()
|