[CMake] VC8 projects generated multiple times

Laurentiu Nicolae Laurentiu.Nicolae at quintiq.com
Thu Jun 8 05:19:03 EDT 2006


Hi Bill, David,

By "changing workspaces" I mean that files tend to be added, deleted or
moved quite often during development. We are a VS-only house (at the
moment), and this is THE reason why we want to generate our workspaces.
A normal use scenario: developer A adds 20 files, moves another 15
around, deletes a few and then checks everyting in. Developer B syncs
his source tree and needs to regenerate his workspace. Keeping the
workspaces in the source control is not an option for us, that is why we
go for generation.

As a small example of our process, assume the following folder
structure:
/
-ServerEXE
-ClientEXE
-BaseDLL

####################
/CMakeList.txt

INCLUDE ( CMakeMacros.txt)
PROJECT ( All )
# add executables to be processed by CMake
ADD_SUBDIRECTORY( ServerEXE )
ADD_SUBDIRECTORY ( ClientEXE )

####################
/CMakeMacros.txt

# gather source files in ProjectSources
MACRO ( GenerateProject ProjectSources)

  FILE ( GLOB_RECURSE AllSources           *.c *.cpp *.h *.inl *.rc
*.ico )
  SET ( "${ProjectSources}" ${AllSources}  )

  FOREACH ( Source ${AllSources} )
    STRING ( REGEX REPLACE ${CMAKE_CURRENT_SOURCE_DIR} "" RelativePath
"${Source}" )
    STRING ( REGEX REPLACE "[\\\\/][^\\\\/]*$" "" RelativePath
"${RelativePath}" )
    STRING ( REGEX REPLACE "^[\\\\/]" "" RelativePath "${RelativePath}"
)
    STRING ( REGEX REPLACE "/" "\\\\\\\\" RelativePath
"${RelativePath}" )
    SOURCE_GROUP ( "${RelativePath}" FILES ${Source} )
  ENDFOREACH ( Source )

ENDMACRO ( GenerateProject )

####################
/ServerEXE/CMaleList.txt

PROJECT(ServerEXE)

GenerateProject ( ProjectSources )
# get the file lists
GenerateProject(ProjectSourceS)
ADD_EXECUTABLE ( ServerEXE ${ProjectSources} )

ADD_SUBDIRECTORY ( ../BaseDLL )
INCLUDE_DIRECTORIES ( ../BaseDLL )
ADD_DEPENDENCIES ( Server BaseDLL )
TARGET_LINK_LIBRARIES ( BaseDLL )

####################
/ClientEXE/CMaleList.txt

PROJECT(ClientEXE)

# get the file lists
GenerateProject(ProjectSources)
ADD_EXECUTABLE ( ClientEXE ${ProjectSources} )

ADD_SUBDIRECTORY ( ../BaseDLL )
INCLUDE_DIRECTORIES ( ../BaseDLL )
ADD_DEPENDENCIES ( Server BaseDLL )
TARGET_LINK_LIBRARIES ( BaseDLL )

####################

/BaseDLL/CMaleList.txt

# notice: there's no PROJECT

# get the file lists
GenerateProject(ProjectSources)

# add library
ADD_LIBRARY ( BaseDLL SHARED ${ProjectSources} )

#######################

What I've found out so far:

* Solutions are only generated if the PROJECT command is present
* In this configuration the root project (All) gets BaseDLL twice
* If the ADD_SUBDIRECTORY directives are missing from the ServerEXE and
ClientEXE cmake files, then the BaseDLL project is going to be missing
from the generated solutions
* If I try to process the BaseDLL only once (in a manner similar with
the #ifndef/#define constructs of C headers), BaseDLL will be missing
from all but the first solution

It occurs to me (as I'm writing this) that I could generate the lists
of files once per directory (in a configuration file, perhaps) and then
read them back in instead of globbing every time. Is that a suitable
solution? 

Cheers,
Laurentiu


--
Laurentiu Nicolae
Senior Software Engineer
Quintiq

Tel: +31 (0)73 691 07 39
Fax: +31 (0)73 691 07 54
Laurentiu.Nicolae at quintiq.com 
www.quintiq.com 

------------------------------------------------------------------------------------------
This message contains information that may be privileged or
confidential and is the property of Quintiq. It is only intended for the
person to whom it is addressed. If you are not the intended recipient,
you are not authorized to read, print, retain, copy disseminate,
distribute or use this message or any part thereof. If you receive this
message in error, please notify the sender immediately and delete all
copies of this message. Please note that e-mails are susceptible to
change.

>>> "William A. Hoffman" <billlist at nycap.rr.com> 08-Jun-06 4:42:15 AM
>>>
>This is most likely the source of the problem.   I am not sure what
>it has to do with changing workspaces?   Globbing the source tree
>can be dangerous as you may pick up junk files, and also cmake has
>no way to know when a new file was added.  So, it will not always
>be up-to-date.   
>
>So, maybe you could describe your process a bit more so that a
suggestion
>could be made.
>
>-Bill



More information about the CMake mailing list