Sunday, October 7, 2012

Building The Latest With Command Line CMake

To use CMake from the command line on Windows, the directory containing cmake.exe must be added to the path in MSYS just like for the git programs.  The directory /c/Program Files/Cmake 2.8/bin (Windows XP) or /c/Program Files (x86)/Cmake 2.8/bin (Windows 7) needs to be added.  One thing I forgot to mention in the October 5, 2012 post was that in order for the "/c" part to work in MSYS, the /etc/fstab (C:\MinGW\msys\1.0\etc\fstab) file system table file needs to be modified by adding a new line containing "C:\  /c" to give access to the entire C: drive.

To start, first create the build directory.  For this procedure, create ibcp-build in the same directory as the ibcp source directory and change to it.  On Windows, just like in the CMake GUI, the generator needs to be selected from the command line.  This is done with the ‑G option.  So, use this command to generate the make file:
cmake -G "MSYS Makefiles" ../ibcp 
On Linux, the default generator will be used, so use the cmake ../ibcp command.  To build, use the make command.  By the way, to see the complete compile lines that make is using, use the make VERBOSE=1 command to build (which can be helpful in debugging compile problems like header files that can't be found).

Now some additional build issues need to be resolved, including correcting the issues with parser test #3 on the different platforms, finding the problem with in-source directory builds, and correcting regression testing so that it can be run from the build directory without have to copy the executable to the source directory.

So far, Release 0.1.16 development has been mostly about the build system, but a couple of other minor changes were made, namely, parentheses are no longer stored with identifiers and support for negative constants was added to the parser (instead of treating the minus character as a unary operator).  Therefore, before continuing with development (and a change is coming, stay tuned), a release will be made with the new CMake build system once the remaining issues are resolved.

Building The Latest With CMake-GUI

Instructions for building with CMake were previously given on June 23, 2011 for Windows and June 21, 2011 for Linux, but will be briefly given here again using the CMake GUI for both.

On Windows, the CMake program needs to be installed.  To keep up to date, the current version (2.8.9) was downloaded from Kitware and installed.  There is only a 32-bit version, but this works fine on Windows 7 64-bit.  The defaults of the installer were used.  This version is close to the packages (2.8.7) mentioned on October 3, 2012 installed on Mint 13 (Ubuntu 12.04).

Start the CMake GUI, on Windows: Start, All Programs, CMake 2.8, CMake (cmake-gui), and on Linux: CMake from the launcher menu under Applications/Development or the cmake-gui command from a terminal in any directory).  Once started, enter or browse to the ibcp directory where the source code is (on Windows, this will be C:/MinGW/msys/1.0/home/username/ibcp, and on Linux where it was cloned to, probably /home/username/ibcp).  Then select the directory to build the binaries in (recommend using C:/MinGW/msys/1.0/home/username/ibcp-build or /home/username/ibcp-build).  Click the Configure button, which brings up a dialog for which generator to use.

On Windows, the generator needs to be changed to MSYS Makefiles, and on Linux, the default Unix Makefiles is used.  Click the Finish button to configure.  The CmakeLists.txt file will be processed and the output will be written to the lower pane.  Click the Generate button to create the make file.  That's it, the program can now be built.  From the command line, change to the ibcp-build directory and use the make command.

To test, copy the executable (ibcp.exe on Windows or ibcp on Linux) to the ibcp directory (on Linux, copy it as ibcp.exe).  From the ibcp directory, the regtest script is used to run the tests.  Currently, all tests succeed on Windows XP.  On Windows 7, one test in parser test #3 fails due to how small a floating point number can be (see here).  On Linux, several (5) tests in parser test #3 don't compare because exponents are output with only 2 digits instead of 3 on Windows.  Next up, using CMake from the command line...