Skip to content

Commit 7539be2

Browse files
Fix ARM relocation trucation build errors (#1008)
* Initial fix for ARM relocation trucation build errors * Move PIC flags into GetGTest.cmake
1 parent 09505b5 commit 7539be2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cmake/GetGTest.cmake

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,21 @@ function(find_and_configure_gtest VERSION)
3636
return()
3737
endif()
3838

39+
# Set GoogleTest-specific options
40+
set(GTEST_OPTIONS "INSTALL_GTEST ON")
41+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
42+
# Force PIC for GoogleTest on ARM64 to avoid relocation issues
43+
list(APPEND GTEST_OPTIONS "CMAKE_POSITION_INDEPENDENT_CODE ON")
44+
message(STATUS "Enabling PIC for GoogleTest on ARM64")
45+
endif()
46+
3947
# Find or install GoogleTest
4048
CPMFindPackage(NAME GTest
4149
VERSION ${VERSION}
4250
GIT_REPOSITORY https://github.com/google/googletest.git
4351
GIT_TAG v${VERSION}
4452
GIT_SHALLOW TRUE
45-
OPTIONS "INSTALL_GTEST ON"
53+
OPTIONS ${GTEST_OPTIONS}
4654
# googletest >= 1.10.0 provides a cmake config file -- use it if it exists
4755
FIND_PACKAGE_ARGUMENTS "CONFIG")
4856
# Add GTest aliases if they don't already exist.

0 commit comments

Comments
 (0)