[CMake] VC8 projects generated multiple times

Laurentiu Nicolae Laurentiu.Nicolae at quintiq.com
Wed Jun 14 03:20:31 EDT 2006


Hi all,

I changed the GenerateProject macro to cache my file lists. In this way
I'm only globbing once. I included the changed macro below, maybe
someone will find it useful.

We gained about 20% using the caches, which makes it worthwile. I
somehow expected more. CMake takes some time to analyze dependencies, I
guess, and there's a lot of them: peak memory usage for generating all
our projects was around 150MB.

Cheers,
Laurentiu

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

# gather source files in ProjectSources
MACRO ( GenerateProject ProjectSources Source)

  SET ( FoundSourcesFile "FoundSourcesFile-NOTFOUND" )
  FIND_FILE ( FoundSourcesFile ${Source}Sources.cmake PATHS
${CMAKE_CURRENT_BINARY_DIR} NO_DEFAULT_PATH )

  IF ( FoundSourcesFile )
    # read cached file list
    MESSAGE ( STATUS "    Found extra sources file ${FoundSourcesFile}"
)
    INCLUDE ( ${CMAKE_CURRENT_BINARY_DIR}/${Source}Sources.cmake )

  ELSE ( FoundSourcesFile )
    # get the file lists
  FILE ( GLOB_RECURSE AllSources           *.c *.cpp *.h *.inl *.rc
*.ico )

    # write cached file list
    MESSAGE ( STATUS "    Generating ${Source}Sources.cmake" )
    CONFIGURE_FILE ( ${CMAKE_HOME_DIR}/CMake/QSourceFiles.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${Source}Sources.cmake @ONLY )

  ENDIF ( FoundSourcesFile )

  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 )

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


--
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.


More information about the CMake mailing list