[CMake] To quote (path) variables or not, and everywhere?

Miller Henry MillerHenry at JohnDeere.com
Mon Sep 25 10:58:18 EDT 2017


To add fuel to this, I like to argue that paths should not be quoted if at all possible.  I find that in many cases where a path is quoted those quotes are being done to work around a bad project structure and you can reorganize your project to get rid of the need for quotes.

-----Original Message-----
From: CMake [mailto:cmake-bounces at cmake.org] On Behalf Of Mateusz Loskot
Sent: Monday, September 25, 2017 6:41 AM
To: Oleksii Vilchanskyi <alexvilchansky at yahoo.com>
Cc: cmake at cmake.org
Subject: Re: [CMake] To quote (path) variables or not, and everywhere?

On 25 September 2017 at 12:57, Oleksii Vilchanskyi <alexvilchansky at yahoo.com> wrote:
> As usually with CMake, there are no recommendations/guidelines.

So, cases with the ammo for CMake sceptics and opponents are not empty, yet. Pity.

> However, here's my logic:
>
> 1) if it's a path, always quote it
> 2) if it's not a pat, but inside an if() or any similar core language 
> structure, quote it as well
> 3) don't quote only if you're sure the string can't have spaces - 
> otherwise do quote
> 4) quoting is free and doesn't hurt

That sounds reasonable. Thank you.

Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake


More information about the CMake mailing list