Skip to content

Commit

Permalink
Merge pull request #46 from RI-SE/fetch_gtest_when_building_tests
Browse files Browse the repository at this point in the history
Only fetch gtest when building tests
  • Loading branch information
Robert108 authored Mar 28, 2024
2 parents 7c9b07a + e9b7f4b commit 27d7aa4
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,6 @@ set(CMAKE_C_STANDARD_REQUIRED ON)

project(ISO22133 LANGUAGES C CXX)

# 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)


# Swig flags
set(WITH_SWIG OFF CACHE BOOL "Enable swigging")
set(SWIG_WITH_JAVA OFF CACHE BOOL "Swig to target-language java")
Expand Down Expand Up @@ -70,7 +56,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 Expand Up @@ -147,4 +146,4 @@ if (WITH_SWIG)
else()
message(WARNING "SWIG not found")
endif()
endif()
endif()

0 comments on commit 27d7aa4

Please sign in to comment.