I would like to detect whether the CMakeLists.txt file is run with sudo priveleges, so that an application for example on macOS can be installed to the /Application directory while if it is not, it installed into CMAKE_INSTALL_PREFIX/bin.
Can this be done somehow?
1 Like
A better approach would be to always install to ${CMAKE_INSTALL_PREFIX}/bin
, configure with -DCMAKE_INSTALL_PREFIX=/Applications/MyApp
, and then install with sudo cmake --install .
1 Like
Or even better, use CPack’s productbuild or DragNDrop generator.
2 Likes