Mark Van Peteghem | 1 Jul 2010 09:12
Picon

Re: Different configurations with Visual Studio

Thanks, this works. Actually

if(CMAKE_CONFIGURATION_TYPES)
   set(CMAKE_CONFIGURATION_TYPES Debug Release DebugMX31 ReleaseMX31)

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

also works for me. I've added it to the FAQ of the Wiki. But this is only half of what need. I actually need to make this generate settings for a different platform as well, I mean 'platform' in the Visual Studio sense, also called 'solution platform' in Visual Studios configuration manager, which is Win32 by default, but I need it for both Win32 and MX31.

Can this be done with CMake? I'm afraid not, but if it is possible, how? In the project file it is written as something like Debug|MX31, but using that in CMake doesn't work.

Mark

2010/6/28 Michael Wild <themiwi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

On 28. Jun, 2010, at 15:17 , Mark Van Peteghem wrote:

> Hi,
>
> I am using CMake to generate Visual Studio project files, later also for
> CodeBlocks.
>
> It seems that CMake generates four different configurations for Visual
> Studio: Debug, Release, MinSizeRel and RelWithDebInfo. However, I need other
> configuations, Debug and Release, both for Win32 and MX3, in one project
> file. How do I change this?
>
> I tried this by changing *CMAKE_CONFIGURATION_TYPES *and CMAKE_BUILD_TYPES,
> e.g.
>
> SET(CMAKE_BUILD_TYPES Debug Release DebugMX31 ReleaseMX31)
>
> but I have the impression that these variables cannot be changed.
>
> --
> Mark

You have to change CMAKE_CONFIGURATION_TYPES in the cache. Here is some template I use:

# Xcode generator is buggy (linker flags are not inherited from compile flags
# and custom configurations don't work with shared libraries)
if(NOT CMAKE_GENERATOR STREQUAL Xcode)
 set(CMAKE_C_FLAGS_SUPERDUPER "--super --duper" CACHE
   STRING "Flags used by the compiler during super-duper builds")
 set(CMAKE_EXE_LINKER_FLAGS_SUPERDUPER "--super --duper" CACHE
   STRING "Flags used by the linker for executables during super-duper builds")
 set(CMAKE_SHARED_LINKER_FLAGS_SUPERDUPER "--super --duper" CACHE
   STRING "Flags used by the linker for shared libraries during super-duper builds")
 set(CMAKE_MODULE_LINKER_FLAGS_SUPERDUPER "--super --duper" CACHE
   STRING "Flags used by the linker for loadable modules during super-duper builds")
 mark_as_advanced(CMAKE_C_FLAGS_COVERAGE CMAKE_EXE_LINKER_FLAGS_SUPERDUPER
   CMAKE_SHARED_LINKER_FLAGS_SUPERDUPER CMAKE_MODULE_LINKER_FLAGS_SUPERDUPER)
 # This variable is only set for multi-config IDE generators
 if(CMAKE_CONFIGURATION_TYPES)
   list(APPEND CMAKE_CONFIGURATION_TYPES SuperDuper)
   list(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
   set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
     "Semicolon separated list of supported configuration types [Debug|Release|MinSizeRel|RelWithDebInfo|SuperDuper]"
     FORCE)
 endif()
endif()

HTH

Michael


_______________________________________________
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
Diablo 666 | 1 Jul 2010 09:45
Picon
Favicon

Exclude CMakeFiles path from GLOB_RECURSE

Hi,

I'm currently trying to use the following line to include all source files into my build:

file (GLOB_RECURSE Files_CPP *.cpp)
add_executable(test
    ${Files_CPP}
)

Everything runs fine while using an out-of-source build, but for in-source builds these lines include .cpp files from the CMakeFiles directory. Is there any way to exclude this directory within the file command?

Best regards,
Andreas

Räumen Sie Ihr Postfach auf - ganz einfach mit Hotmail!
_______________________________________________
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
Michael Wild | 1 Jul 2010 10:04
Picon
Gravatar

Re: Exclude CMakeFiles path from GLOB_RECURSE


On 1. Jul, 2010, at 9:45 , Diablo 666 wrote:

> 
> Hi,
> 
> I'm currently trying to use the following line to include all source files into my build:
> 
> file (GLOB_RECURSE Files_CPP *.cpp)
> add_executable(test
>    ${Files_CPP}
> )
> 
> Everything runs fine while using an out-of-source build, but for in-source builds these lines include
.cpp files from the CMakeFiles directory. Is there any way to exclude this directory within the file command?
> 
> Best regards,
> Andreas

1. Never use GLOB_RECURSE. It's evil. E.g. if you add or remove source files, CMake has no way of knowing that
it should be re-run. Just list all the files in your CMakeLists.txt (or, if you think the list is
excessively long, create a file called e.g. files.cmake, put the list in there and INCLUDE it in the
CMakeLists.txt file.

2. Never do in-source builds. CMake creates many, many files, and you don't want to delete them all
individually for a clean build. And there's no way to implement a safe "make clean" (e.g. your build system
might be running a custom utility which generates files CMake knows nothing about).

HTH

Michael

_______________________________________________
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

Diablo 666 | 1 Jul 2010 10:15
Picon
Favicon

Re: Exclude CMakeFiles path from GLOB_RECURSE

Hi,

thanks for your reply.

> 1. Never use GLOB_RECURSE. It's evil. E.g. if you add or remove source files, CMake has no way of knowing that it should be re-run.
I have tested rerunning cmake manually and it worked out well. (Testcase: I added a new .cpp file to the build) I either have to change the CMakeLists.txt or to rerun cmake manually. Seems to be the same effort for me.

