[CMake] Set different compilation flags for specific file
Rob Mathews
Rob.Mathews at varolii.com
Tue Jun 12 14:15:19 EDT 2007
No that doesn't work.
Well ... you could start out by setting CMAKE_CXX_FLAGS_RELEASE to ""
and then using the SET_SOURCE_FILES_PROPERTIES to add the flags you need
to every file .. the file that
SET(CMAKE_CXX_FLAGS_RELEASE_SAVED ${CMAKE_CXX_FLAGS_RELEASE} )
SET(CMAKE_CXX_FLAGS_RELEASE "" )
then for more of the files do this:
SET_SOURCE_FILES_PROPERTIES COMPILE_FLAGS ${CMAKE_CXX_FLAGS_RELEASE})
except for the one file where you want the special flags:
SET_SOURCE_FILES_PROPERTIES COMPILE_FLAGS "special set of flags")
and then restore CMAKE_CXX_FLAGS_RELEASE for the rest of the system
build:
SET(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE_SAVED} )
-----Original Message-----
From: James Bigler [mailto:bigler at cs.utah.edu]
Sent: Tuesday, June 12, 2007 2:09 PM
To: Rob Mathews
Cc: cmake at cmake.org
Subject: Re: [CMake] Set different compilation flags for specific file
So I can't set this for a single source file, but rather a library?
Can I add additional sources to the library after I added the library:
ADD_LIBRARY(mylib ${other_sources})
SET(CMAKE_CXX_FLAGS_RELEASE_SAVED ${CMAKE_CXX_FLAGS_RELEASE} )
SET(CMAKE_CXX_FLAGS_RELEASE "/MT /Ox /Ob1 /DNDEBUG" )
ADD_LIBRARY(mylib ${special_file})
SET(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE_SAVED} )
This didn't seem to work.
James
Rob Mathews wrote:
> Put it in that one file like this:
>
> SET(CMAKE_CXX_FLAGS_RELEASE_SAVED ${CMAKE_CXX_FLAGS_RELEASE} )
> SET(CMAKE_CXX_FLAGS_RELEASE "/MT /Ox /Ob1 /DNDEBUG" )
> .. add the library or target
> SET(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE_SAVED} )
>
> -----Original Message-----
> From: James Bigler [mailto:bigler at cs.utah.edu]
> Sent: Tuesday, June 12, 2007 1:38 PM
> To: Rob Mathews
> Cc: cmake at cmake.org
> Subject: Re: [CMake] Set different compilation flags for specific file
>
> Wouldn't that set it for all the source files in the project? I just
> want to
> override 1 file amongst many others.
>
> Rob Mathews wrote:
>> Why wouldn't you simply do this:
>>
>> SET(CMAKE_CXX_FLAGS_RELEASE "/MT /Ox /Ob1 /DNDEBUG" )
>>
>> (or whatever your particular flags are)
>> ?
>>
>>
>> -----Original Message-----
>> From: cmake-bounces+rmathews=envoyww.com at cmake.org
>> [mailto:cmake-bounces+rmathews=envoyww.com at cmake.org] On Behalf Of
> James
>> Bigler
>> Sent: Tuesday, June 12, 2007 1:14 PM
>> To: cmake at cmake.org
>> Subject: [CMake] Set different compilation flags for specific file
>>
>> I have a file that doesn't compile properly with certain optimization
>> flags that
>> I wish to use on the rest of my system. I poked around the wiki and
> the
>> help
>> file, but I can't find any information on how to do this.
>>
>> According to the documentation SET_SOURCE_FILES_PROPERTIES
> COMPILE_FLAGS
>> only
>> appends new flags. I want to override the values in CMAKE_CXX_FLAGS
> and
>> CMAKE_CXX_FLAGS_RELEASE.
>>
>> Thanks,
>> James
>> _______________________________________________
>> CMake mailing list
>> CMake at cmake.org
>> http://www.cmake.org/mailman/listinfo/cmake
>>
>>
>
>
More information about the CMake
mailing list