[CMake] check_cxx_compiler_flag usage

Clément Gregoire lectem at gmail.com
Thu Dec 7 06:29:15 EST 2017


Well to be honest, as long as it's done correctly I don't really have any
issues with it.
The issue is that I've seen many Cmakelists.txt changing CMAKE_CXX_FLAGS
directly and forcing it upon the user by adding a target_add_* which most
of the time is not what you want.
Adding a new configuration type is indeed the best solution (though it
forces it on all the targets), it's also what I use for my coverage builds.

Le jeu. 7 déc. 2017 à 10:38, Eric Noulard <eric.noulard at gmail.com> a écrit :

> 2017-12-07 9:35 GMT+01:00 Clément Gregoire <lectem at gmail.com>:
>
>> That's probably an issue with linking because it doesn't know it has to
>> link asan.
>> Either way, settings asan flags is the job of the user, not the
>> cmakelists.txt.
>> Such things should be kept in tool chain or config files IMHO.
>>
>
> I do not agree with you.
>
> Most of the time you will have to handle various type of build for the
> same toolchain: i.e. debug, optimize, profiling etc...
> sanitizing is another case of build type.
> I wouldn't put it in the toolchain since it could work with various
> toolchain and at least with GCC or Clang.
>
> I don't know what you mean by "config file".
>
>
>> You can try running cmake in verbose mode for more information.
>>
>> Le jeu. 7 déc. 2017 à 09:25, Damien R <damienrg+list at gmail.com> a écrit :
>>
>>> Hi,
>>>
>>> I am trying to use CHECK_CXX_COMPILER_FLAG with cmake 3.9 to check if
>>> the compiler supports asan.
>>> The CMakeLists.txt is:
>>> cmake_minimum_required(VERSION 3.9)
>>> include(CheckCXXCompilerFlag)
>>> check_cxx_compiler_flag("-fsanitize=address" COMPILER_SUPPORT_FLAG)
>>>
>>> I always got:
>>> -- Performing Test COMPILER_SUPPORT_FLAG - Failed
>>>
>>> Even if the documentation say that CHECK_CXX_COMPILER_FLAG sets
>>> CMAKE_REQUIRED_DEFINITIONS by the name of the macro I thought that it would
>>> work.
>>> Can you tell me why CHECK_CXX_COMPILER_FLAG use
>>> CMAKE_REQUIRED_DEFINITIONS instead of CMAKE_REQUIRED_FLAGS
>>> and what is the official way for checking this flag?
>>>
>>> Regards,
>>>
>>> Damien R.
>>>
>>> --
>>>
>>> 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
>>
>>
>> --
>>
>> 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
>>
>
>
>
> --
> Eric
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20171207/92092cbc/attachment-0001.html>


More information about the CMake mailing list