Can't deploy R markdown HTML with embedded shiny apps and packages that require cmake

I have a markdown doc that includes several embedded inline shiny apps. It runs fine on my local machine, but I can't deploy to shinyapps.io. The problem seems to be related to the nloptr package, which is a dependency of piecewiseSEM. I don't really know what the root cause is, but it seems that nloptr requires the cmake utility, which is not found on the shinyapps server.

reprex (apologies for the formatting):

---
title: "shiny-reprex"
author: "Anson Call"
date: "2022/02/08"
output:
  html_document:
    toc: yes
    toc_depth: 6
runtime: shiny
---
knitr::opts_chunk$set(echo = TRUE)
library(piecewiseSEM)
```{r cars}
  shinyApp(
    ui = fluidPage(
      numericInput("n", "n", 1),
      plotOutput("plot")
    ),
    server = function(input, output, session) {
      output$plot <- renderPlot( plot(head(cars, input$n)) )
    }
  )

/```

I clipped this text from the console during the attempted deployment, which seems relevant:

...
using NLopt via local cmake build on x86_64 

------------------ CMAKE NOT FOUND --------------------

CMake was not found on the PATH. Please install CMake:
...

and finally the error message, after the deployment fails:

/usr/bin/ld: cannot find -lnlopt
collect2: error: ld returned 1 exit status
make: *** [/opt/R/4.1.2/lib/R/share/make/shlib.mk:10: nloptr.so] Error 1
ERROR: compilation failed for package ‘nloptr’
* removing ‘/opt/R/4.1.2/lib/R/library/nloptr’
################################# End Task Log ################################# 
Error: Unhandled Exception: Child Task 1097159045 failed: Error building image: Build exited with non-zero status: 1
Execution halted

any advice?

FYI the reprex might need some light editing. Getting markdown code to show as preformatted text in a markdown editor is tricky.

It must be related to cmake. I read this thread and thought my issue might be similar. If I add library(symengine) to the setup chunk, it deploys just fine, I think because symengine installs cmake, and that solves the missing dependency problem for nloptr. But what is the proper way to fix this issue?