Monday, October 8, 2012

Additional CMake Corrections

Back at the end of September when Mint 12 (Ubuntu 11.10) with GCC 4.4 (needed for CUDA development) was still being used, a change to the CMake file to allow (with a warning) GCC versions less than 4.5, which do not support linking static libraries.  This option was used to create an executable that did not require dynamic libraries (so the binaries posted on SourceForge would run without having to install any other software). 

This change was considered temporary and the warnings produced with older GCC versions could be ignored and any executables produced couldn't be posted.  To eliminate this compiler warning, an if statement was added around the statement that added the static library link options in the CMake file, so that this option is used for GCC versions 4.5 and later.

The problem with in source directory builds was due to the local string.h header file name conflicting with the standard header file of the same name, which was included in the local string.h header file - the local header file was being included instead of the standard header file.

There is a statement in the CMake file that adds the project's binary directory to the include directories searched so that the auto-generated include files can be found.  So, with an in source directory build, the local string.h file was being found even with angle brackets on the include statement since the project directory was now being searched and is apparently being search before the standard directories.

With an in source directory build, if the project directory is not added to the include directories, the correct header file is found.  Since it is not necessary to add the project directory if building in the source directory (the auto-generated header files will be in the same directory as the source files including them), so to correct this problem, a check was added to the CMake file that if the project binary (build) directory is the same as the project source directory, then it is not added to the include directories.

The old make file was also removed since it now being generated by CMake and there are problems when doing in source directory builds with it present since CMake modifies the make file that is under source control (git then indicates that is was modified).  These two commits are now up on github.