[CMake] Decoupuling configuration and toolchain

Ryan Pavlik rpavlik at iastate.edu
Thu Sep 23 12:50:42 EDT 2010


See here for information on build/source directories:
http://www.paraview.org/Wiki/CMake_FAQ#Out-of-source_build_trees

For your example compiler flag (is that gcc only?) and all other info you've
provided so far, you'd probably want to do something like this:

if(CMAKE_CONFIGURATION_TYPES)
     set(CMAKE_CONFIGURATION_TYPES Debug Release)
     set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE
STRING "Reset the configurations to what we need" FORCE)
endif()

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D _DEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /D _NDEBUG")

if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CROSSCOMPILING)
    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -no-rtti")
endif()

Hope this helps!

On Thu, Sep 23, 2010 at 10:50 AM, Andrea Galeazzi <galeazzi at korg.it> wrote:

> But where could I put the custom options for the compiler, for example in
> arm-debug I'd like to have
> CMAKE_CXX_FLAGS -no-rtti
> what do you mean with build directory, the source directory?
>
> Citando Ryan Pavlik <rpavlik at iastate.edu>:
>
>
>  Keep these lines, if they are necessary for your system:
>> if(CMAKE_CONFIGURATION_TYPES)
>>      set(CMAKE_CONFIGURATION_TYPES Debug Release)
>>      set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE
>> STRING "Reset the configurations to what we need" FORCE)
>> endif()
>>
>> Remove the other lines.  In general, for something like this, you'd have
>> multiple binary/build directories for a single source tree.  With a
>> multi-config generator like Visual Studio, you just would need one build
>> directory for each platform (win32 and arm).  For a single-config
>> generator
>> like NMake or Unix Makefiles, you'd have one build directory for each
>> platform-mode pair (win32-release, win32-debug, etc).
>>
>> Hope this helps!
>>
>> Ryan
>>
>> On Thu, Sep 23, 2010 at 9:58 AM, Andrea Galeazzi <galeazzi at korg.it>
>> wrote:
>>
>>  Hi everybody,
>>> I've got a project with two configuration (Debug and Release) and two
>>> target: win32 and ARM.
>>> In your opinion what's the best way to manage a such kind of project?
>>> As an example, in my CmakeList I have the following piece of code that
>>> works fine only for visual studio.
>>> if(CMAKE_CONFIGURATION_TYPES)
>>>          set(CMAKE_CONFIGURATION_TYPES Debug Release)
>>>      set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE
>>> STRING "Reset the configurations to what we need" FORCE)
>>>          set(CMAKE_CXX_FLAGS_DEBUG "/D _DEBUG")
>>>          set(CMAKE_CXX_FLAGS_RELEASE "/D _NDEBUG")
>>> endif()
>>>
>>> What I need is to move this code in another file so I can also specify
>>> similar options for gcc etc......
>>> On the other hand in CMakeList.txt should contain just only the
>>> sources,include path and the other statements not involving the specific
>>> target or configuration.
>>> Cheers
>>> _______________________________________________
>>> 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
>>>
>>>
>>
>>
>> --
>> Ryan Pavlik
>> HCI Graduate Student
>> Virtual Reality Applications Center
>> Iowa State University
>>
>> rpavlik at iastate.edu
>> http://academic.cleardefinition.com
>> Internal VRAC/HCI Site: http://tinyurl.com/rpavlik
>>
>>


-- 
Ryan Pavlik
HCI Graduate Student
Virtual Reality Applications Center
Iowa State University

rpavlik at iastate.edu
http://academic.cleardefinition.com
Internal VRAC/HCI Site: http://tinyurl.com/rpavlik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100923/5abf5750/attachment.htm>


More information about the CMake mailing list