I would like to learn how to download and compile external libraries using the cmake external project module.
For example, lets say that I wanted to download the source from the SFML library https://github.com/LaurentGomila/SFML.git
and compile it. I have tried using something like the following. Unfortunately, I can't figure out why it is not compiling after the source gets cloned :(
EXTERNALPROJECT_ADD(sfml
PREFIX ${sfml_PREFIX}
GIT_REPOSITORY https://github.com/LaurentGomila/SFML.git
INSTALL_DIR ${sfml_INSTALL_DIR}
CMAKE_ARGS ${sfml_CMAKE_ARGS})
Perhaps your variables do not contain the values you think they contain... Double check the value of your sfml_* variables. Also double check that the CMake variable GIT_EXECUTABLE has the value you expect after including ExternalProject...
The following CMakeLists.txt file works for me on my Mac using CMake 2.8.5:
It fails during the install for me with a permission denied because I did not run "make" as sudo, and it tries to install into the absolute path "/Library/Frameworks/sndfile.framework"
One other piece of advice, too. I notice you're installing "/Applications/CMake 2.8-5.app/Contents/share/cmake-2.8/Modules/FindSFML.cmake" directly into the CMake installation... That is generally discouraged, as that modification to the CMake installation is likely to disappear if the user uninstalls and re-installs CMake. Or simply upgrades to another CMake. Or uses a 2nd or 3rd CMake that is also installed on the computer.
You should instead create a project config file in your own installation, that CMake can find with it's built-in rules for finding packages at standard locations. Read the fine print of the CMake find_package documentation for the full details on project config files:
http://cmake.org/cmake/help/cmake-2-8-docs.html#command:find_package