[CMake] Remove default compiler options

Antoine Tollenaere atollena at gmail.com
Fri Sep 1 03:45:54 EDT 2006


Hi,

I'm trying to get rid of the default CMake compiler options when
generating a VS2003 project. I'm linking to some binary components
that I can not recompile and it looks like when executing my project I
get some runtime error due to calling conventions incompatibilities.
I tried it several ways, including saving  CMake_CXX_FLAGS and all the
build type variants, unsetting them, and restore after ADD_EXECUTABLE,
but the result is not was I'm looking for:

  SET(CMAKE_CXX_FLAGS_SAVE ${CMAKE_CXX_FLAGS})
  SET(CMAKE_CXX_FLAGS_RELEASE_SAVE ${CMAKE_CXX_FLAGS_RELEASE})
  SET(CMAKE_CXX_FLAGS_DEBUG_SAVE ${CMAKE_CXX_FLAGS_DEBUG})
  SET(CMAKE_SHARED_LINKER_FLAGS_SAVE ${CMAKE_SHARED_LINKER_FLAGS})
  SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE_SAVE
${CMAKE_SHARED_LINKER_FLAGS_RELEASE})
  SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG_SAVE ${CMAKE_SHARED_LINKER_FLAGS_DEBUG})

  SET(CMAKE_CXX_FLAGS "")
  SET(CMAKE_CXX_FLAGS_RELEASE "")
  SET(CMAKE_CXX_FLAGS_DEBUG "")
  SET(CMAKE_SHARED_LINKER_FLAGS "")
  SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "")
  SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "")

  ADD_EXECUTABLE(something
    aFile.cpp)

  SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_SAVE})
  SET(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE_SAVE})
  SET(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG_SAVE})
  SET(CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS_SAVE})
  SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE
${CMAKE_SHARED_LINKER_FLAGS_RELEASE_SAVE})
  SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG ${CMAKE_SHARED_LINKER_FLAGS_DEBUG_SAVE})

When built, target "something" still have some options like  "/GS /GR".
Is there a clean way to remove all the default options and to
customize them properly.
Regards,


-- 
Antoine Tollenaere

Jabber ID : atollena at fritalk.com
tel : +33 6 86 75 99 35


More information about the CMake mailing list