[CMake] set_target_properties not setting COMPILE_DEFINITIONS?

David Doria daviddoria at gmail.com
Tue Mar 29 10:14:27 EDT 2011


> Most likely coming from here:
> /home/doriad/src/CMake/Modules/UsewxWidgets.cmake(72): SET(CMAKE_CXX_FLAGS
> ${CMAKE_CXX_FLAGS} ${wxWidgets_CXX_FLAGS} )

I added:
message("CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")

and the output is:

CMAKE_CXX_FLAGS:  -pthread  -ftemplate-depth-50 -Wall -Wno-deprecated

> Hmm, there is also this:
>
> /home/doriad/src/CMake/Modules/UsewxWidgets.cmake(60):
> SET_PROPERTY(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
> ${wxWidgets_DEFINITIONS} )
>
>
> I wonder if the directory properties are causing the trouble some how.
>
> If you add a message to print out CMAKE_CXX_FLAGS you should see that stuff.
>  That should not affect the definitions...  But, the directory property
> might be the problem.  You could try that in the small example.

I added the SET_PROPERTY line to the small example:

list(APPEND myvariable "UNIX")
list(APPEND myvariable "DAVID")
message("myvariable: ${myvariable}")
message("CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
SET_PROPERTY(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
${wxWidgets_DEFINITIONS} )
set_target_properties(CompilerFlags PROPERTIES COMPILE_DEFINITIONS
${myvariable})

and it still works correctly (the flags are passed to the compiler in
the make VERBOSE=1 output).

I then added

find_package(wxWidgets COMPONENTS core base REQUIRED)
include( ${wxWidgets_USE_FILE} )

so that ${wxWidgets_DEFINITIONS} was actually defined and the small
example still worked correctly (make VERBOSE=1 shows:

/usr/lib/ccache/c++   -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES
-D__WXGTK__ -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -DUNIX
-DDAVID -pthread -g -isystem
/usr/lib/wx/include/gtk2-unicode-release-2.8 -isystem
/usr/include/wx-2.8    -o
CMakeFiles/CompilerFlags.dir/CompilerFlags.cxx.o -c
/media/portable/Examples/CMake/CompilerFlags/CompilerFlags.cxx

where it previously showed:

/usr/lib/ccache/c++   -DUNIX -DDAVID -g   -o
CMakeFiles/CompilerFlags.dir/CompilerFlags.cxx.o -c
/media/portable/Examples/CMake/CompilerFlags/CompilerFlags.cxx

Any more suggestions?


More information about the CMake mailing list