[CMake] Compilation options

Mathieu Malaterre mathieu.malaterre at gmail.com
Tue Jun 17 07:58:18 EDT 2008


What compiler are you using ?

For instance for gcc, the order is defined in gcc.cmake, and it is
actually the correct order for gcc. AFAIK you simply need to reorder
the option in whatever order your compiler want them...

eg.:

IF(CMAKE_COMPILER_IS_GNUCXX)
  SET (CMAKE_SHARED_LIBRARY_CXX_FLAGS "-fPIC")   # -pic
  SET (CMAKE_CXX_FLAGS_INIT "")
  SET (CMAKE_CXX_FLAGS_DEBUG_INIT "-g")
  SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG")
  SET (CMAKE_CXX_FLAGS_RELEASE_INIT "-O3 -DNDEBUG")
  SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O2 -g")
  SET (CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER>
<DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
  SET (CMAKE_CXX_CREATE_ASSEMBLY_SOURCE "<CMAKE_CXX_COMPILER>
<DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
  IF(NOT APPLE)
    SET (CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ")
  ENDIF(NOT APPLE)
ENDIF(CMAKE_COMPILER_IS_GNUCXX)


HTH
-Mathieu

On Thu, Jun 12, 2008 at 1:09 PM, Benjamin Depardon
<benjamin.depardon at ens-lyon.fr> wrote:
> Hello,
>
> I'd like to know why does cmake add its compilation options (such as -o, or
> some variable definitions) before the options contained in
> CMAKE_language_FLAGS?
> Is there a way to bypass this, and tell cmake to add its flags at the end of
> the command line?
> The problem is that I am using a compiler which requires options in a
> certain order, and as cmake adds its own before the ones I defined, it
> brokes the compilation.
>
> Thanks
>
> Ben
>
> ---------------------------
> Benjamin Depardon
>
> Laboratoire de l'Informatique du Parallélisme (LIP) - Projet GRAAL
> Ecole Normale Supérieure de Lyon
> 46, allée d'Italie
> 69364 Lyon Cedex 07 - France
>
> Tel: +33 (0)4 37 28 76 43
>        +33 (0)6 84 08 31 55
>
> http://graal.ens-lyon.fr/~bdepardo
> ---------------------------
>
> «Le réel possède un avantage considérable sur la fiction, c'est d'être
> unique.»
>    Raymond Depardon
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>



-- 
Mathieu


More information about the CMake mailing list