-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Windows] cmake: fix cmake/googletest.cmake on Windows (#2350)
* cmake: fix cmake/googletest.cmake on Windows * incorporate review feedback --------- Co-authored-by: Artur Wojcik <artur.wojcik@amd.com>
- Loading branch information
Showing
3 changed files
with
86 additions
and
51 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
################################################################################ | ||
# | ||
# MIT License | ||
# | ||
# Copyright (c) 2023 Advanced Micro Devices, Inc. | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
# | ||
################################################################################ | ||
|
||
include(FetchContent) | ||
|
||
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) | ||
|
||
set(GOOGLETEST_DIR "" CACHE STRING "Location of local GoogleTest repo to build against") | ||
|
||
if(GOOGLETEST_DIR) | ||
set(FETCHCONTENT_SOURCE_DIR_GOOGLETEST ${GOOGLETEST_DIR} CACHE STRING "GoogleTest source directory override") | ||
endif() | ||
|
||
set(BUILD_GMOCK OFF CACHE INTERNAL "") | ||
|
||
FetchContent_Declare( | ||
googletest | ||
GIT_REPOSITORY https://github.com/google/googletest.git | ||
GIT_TAG f8d7d77c06936315286eb55f8de22cd23c188571 | ||
) | ||
|
||
if(WIN32) | ||
set(gtest_force_shared_crt ON CACHE INTERNAL "") | ||
endif() | ||
|
||
# Store the current value of BUILD_SHARED_LIBS | ||
set(__build_shared_libs ${BUILD_SHARED_LIBS}) | ||
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "") | ||
|
||
FetchContent_MakeAvailable(googletest) | ||
|
||
# Restore the old value of BUILD_SHARED_LIBS | ||
set(BUILD_SHARED_LIBS ${__build_shared_libs} CACHE BOOL "Type of libraries to build" FORCE) | ||
|
||
set(GTEST_CMAKE_CXX_FLAGS | ||
-Wno-undef | ||
-Wno-reserved-identifier | ||
-Wno-global-constructors | ||
-Wno-missing-noreturn | ||
-Wno-disabled-macro-expansion | ||
-Wno-used-but-marked-unused | ||
-Wno-switch-enum | ||
-Wno-zero-as-null-pointer-constant | ||
-Wno-unused-member-function | ||
-Wno-comma | ||
-Wno-old-style-cast | ||
-Wno-deprecated | ||
-Wno-unsafe-buffer-usage | ||
-Wno-float-equal | ||
-Wno-ignored-attributes | ||
-Wno-incompatible-pointer-types | ||
-Wno-enum-constexpr-conversion | ||
-Wno-deprecated-builtins) | ||
|
||
target_compile_options(gtest PRIVATE ${GTEST_CMAKE_CXX_FLAGS}) | ||
target_compile_options(gtest_main PRIVATE ${GTEST_CMAKE_CXX_FLAGS}) | ||
|
||
include(GoogleTest) | ||
unset(GTEST_CMAKE_CXX_FLAGS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters