[CMake] Build flags when using Qt plugins (was: Where is QT_USE_IMPORTED_TARGETS not safe to use?)

Stephen Kelly steveire at gmail.com
Wed Jun 22 18:38:24 EDT 2011


Stephen Kelly wrote:

>> As a workaround, you can enforce a value for CMAKE_BUILD_TYPE if on
>> Windows
>> and CMAKE_CONFIGURATION_TYPES is empty.  If you enforce that, then you
>> don't need to have the add_definition(-DQT_NO_DEBUG).
>>
> 
> Thanks for the pointer. I'll try setting that in the cache before calling
> project() as described here:
> 
> http://www.cmake.org/pipermail/cmake/2008-September/023808.html
> 

It didn't really work as described. I had to set the CMAKE_BUILD_TYPE after 
the call to project() or else MINGW seemed to not be defined, and I had to 
use if (NOT CMAKE_BUILD_TYPE) instead of if (NOT DEFINED CMAKE_BUILD_TYPE).

I don't know if either of these things are themselves bugs or expected 
behaviour.

if (MINGW)
  if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build,
  options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release
  RelWithDebInfo MinSizeRel Coverage.")
  endif()
endif()

I'm happy to have this working now though :). I confirmed that changing it 
in cmake-gui works too.

Thanks,

Steve.




More information about the CMake mailing list