CMake GUI failed to create directory in /opt/local/ I’m trying to build the Eigen library using the CMake GUI. I’ve downloaded the library from the webiste (.tar.bz2), extracted it, and used the extracted path as source location for the CMake GUI, the CMakeLists.txt was already provided with it.

I’m able to build the library in other places, but when I set destination path to:

/opt/local/DESTINATION_PATH


It first asks me if it should create the destination directory as it doesn't exist. When I click yes, it tells me the following and quits:


  FAILED TO CREATE DIRECTORY


I need the library to be built within /opt/local/. Can anyone help me?
You say this:


  I’m able to build the library in other places…


But it’s choking here:


  /opt/local/DESTINATION_PATH


While I have not used CMake, in general Unix/Linux context the problem is the /opt/local/ directory would be owned by root. And if you want to create content in there, you would need to launch CMake via sudo so you can gain super user privileges.

According to this answer on Stack Overflow you can do it like this. First open up the terminal command line and type in this command:

sudo /Applications/CMake.app/Contents/MacOS/CMake


Next it will ask you for your password. Go ahead and type that in. And when CMake launches it will be via sudo so writing to /opt/local/ should not be an issue.