astamm / nloptr

nloptr provides an R interface to NLopt, a free/open-source library for nonlinear optimization providing a common interface to a number of different optimization routines which can handle nonlinear constraints and lower and upper bounds for the controls.
https://astamm.github.io/nloptr/
Other
105 stars 35 forks source link

End configuration sooner and louder if cmake missing when needed #103

Closed eddelbuettel closed 2 years ago

eddelbuettel commented 2 years ago

We had some reports where users didn't really realize they were missing cmake. I realized that I can (and maybe "should", hence this PR) test for that and have configure stop with the clear message from your shell script.

On empty R docker container (without cmake or nlopt) we now get:

edd@rob:~/git/nloptr(master)$ docker run --rm -ti -v $PWD:/mnt -w /work r-base bash
root@2b5065467a3a:/work# ./configure 
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ -std=gnu++14 accepts -g... yes
checking how to run the C++ preprocessor... g++ -std=gnu++14 -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ -std=gnu++14 accepts -g... (cached) yes
checking for pkg-config... /usr/bin/pkg-config
checking if pkg-config knows NLopt... no
checking for cmake... no

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

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

 - yum install cmake          (Fedora/CentOS; inside a terminal)
 - apt install cmake          (Debian/Ubuntu; inside a terminal).
 - pacman -S cmake            (Arch Linux; inside a terminal).
 - brew install cmake         (MacOS; inside a terminal with Homebrew)
 - port install cmake         (MacOS; inside a terminal with MacPorts)

Alternatively install CMake from: <https://cmake.org/>

-------------------------------------------------------

configure: error: Could not fine 'cmake'.
root@2b5065467a3a:/work# 

Feel free to discard if you would rather address this differently what it occured to me that this may help.

astamm commented 2 years ago

That is a valid point and I am happy with your solution. Can you just change fine with find please?

eddelbuettel commented 2 years ago

Whoops. Will fix.

eddelbuettel commented 2 years ago

(You may want to toss a sudo in front of text for apt and yum (and possibly pacman and maybe port and brew). System-wide installation will likely not work as a mere user.)