[CMake] check_cxx_compiler_flag usage

Damien R damienrg+list at gmail.com
Thu Dec 7 03:24:29 EST 2017


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20171207/8fd155df/attachment.html>


More information about the CMake mailing list