[CMake] Different CMAKE_CXX_FLAGS for different executables

David Doria daviddoria at gmail.com
Thu Mar 24 18:39:47 EDT 2011


On Thu, Mar 24, 2011 at 11:31 AM, Yuri Timenkov <yuri at timenkov.ru> wrote:
> Use COMPILE_FLAGS target property. Like this:
>
> set_target_properties(Exec2 PROPERTIES COMPILE_FLAGS "/flag1 /flag2")
>
> You can see full list of properties in CMake documentation. Note that
> compiler flags may be also set for particular source file with
> set_source_files_properties command.

Hi Yuri,

I tried a CMakeLists.txt file like this:

cmake_minimum_required(VERSION 2.6)
PROJECT(SetTargetProperties)
ADD_EXECUTABLE(SetTargetProperties SetTargetProperties.cxx)
set_target_properties(SetTargetProperties PROPERTIES COMPILE_FLAGS "-DUNIX")

Then I ran:

make VERBOSE=1

and I don't see anything in the output that indicates that this flag
was passed, but I also don't see the call to g++ at all. How would I
check that this worked correctly?

Thanks for your help so far,

David


More information about the CMake mailing list