I have created the following CMakelists.txt for my project which includes some files which need to be compiled with C and then will be linked with my C++ binary. I'm also using libasan.
cmake_minimum_required(VERSION 3.0)
SET(GCC_COVERAGE_COMPILE_FLAGS "-g3 -fsanitize=address -fno-omit-frame-pointer")
SET(GCC_COVERAGE_LINK_FLAGS "-fsanitize=address -static-libasan")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
project(ABC_PROXY VERSION 1.0.0 LANGUAGES C CXX)
add_executable(abc_proxy
src/file1.c
src/main.cpp
)
target_include_directories(abc_proxy PRIVATE /home/vishal/cpp_file/new /home/vishal/cpp_file/new/framework)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
In the above file I only have one target binary. But now I want to have 2 binaries. One will be compiled with libasan and the other will be compiled without it. How can I use different flag values in the 'CMAKE_EXE_LINKER_FLAGS ' , 'CMAKE_CXX_FLAGS' and 'CMAKE_CXX_FLAGS' for each binary target?