[CMake] Resetting CMAKE_Fortran_FLAGS for a specific file

marco restelli mrestelli at gmail.com
Wed Aug 13 06:18:20 EDT 2014


Hi Petr,
   thanks, very informative!

2014-08-13 9:20 GMT+0200, Petr Kmoch <petr.kmoch at gmail.com>:
> Hi Marco.
>
> Sane compilers allow later command-line options to override earlier ones,
> so what you're doing should be fine. Unfortunately, I know some Fortran
> compilers are not sane in this regard.

Here, I would really like to reduce as much as possible the flags
regardless of the chosen compiler, so "undoing" the chosen flags
seems to me cumbersome and compiler dependent, compared to resetting
them altogether. I like the idea of OBJECT libraries better (it also
solves other problems I have, I did not know about it!).

> If you really need to solve this by explicitly modifying the global list
> for a particular file, the only thing I can think of is move those files to
> a separate CMakeList and turn them into an object library:

This almost works, I have a problem specifying liking dependencies for
the OBJECT libraries. With a normal library, I can use

TARGET_LINK_LIBRARIES( my_library ${other_libs_my_library_depends_on} )

but if my_library is OBJECT I see the error

  Object library target "my_library" may not link to anything.

One option would be adding the TARGET_LINK_LIBRARIES to the STATIC
library where the TARGET_OBJECTS are used, but this seems to
contradict the modularity idea of the OBJECT libraries. Is there a
better solution?

Marco


More information about the CMake mailing list