[CMake] Fwd: Problems setting CMAKE_CONFIGURATION_TYPES for Visual Studio

Paul Smith paul at mad-scientist.net
Wed May 29 11:00:02 EDT 2013


This is probably not related, but your comment about deleting the cmake
cache made me think of it: one thing to be sure of is that if you delete
CMakeCache.txt you ALSO delete the CMakeFiles/ directory.

Deleting CMakeCache.txt but not CMakeFiles yields corrupted results
after you run "cmake" the next time.  Being sure to delete both at the
same time, all the time, allows things to work OK.


On Wed, 2013-05-29 at 16:55 +0200, Petr Kmoch wrote:
> I haven't looked into CMake code deep enough, so I don't really know
> how it works either. Maybe project() stores something into the cache
> which causes it to not trample over the configuration list in the next
> run. Just guessing.
> 
> Petr
> 
> 
> 
> On Wed, May 29, 2013 at 4:40 PM, gaga bla <gagabla0 at gmail.com> wrote:
>         Hello Petr,
>         
>         i don't understand how this solves the problem, but indeed it
>         does!
>         
>         Still i have one small problem. To make regeneration of a
>         clean project as easy as possible, i have a batch file, which
>         first clears all generated data (including cmake cache), an
>         then runs cmake. Since this fails now the first time, i have
>         to run cmake twice in this batch file, but if other errors
>         occour, i get output twice.
>         
>         
>         Maybe if i could understand why your solution works, i could
>         come up with one that works without running cmake once again?
>         
>         
>         Thanks so far!
>         Janosch
>         
>         
>         
>         On Wed, May 29, 2013 at 1:34 PM, Petr Kmoch
>         <petr.kmoch at gmail.com> wrote:
>                 Hi Janosch.
>                 
>                 A solution to this problem which works for me is: if
>                 the configurations are not those I want, set them
>                 correctly and abort the generation (with a help
>                 message).
>                 
>                 I put the following code into the CMakeList after the
>                 call to project():
>                 
>                 if(CMAKE_CONFIGURATION_TYPES AND NOT
>                 CMAKE_CONFIGURATION_TYPES MATCHES FullDebug)
>                 
>                   set(cfgs ${CMAKE_CONFIGURATION_TYPES})
>                 
>                   list(REMOVE_ITEM cfgs MinSizeRel)
>                 
>                   list(APPEND cfg FullDebug)
>                 
>                   set(CMAKE_CONFIGURATION_TYPES ${cfgs} CACHE STRING
>                 "List of supported configurations." FORCE)
>                   message(FATAL_ERROR "List of configurations was
>                 reset, please re-run CMake.")
>                 endif()
>                 
>                 
>                 
>                 Hope this helps.
>                 
>                 Petr
>                 
>                 
>                 
>                 On Wed, May 29, 2013 at 1:14 PM, gaga bla
>                 <gagabla0 at gmail.com> wrote:
>                 
>                         Hello Eric,
>                         
>                         thanks for your reply, i tried this, but in my
>                         case it doesn't work. I made a function that
>                         first sets the configuration types (using your
>                         line of code) and then calls the project
>                         function. Using this function instead of the
>                         project function itself, still all
>                         configurations are beeing generated.
>                         
>                         I browsed through the cmake sources and
>                         modules, but i coudn't find the place that
>                         reintroduces those configurations.
>                         
>                         It looks like a bug to me, later on i will try
>                         to produce an example.
>                         
>                         
>                         Kind regards
>                         Janosch
>                         
>                         
>                         
>                         On Tue, May 28, 2013 at 10:01 PM, Eric Clark
>                         <eclark at ara.com> wrote:
>                                 Our projects limit the types to just
>                                 Debug and Release. However, what I
>                                 found was that you had to set the
>                                 variable before every call to
>                                 project(…). What we did was we created
>                                 a module called BuildTypes.cmake and
>                                 include it first thing in every list
>                                 file. The file has one line of code in
>                                 it that looks like this:
>                                 
>                                  
>                                 
>                                 set(CMAKE_CONFIGURATION_TYPES Debug
>                                 Release CACHE TYPE INTERNAL FORCE)
>                                 
>                                  
>                                 
>                                 This does the trick for us. Hope this
>                                 helps…
>                                 
>                                  
>                                 
>                                 Eric
>                                 
>                                  
>                                 
>                                 From: cmake-bounces at cmake.org
>                                 [mailto:cmake-bounces at cmake.org] On
>                                 Behalf Of gaga bla
>                                 Sent: Tuesday, May 28, 2013 12:55 PM
>                                 To: cmake at cmake.org
>                                 Subject: [CMake] Problems setting
>                                 CMAKE_CONFIGURATION_TYPES for Visual
>                                 Studio
>                                 
>                                  
>                                 
>                                 Hello, I have problems reducing
>                                 available configuration types for a
>                                 Visual Studio project.
>                                 
>                                 No matter what I do, the project
>                                 always contains all four configuration
>                                 types.
>                                 
>                                  
>                                 
>                                 I have two files involved, I tried to
>                                 strip everything that seemed to be
>                                 unimportant:
>                                 
>                                  
>                                 
>                                 CmakeLists.txt (Main file):
>                                 
>                                 ------------------------------------
>                                 
>                                 include("... Helpers.cmake")
>                                 
>                                 configureMyProject("MyProject")
>                                 
>                                 message("Config types (outside):
>                                 ${CMAKE_CONFIGURATION_TYPES}")
>                                 
>                                 ------------------------------------
>                                 
>                                  
>                                 
>                                 Helpers.cmake:
>                                 
>                                 ------------------------------------
>                                 
>                                 if(__myhelpers)
>                                 
>                                                 return()
>                                 
>                                 endif()
>                                 
>                                 set(__myhelpers YES)
>                                 
>                                  
>                                 
>                                 function(configureMyProject
>                                 MY_NAME ........)
>                                 
>                                   set(CMAKE_CONFIGURATION_TYPES
>                                 "Debug;RelWithDebInfo" CACHE STRING ""
>                                 FORCE)
>                                 
>                                   message("Config types (before):
>                                 ${CMAKE_CONFIGURATION_TYPES}") 
>                                 
>                                   project(${MY_NAME}) 
>                                 
>                                   message("Config types (after):
>                                 ${CMAKE_CONFIGURATION_TYPES}") 
>                                 
>                                   set(CMAKE_CONFIGURATION_TYPES
>                                 "Debug;RelWithDebInfo" CACHE STRING ""
>                                 FORCE) 
>                                 
>                                   message("Config types (after 2):
>                                 ${CMAKE_CONFIGURATION_TYPES}")
>                                 
>                                   ...
>                                 
>                                   add_library(...)
>                                 
>                                   ...
>                                 
>                                 endfunction()
>                                 
>                                 ------------------------------------
>                                 
>                                  
>                                 
>                                 I then get the following output:
>                                 
>                                 ------------------------------------
>                                 
>                                 Config types (before):
>                                 Debug;RelWithDebInfo
>                                 
>                                 Config types (after):
>                                 Debug;Release;MinSizeRel;RelWithDebInfo
>                                 
>                                 Config types (after 2):
>                                 Debug;RelWithDebInfo
>                                 
>                                 Config types (outside):
>                                 Debug;RelWithDebInfo
>                                 
>                                 ------------------------------------
>                                 
>                                  
>                                 
>                                 So it seems to me, that the call of
>                                 the project-function resetted the
>                                 configuration types and created then
>                                 the project accordingly.
>                                 
>                                 Is this a bug or am I doing something
>                                 wrong? Does anyone know a workaround?
>                                 
>                                  
>                                 
>                                 Kind regards
>                                 
>                                 Janosch Scharlipp
>                                 
>                                 
>                         
>                         
>                         
>                         
>                         
>                         
>                         --
>                         
>                         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