tahonermann / text_view

A C++ concepts and range based character encoding and code point enumeration library
MIT License
122 stars 14 forks source link

Add basic CMake configuration #22

Closed tcbrindle closed 7 years ago

tcbrindle commented 7 years ago

CMake is more-or-less the de-facto standard build system for C++ today. This PR adds a very basic CMake configuration which is sufficient to build the tests and examples, and to use CLion to hack on Text_view.

The configure step requires the compiler to be set to GCC 6.2 (via the CMAKE_CXX_COMPILER switch), and the path to the STL2 headers to be supplied via the CMCSTL2_INCLUDE_DIR variable if these are not present in one of the default search paths (i.e. /usr/include or /usr/local/include). For example, on my system, I use the following build commands:

$ mkdir build
$ cd build
$ cmake .. -DCMAKE_CXX_COMPILER=g++-6 -DCMCSTL2_INCLUDE_DIR=/Users/tristan/Coding/cmcstl2/include
$ cmake --build .

The second commit also adds instructions to README.md.

tahonermann commented 7 years ago

Thank you, Tristan! Adding a cmake based build system was issue #2, so I was very grateful to see this!

My experience with cmake is very limited, but I agree that it is the current industry favorite. I decided it was time for me to get more familiar, so I doubled down on what you contributed, added support for testing and installation, and removed the previous 'make' based build system. I spent a fair amount of time researching typical cmake usage and tried to follow typical cmake usage patterns. I hope what I came up with reflects typical usage. Any feedback you might have on it would be much appreciated! See commit d0f03e5c9ca48716fdff9244f4649410966eb1aa for the changes.

I haven't used CLion, so please let me know if the changes I made don't integrate well with it! Please note that I changed the names of some variables to match prior names (e.g., CMCSTL2_INSTALL_PATH vs CMCSTL2_INCLUDE_DIR).

Finally, I added copyright notices to the files you added and added both of us as authors. If you have any concerns, please let me know!

tcbrindle commented 7 years ago

Hi Tom,

This is great! My initial commit was very much a skeleton implementation just to get it working, but it's great to have it done "properly" with a FindCMCSTL2.cmake module.

I'm pleased to report that the new configuration still works perfectly with CLion.

There are a couple of minor comments regarding the commit (I'll use Github's facility to comment inline to do this), but I'm far from a CMake expert myself so feel free to ignore me :-)

Thanks again,

Tristan