CGAL is an amazing computational geometry library that can make your programming life so much simpler and faster. Once you overcome the weird looking coding style becomes a powerful tool.
Here I’ll describe a few modifications that I make on the cgal generated CMakeList.txt that make my life a bit easier and make the files more portable.
In short, the steps are
1) For each project create a new folder and create a default CMakeList.txt file by running cgal_create_cmake_script
1 2 3 |
mkdir test_intersections cd test_intersections cgal_create_cmake_script |
This is going to create a default CMakeList.txt file.
If the cgal installation is not on the search path then the cgal_create_cmake_script can be found under path/to/cgal-releases-CGAL-x.xx.x/Scripts/scripts/
To make the script easier to transfer between my CGAL projects I’m doing the following changes:
First I remove the default project name which is taken by the folder name.
Then I add a target name for the project and a target source.
Remove one statement create_single_source_cgal_program(…)
Finally, at the end of the file, I set the project and the executable.
To run cmake you need to create a file with the name ${TARGET}.cpp, in my case test1.cpp. Even an empty file its ok
Then run cmake (don’t forget the space dot)
1 |
cmake . |
If you have to provide the cgal path then add the following option
1 |
-DCGAL_DIR:PATH=path/to/cgal-releases-CGAL-x.xx.x/build/release |
If the configuration is successful you can run make after you have written some code into the file ${TARGET}.cpp
1 |
make |
Those modifications allow to copy the same CMakeList.txt files to other projects and build them with a single modification just the very first line. In addition with a few other modifications that will be subject to another post you can add other libraries like deal.ii and OpenSceneGraph