[Cmake] file/project specific compile flags

William A. Hoffman bill.hoffman at kitware.com
Fri Oct 26 09:02:51 EDT 2001


At 10:54 AM 10/26/2001 +0100, Phil Pritchett wrote:
>Bill,
>
>A while ago on the vxl mailing list you mentioned that you were working on
>file-specific compile flags. The problem I have currently is that I have a
>build type for an application where one of the libraries must be compiled
>with /01 (min-size optimization) and the others are compiled with /O2
>Is there any way that I can do this under cmake ? It seems that CMake would
>need to be aware of the which build type is being built in order to do this.

Right now you can not add flags per file, however, you can add flags per 
directory.
You can use the SET command to override a cache value
Put this in the list file for the one that needs O1:
SET(CMAKE_CXX_FLAGS -O1)

>A couple of other things I have found so far :
>
>o adding build types is a pain for MS and has no equivalent under unix,
>under  the old target and vxl make systems you could "make debug".

On unix, I would create a new build directory, and use CXXFLAGS to control 
flags.
vxl-debug  (CXXFLAGS=-g cmake ../vxl)
vxl-release (CXXFLAGS=-O3 cmake ../vxl)



>o CMakeWindowSystemConfig.cmake is always taken from the system CMake
>Templates  directory rather than the one specified by
>MSPROJECT_TEMPLATE_DIRECTORY. is this the correct behaviour

>o even though you can add build types to the various MS templates the search
>and replace used to generated the project files is hardcoded in, so I
>couldn't add  CMAKE_CXX_FLAGS_MYBUILD into the project templates.

The extra template directory is not really used by us, so I am sure there 
are issues with it.


>Cheers,
>Phil




More information about the CMake mailing list