Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve gtest discovery #169

Merged
merged 2 commits into from
Jan 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,32 @@ def static isMusl() {

ext.hasGtest = false

// This is hardcoded - we could have some discovery mechanism here but it would mean forking to shell
if (os().isMacOsX() && file('/opt/homebrew/opt/googletest').exists()) {
ext.hasGtest = true
} else if (os().isLinux() && file('/usr/include/gtest').exists()) {
ext.hasGtest = true
// Define potential GTest locations for MacOS and Linux
def gtestLocations = [
macos: ['/opt/homebrew/opt/googletest', '/usr/local/opt/googletest'],
linux: ['/usr/include/gtest', '/usr/local/include/gtest']
]

// Function to check if any of the specified paths exist
def checkGtestPaths(paths) {
for (path in paths) {
if (file(path).exists()) {
return true
}
}
return false
}

// Determine OS and check for GTest
if (os().isMacOsX()) {
ext.hasGtest = checkGtestPaths(gtestLocations.macos)
} else if (os().isLinux()) {
ext.hasGtest = checkGtestPaths(gtestLocations.linux)
}

// Log a message for debugging
if (!ext.hasGtest) {
println "GTest not found. Please install GTest or configure paths."
}

ext {
Expand Down
Loading