[CMake] COMPILE_FLAGS on per target and per configuration basis

Timenkov Yuri ytimenkov at parallels.com
Mon Mar 24 14:29:52 EDT 2008


On Monday 24 March 2008 21:20:45 Ilya Shvetsov wrote:
> On Mon, 24 Mar 2008 20:02:27 +0200, Timenkov Yuri
>
> <ytimenkov at parallels.com> wrote:
> >> May be exist some way do the same with COMPILE_FLAGS ?
> >
> > I do it following way:
> > set_source_files_properties(
> > 	${MyTarget_SRCS}
> > 	PROPERTIES COMPILE_FLAGS "/J /Zc:wchar_t"
> > 	)
>
> Problem still exist. I need per config type. Because of Visual Studio
> Generator I can't write some thing like this:
I think you can use same way of configuration-specific flags as for linker 
(that is CMAKE_CXX_FLAGS_DEBUG, CMAKE_CXX_FLAGS_MINSIZEREL, 
CMAKE_CXX_FLAGS_RELEASE)

But this way you can set them on per-source basis.

CMake is great tool, which allows you customize build in may ways (It seems so 
at least :) ).
In my project, I had to use specific flags only for some sources but in all 
configurations.

Look at advanced variables provided by CMakeSetup.exe or ccmake. It appears 
sometimes useful for me to turn off optimization in RelWithDebInfo build type 
(I need release version msvcrt dlls), And in CMakeSetup I can set it with one 
simple change in hundred of projects.

I suppose these flags should help you, and affect 
(project+configuration)-specific compiler options in Visual Studio.

>
> if (CMAKE_BUILD_TYPE STREQUAL "Final")
> ...
> endif
>
> Because of two targets in on CMakeLists.txt I can't use
> CMAKE_CXX_COMPILE_FLAGS.


More information about the CMake mailing list