Skip to content

Commit

Permalink
Merge pull request #696 from LLNL/bugfix/white238/guard_gtest
Browse files Browse the repository at this point in the history
Harden two cases where projects do not enable C as a language
  • Loading branch information
white238 authored Sep 4, 2024
2 parents ccdeeb1 + 4cbe363 commit eb0acb3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
3 changes: 3 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ The project release numbers follow [Semantic Versioning](http://semver.org/spec/
- Removed GoogleTest, GoogleMock, and GoogleBenchmarks calling CMake's `GNUInstallDirs`
which was causing non-deterministic install variables depending on your combination of
static/shared libraries and if any of the previously mentioned TPLs were enabled.
- Enable C language support and emit a warning when GoogleTest or GoogleMock are enabled but
not the C language.
- Guard HIP C smoketest against projects that don't enable C as a language in their projects.

## [Version 0.6.2] - Release date 2024-03-15

Expand Down
19 changes: 11 additions & 8 deletions tests/smoke/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,17 @@ if (ENABLE_HIP)
blt_add_test(NAME blt_hip_runtime_smoke
COMMAND blt_hip_runtime_smoke)

blt_add_executable(NAME blt_hip_runtime_c_smoke
SOURCES blt_hip_runtime_c_smoke.c
OUTPUT_DIR ${TEST_OUTPUT_DIRECTORY}
DEPENDS_ON blt::hip_runtime
FOLDER blt/tests )

blt_add_test(NAME blt_hip_runtime_c_smoke
COMMAND blt_hip_runtime_c_smoke)
get_property(_enabled_langs GLOBAL PROPERTY ENABLED_LANGUAGES)
if("C" IN_LIST _enabled_langs)
blt_add_executable(NAME blt_hip_runtime_c_smoke
SOURCES blt_hip_runtime_c_smoke.c
OUTPUT_DIR ${TEST_OUTPUT_DIRECTORY}
DEPENDS_ON blt::hip_runtime
FOLDER blt/tests )

blt_add_test(NAME blt_hip_runtime_c_smoke
COMMAND blt_hip_runtime_c_smoke)
endif()

if(ENABLE_GTEST)
blt_add_executable(NAME blt_hip_gtest_smoke
Expand Down
14 changes: 13 additions & 1 deletion thirdparty_builtin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,19 @@ if(ENABLE_TESTS)

message(STATUS "Google Test Support is ${ENABLE_GTEST}")
message(STATUS "Google Mock Support is ${ENABLE_GMOCK}")


# GoogleMock and GoogleTest both require the C language enabled.
# This can cause problems due to the language being enabled globally
# but variables like CMAKE_C_COMPILE_OBJECT being created directory scoped.
# Enable the C language for them but omit a warning.
if(ENABLE_GTEST OR ENABLE_GMOCK)
get_property(_enabled_langs GLOBAL PROPERTY ENABLED_LANGUAGES)
if(NOT "C" IN_LIST _enabled_langs)
message(WARNING "Enabling the C language due to Google Mock|Test requiring it. To quiet this warning, add C to your project(...) call.")
enable_language(C)
endif()
endif()

#
# Guard of googletest w/ ENABLE_GTEST
# In BLT, ENABLE_GTEST is also required when using ENABLE_GMOCK
Expand Down

0 comments on commit eb0acb3

Please sign in to comment.