[CMake] Compilation options

Mathieu Malaterre mathieu.malaterre at gmail.com
Fri Jun 20 03:19:48 EDT 2008


Salut Benjamin,

On Fri, Jun 20, 2008 at 8:03 AM, Benjamin Depardon
<Benjamin.Depardon at ens-lyon.fr> wrote:
> In fact I'm using the TAU compiler, which is a script that modify the code
> before compiling it with a standard compiler (gcc).
> My problem is that CMake adds a-D<name of the file>_EXPORTS flag before any
> of my flags when it calls the compiler (script).

ah the famous target_EXPORTS flags

> So I think that even changing these lines won't work.
> SET (CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> <FLAGS> -E
> <SOURCE> > <PREPROCESSED_SOURCE>")
>  SET (CMAKE_C_CREATE_ASSEMBLY_SOURCE "<CMAKE_C_COMPILER> <FLAGS> -S <SOURCE>
> -o <ASSEMBLY_SOURCE>")
>
> My question is why does it adds such a flag, and can we choose its position
> inside the <FLAGS> list?

You are right, this flag AFAIK cannot be changed from this file. This
is not a compiler flag but rather an internal behavior on how to
handle shared libs in cmake... but I'll leave the full answer to a
cmake developers.

Just for info this flag is used so that you can define something like
that in your code:

#ifdef target_EXPORTS
  #define MY_EXPORT __declspec( dllexport )
#else
  #define MY_EXPORT __declspec( dllimport )
#endif

this is the only way IMHO to build and link against a shared lib with
msvc compilers (without .def files).

HTH
-- 
Mathieu


More information about the CMake mailing list