Skip to content

Commit

Permalink
Only fetch gtest when building tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert108 committed Mar 26, 2024
1 parent 7c9b07a commit fd25778
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ execute_process(
)
FetchContent_Declare(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.11.0
GIT_TAG main
)
FetchContent_MakeAvailable(googletest)

Expand Down Expand Up @@ -70,7 +70,20 @@ install(TARGETS ${ISO22133_TARGET}
# Tests

# Only build tests if we are on x86_64 and not cross compiling
if ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64" AND ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "${CMAKE_HOST_SYSTEM_PROCESSOR}"))
if (BUILD_TESTING AND "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64" AND ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "${CMAKE_HOST_SYSTEM_PROCESSOR}"))
# Dependencies
include(FetchContent)
execute_process(
COMMAND ping www.github.com -c 1 -q
ERROR_QUIET
RESULT_VARIABLE NO_CONNECTION
)
FetchContent_Declare(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.11.0
)
FetchContent_MakeAvailable(googletest)

enable_testing()
file(GLOB TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/tests/*.cpp)
add_executable(${ISO22133_TARGET}_test
Expand Down

0 comments on commit fd25778

Please sign in to comment.