For now, the repository of my application contains the Visual Studio 11 project files, my source and header files, library headers and their compiled *.lib files and some assets.
But it is a big effort to set up the project on every new platform to test compatibility or continue development. Each time I have to create a new project for the current IDE, and more important, download all the used third party libraries and compile the *.lib files for the current compiler.
Is there a way to automatedly fetch required libraries and compile them to *.lib files on all platforms? Moreover, it would be pleasant to cover project settings so that it is easier to set up projects for new compilers or IDEs.
I believe, CMake (http://www.cmake.org/) is the best C++ has now. Like C++ itself, CMake is neither pretty nor simple to use, but, again, like C++, it's very powerful and versatile.
It's currently used by a great number of projects, which need custom and/or complex configuration and building.
Here's some of it's features, you may find useful:
find_package
macro that helps finding installed libraries to make use of it in the project. E.g. if you have the boost libraries installed, you can use something like the following code, which I believe is rather self-descriptive find_package( Boost COMPONENTS thread system)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
endif(Boost_FOUND)
include(ExternalProject)
ExternalProject_Add(
ZLIB
URL http://zlib.net/zlib-1.2.8.tar.gz
)
It will fetch the tarball from the given url, build zlib, and install it. After that you can use find_package again. curl
or git clone
to fetch the sources, and call building and installing commands manually.Once again, it's not an out-of-the-box or just-works solution, but it gets the job done, which is acknowledged by a quite large user base. To paraphrase the known quote, 'CMake is the worst build tool, but others are even worse'