[CMake] Where do add_dependencies() that are not defines go?
Luke Dalessandro
ldalessandro at gmail.com
Thu Apr 29 08:17:57 EDT 2010
On Thu, Apr 29, 2010 at 4:00 AM, Michael Wild <themiwi at gmail.com> wrote:
> Considering that doing something like this:
>
> add_definitions(-m64)
>
> is not a very good idea since it is very compiler/platform specific,
Right.
I'm trying to make a minimally invasive change in the structure of an
existing project that I don't have full control over, and I was really
just trying to recover non -D defines added through this command for
an add_custom_command.
Luke
> you might want to attack the whole problem from a different angle:
>
> if(CMAKE_COMPILER_IS_GNUC)
> if(CMAKE_SIZEOF_VOID_P EQUAL 8)
> set(_comp_flag -m64)
> else()
> set(_comp_flag -m32)
> endif()
> elseif(...)
> ...
> else()
> set(_comp_flag)
> endif()
> set(${PROJECT}_COMPILE_FLAGS "${_comp_flag}" CACHE STRING "Extra compile flags")
> add_definitions(${${PROJECT}_COMPILE_FLAGS})
>
>
> This way the user has still the opportunity to intervene and select different flags (or provide them if your CMakeLists.txt doesn't know how to handle this particular compiler).
>
> HTH
>
> Michael
>
> On 29. Apr, 2010, at 9:41 , Marcel Loose wrote:
>
>> Hi Luke,
>>
>> A little digging revealed that you should use the property DEFINITIONS
>> instead of COMPILE_DEFINITIONS, despite the fact that the manual says
>> that DEFINITIONS is there for backward compatibility only. I noticed
>> that that's the only property that contains your compile flag. Maybe
>> someone from Kitware can comment on this?
>>
>> Best regards,
>> Marcel Loose.
>>
>> On Wed, 2010-04-28 at 12:58 -0400, Luke Dalessandro wrote:
>>> On Wed, Apr 28, 2010 at 12:04 PM, Marcel Loose <loose at astron.nl>
>> wrote:
>>>> Hi Luke,
>>>>
>>>> Remember that the definitions you do with add_definitions() are
>> scoped;
>>>> i.e. you can only see them in the directory where you defined them
>> and
>>>> its sub-directories, but not its parent directories.
>>>>
>>>> You should definitely do add_definitions("-m64") in your top-level
>>>> directory.
>>>
>>> I understand the scoping issue. The problem is that I don't know what
>>> variable the non -D values are being placed in, so that I can recover
>>> them in a custom build. They're not in any of the CMAKE_<LANG>_FLAGS,
>>> nor are they in a file's COMPILE_FLAGS property. The -D values are
>>> attached to the directory's COMPILE_DEFINITIONS, but the directory
>>> doesn't have COMPILE_FLAGS.
>>>
>>> They're not lost, because (say) -m64 does appear on the build line as
>>> needed, I just don't know what variable they're being stored in.
>>>
>>> Luke
>>>
>>>>
>>>> Best regards,
>>>> Marcel Loose.
>>>>
>>>> On Wed, 2010-04-28 at 11:44 -0400, Luke Dalessandro wrote:
>>>>> I meant add_definitions not dependencies. Sorry.
>>>>>
>>>>> Luke
>>>>>
>>>>> On Wed, Apr 28, 2010 at 11:39 AM, Luke Dalessandro
>>>>> <ldalessandro at gmail.com> wrote:
>>>>>> We sometimes use add_dependencies to add compile flags that
>> aren't
>>>>>> defines, e.g., -m64. I am trying to build an add_custom_command
>> that
>>>>>> needs access to these flags, but I can't seem to find them
>> anywhere
>>>> (I
>>>>>> can get the dependencies from the directory properties).
>>>>>>
>>>>>> Does anyone know where these other flag types are stored?
>>>>>>
>>>>>> Thanks,
>>>>>> Luke
>>>>>>
>>>>> _______________________________________________
>>>>> Powered by www.kitware.com
>>>>>
>>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.html
>>>>>
>>>>> Please keep messages on-topic and check the CMake FAQ at:
>>>> http://www.cmake.org/Wiki/CMake_FAQ
>>>>>
>>>>> Follow this link to subscribe/unsubscribe:
>>>>> http://www.cmake.org/mailman/listinfo/cmake
>>>>
>>>>
>>>>
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.cmake.org/mailman/listinfo/cmake
>>
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.cmake.org/mailman/listinfo/cmake
>
>
More information about the CMake
mailing list