[CMake] Advice on converting legacy project to modern CMake
Rolf Eike Beer
eike at sf-mail.de
Mon Aug 7 07:44:30 EDT 2017
Am 2017-08-07 11:35, schrieb Björn Blissing:
> Hi,
>
> I have some legacy projects which I intend to update to modern CMake.
> The documentation is good but do not really cover "best practices". So
> I have some questions which I hope some of you could help to answer:
>
> 1. Which version if CMake should I target? I.e. Which version should I
> require in my cmake_minimum_required() statement?
If you want to have support for compile feature (i.e. automatically
selecting C++11 if needed), then you should use at least 3.1. I
personally don't see a reason to start lower anyway, if someone wants to
build your new software, getting a new CMake shouldn't a problem anyway.
> 3. Some of my legacy projects have all source in the same directory,
> i.e. both source and header files are in the same directory. Others
> have both private and public headers in the same directory. How do I
> handle this with target_include_directories()? Preferably I would like
> to avoid reorganizing the file structure.
If things are in the same directory you don't need
target_include_directories(), as the header files will be found anyway
if you use "" (probably also <>). If they are in a different directory
it doesn't matter if the private and public things are mixed, you need
to add that directory anyway.
Greetings,
Eike
--
More information about the CMake
mailing list