> 2. Never do in-source builds. CMake creates many, many files, and you don't want to delete them all individually for a clean build. And there's no way to implement a safe "make clean" (e.g. your build system might be running a custom utility which generates files CMake knows nothing about).

I know these problems. I will never do an in-source-build again :-) But unfortunately, I have to support in-source builds, too.

Best regards,
Andreas

Künftig E-Mails über Hotmail ohne Werbung versenden!
_______________________________________________
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
Michael Wild | 1 Jul 2010 10:49
Picon
Gravatar

Re: Exclude CMakeFiles path from GLOB_RECURSE


On 1. Jul, 2010, at 10:15 , Diablo 666 wrote:

> 
> Hi,
> 
> thanks for your reply.
> 
>> 1. Never use GLOB_RECURSE. It's evil. E.g. if you add or remove source files, CMake has no way of knowing
that it should be re-run.
> I have tested rerunning cmake manually and it worked out well. (Testcase: I added a new .cpp file to the
build) I either have to change the CMakeLists.txt or to rerun cmake manually. Seems to be the same effort
for me.

Thing is: will you never forget? And it prevents stray files from being picked up (as you experienced).
Also, you get an immediate response if a file is missing, and not just when the compiler complains about a
missing header or you get undefined references during the linking stage.

If you insist on using GLOB_RECURSE, don't apply it to CMAKE_CURRENT_SOURCE_DIR, but use GLOB on the
CMAKE_CURRENT_SOURCE_DIR and use GLOB_RECURSE on all the subdirectories individually, so you don't
get CMake-generated stuff.

Also, you could filter out all the items contained in the CMakeFiles directory:

file(GLOB_RECURSE SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp *.h)
string(REGEX REPLACE "CMakeFiles/[^;]+;?" "" SRCS "${SRCS}")

Michael
_______________________________________________
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

Marcel Loose | 1 Jul 2010 11:53
Picon
Favicon

Re: Howto unset cache variable without UNSET()

Hi Fraser,

It doesn't. Well, partly it does, but unfortunately setting FOO to an
empty string doesn't make it undefined; i.e. if(DEFINED FOO) will be
TRUE. I've decided to use 'if("${FOO}" MATCHES "^$")' instead.

Best regards,
Marcel Loose.

On Wed, 2010-06-30 at 10:57 +0100, Fraser Hutchison wrote:
> I think 'set(FOO "" CACHE INTERNAL "Foo")' should do the trick.
> 
> All the best,
> 
> Fraser.
> 
> 
> 
> On 30/06/2010 9:38 AM, Marcel Loose wrote:
> > Hi all,
> >
> > Is there a way to unset a cache variable, i.e. make it undefined,
> > *without* using unset().
> >
> > My reason for asking is that my CMake scripts need to be backward
> > compatible with every 2.6 version. Unfortunately, unset() was added
in a
> > patch release (2.6.3 if I recall correctly), so I cannot use it.
> >
> > The problem is that, though 'set(FOO)' will make FOO undefined, this
> > doesn't seem to work for 'set(FOO CACHE INTERNAL "Foo")'.
> >
> > Any ideas how to accomplish this?
> >
> > Best regards,
> > Marcel Loose.
> >
> >
> >
> >
> > _______________________________________________
> > 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

Diablo 666 | 1 Jul 2010 13:47
Picon
Favicon

Re: Exclude CMakeFiles path from GLOB_RECURSE


> Thing is: will you never forget? And it prevents stray files from being picked up (as you experienced). Also, you get an immediate response if a file is missing, and not just when the compiler complains about a missing header or you get undefined references during the linking stage.

Ok, that sounds reasoble. (This should especially convince some lazy people :-D )
Thanks a lot!

Räumen Sie Ihr Postfach auf - ganz einfach mit Hotmail!
_______________________________________________
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
Johny Jose | 1 Jul 2010 14:11
Picon
Picon

Notes not showing up on CDash

I have been trying to upload files as notes for my builds using the ctest_submit(PARTS Notes) command. When i run the script it shows submissions successful but when i check the dashboard i cannot find any notes. What am i doing wrong ?

Regards
Johny

_______________________________________________
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
Diablo 666 | 1 Jul 2010 14:46
Picon
Favicon

Preserve tree structur for IDEs

Hi,

I need CMake to create a Visual Studio solution for a project with several subdirectories but only one single library.
How can I achieve project files that preserve this tree structure?

Best regards,
Andreas

Echte Freunde sagen's per Messenger!
_______________________________________________
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
Eric Noulard | 1 Jul 2010 15:03
Picon

Re: Preserve tree structur for IDEs

2010/7/1 Diablo 666 <thediablo666@...>:
> Hi,
>
> I need CMake to create a Visual Studio solution for a project with several
> subdirectories but only one single library.
> How can I achieve project files that preserve this tree structure?

For "grouping" source in Visual Studio you may use

source_group(name [REGULAR_EXPRESSION regex] [FILES src1 src2 ...])

concerning "several subdir" for one lib, you may have a single CMakeLists.txt
the parent subdir which add_library from subdirs.
Say you tree is :

parent/subdir1
           /subdir2

the parent/CMakeLists.txt may contains

set(SRC_DIR1 subdir1/blah.cc subdir1/bouh.cc)
set(SRC_DIR2 subdir2/how.cc subdir2/how.hh)

add_library(whatever ${SRC_DIR1} ${SRC_DIR2})

You may add source group too:

source_group(LookHere\\SDIR1 FILES ${SRC_DIR1})
source_group(LookHere\\SDIR2 FILES ${SRC_DIR2})

--

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
_______________________________________________
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


Gmane