[CMake] Removing compiler options

Domen Vrankar domen.vrankar at gmail.com
Wed Dec 17 02:08:49 EST 2014


This was asked a few years ago and I doubt that things have changed
since then... http://www.cmake.org/pipermail/cmake/2010-May/036924.html
(http://www.cmake.org/cmake/help/v2.8.10/cmake.html#prop_sf%3aCOMPILE_FLAGS).
An alternative would be to use
http://www.cmake.org/cmake/help/v3.0/module/ExternalProject.html

Regards,
Domen

2014-12-17 4:49 GMT+01:00 Robert Dailey <rcdailey.lists at gmail.com>:
> I still really need help with this. It's a blocker at this point for
> me. Help is greatly appreciated; thanks in advance.
>
> On Sun, Nov 9, 2014 at 10:02 PM, Robert Dailey <rcdailey.lists at gmail.com> wrote:
>> When setting up a CLR project through CMake, it becomes important to
>> be able to *remove* compiler options at the project level. For
>> example, the following need to be removed (MSVC12):
>>
>> /RTC1
>> /EHsc
>>
>> There is no "remove_compile_options()" (which would be convenient).
>> Any reason why this doesn't exist?
>>
>> Right now I'm trying to remove these via CMAKE_CXX_FLAGS locally but
>> this doesn't work unless I forcefully change the cache. But this is a
>> permanent operation that affects *all* projects, which I do not want.
>> This is crazy, I'm hoping there is a better way. I'm using CMake 3.1
>> RC1. Can anyone help me figure out how to remove compiler options on a
>> per-project basis?
>>
>> Here is what I'm doing:
>>
>> function( add_clr_library target_name references )
>>     set( source_files ${ARGN} )
>>
>>     set( default_references
>>         System
>>         System.Core
>>         System.Data
>>         System.Drawing
>>         #System.Xml
>>         #WindowsBase
>>     )
>>
>>     if( CMAKE_CXX_FLAGS_DEBUG MATCHES "/RTC1" )
>>         string( REGEX REPLACE "/RTC(su|[1su])" ""
>> CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" )
>>     endif()
>>
>>     if( CMAKE_CXX_FLAGS MATCHES "/EHsc" )
>>         string( REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )
>>     endif()
>>
>>     add_library( ${target_name} SHARED ${source_files} )
>>
>>     list( APPEND references ${default_references} )
>>
>>     set_target_properties( ${target_name} PROPERTIES
>>         VS_DOTNET_REFERENCES "${references}"
>>         VS_DOTNET_TARGET_FRAMEWORK_VERSION "v4.5"
>>         COMPILE_FLAGS "/clr /EHa"
>>         DEBUG_POSTFIX "d"
>>     )
>> endfunction()
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake


More information about the CMake mailing list