> Has anyone had any luck with precompiled headers on visual studio 2005?
>
> For Visual Studio 6, i added additional parameters to each compiled
> file. I then told one specific file to build the precompiled headers.
> This worked in vs6, but in 2005 the ide must have the actual projects
> setup for precompiled headers. This "hack" won't work on 2005.
>
> I know there have been requests to add precompiled headers, but I was
> wondering if anyone has written a custom add-in to cmake to do this. If
> not, I am going to have to write one.
>
 
I think the best way to achieve this is to write your own generator but I'm not a master of CMake so maybe there is a simplier way.
Anyway I will describe how I added precompiled header in case it can help you, or someone else.
 
The basic idea is to add properties to the files and retrieve them is a custom made generator.
To do this I have a module file which contains a big FOREACH loop. It loops on the source list and add the properties to each file when it encounters one.
 
The list of files :
 
LIST(APPEND GLOBAL_FILE_DESC
 
    "Source Files"
 
    "Source Files/Module"
        @CREATE_PCH "source/dummy.cpp"
        "dummy.h"
        @USE_PCH "source/dummy2.cpp"
        "dummy2.h"
        @NO_PCH "source/dummy3.cpp"
        "dummy3.h"
 
    "Source Files/Docs"
        @EXCLUDE "dummy.dox"
 
    "Resource Files"
        "resources/dummy.rc"
 
)
 
This loop adds properties and sourcegroup. The sub loops allow to add properties or file groups from our master CMakeLists.txt directly.
 
FOREACH(SOURCE_DESCRIPTION ${GLOBAL_FILE_DESC})
 
    # look for the nature of the entry
   
    IF(${SOURCE_DESCRIPTION} MATCHES "@.*")
   
        # this is a property
        # ------------------
        FOREACH(FILE_PROPERTY ${FILE_PROPERTIES})
            IF(${SOURCE_DESCRIPTION} MATCHES "@(${FILE_PROPERTY})$")
               # add this property to the current properties
                LIST(APPEND CUR_PROPERTIES ${${FILE_PROPERTY}_PROPERTY} ${${FILE_PROPERTY}_VALUE})
            ENDIF(${SOURCE_DESCRIPTION} MATCHES "@(${FILE_PROPERTY})$")
        ENDFOREACH(FILE_PROPERTY ${FILE_PROPERTIES})
       
    ELSE(${SOURCE_DESCRIPTION} MATCHES "@.*")
        IF(${SOURCE_DESCRIPTION} MATCHES ".*[.].*$")
 
            # this is a file
            # --------------
            FOREACH(FILE_GROUP ${FILE_GROUPS})
                IF(${SOURCE_DESCRIPTION} MATCHES ".*[.](${REGISTRED_${FILE_GROUP}_EXT})")
                    # add the file to its group
                    LIST(APPEND ${FILE_GROUP} ${SOURCE_DESCRIPTION})
                    IF(CUR_PROPERTIES)
                        # add current properties to the file
                        SET_SOURCE_FILES_PROPERTIES(${SOURCE_DESCRIPTION} PROPERTIES ${CUR_PROPERTIES})
                        SET(CUR_PROPERTIES "")
                    ENDIF(CUR_PROPERTIES)
                ENDIF(${SOURCE_DESCRIPTION} MATCHES ".*[.](${REGISTRED_${FILE_GROUP}_EXT})")
            ENDFOREACH(FILE_GROUP ${FILE_GROUPS})
            # add the file to the current folder list
            LIST(APPEND CUR_FOLDER_LIST ${SOURCE_DESCRIPTION})
           
        ELSE(${SOURCE_DESCRIPTION} MATCHES ".*[.].*$")
       
            # this is a source folder
            # -----------------------
            IF(CUR_FOLDER)
                # we meet a valid source folder
                SOURCE_GROUP(${CUR_FOLDER} FILES ${CUR_FOLDER_LIST})
                SET(CUR_FOLDER_LIST "")
            ENDIF(CUR_FOLDER)
            SET(CUR_FOLDER ${SOURCE_DESCRIPTION})           
           
        ENDIF(${SOURCE_DESCRIPTION} MATCHES ".*[.].*$")
    ENDIF(${SOURCE_DESCRIPTION} MATCHES "@.*")   
ENDFOREACH(SOURCE_DESCRIPTION ${GLOBAL_FILE_DESC})
 
# create the last source folder
IF(CUR_FOLDER)
    SOURCE_GROUP(${CUR_FOLDER} FILES ${CUR_FOLDER_LIST})
ENDIF(CUR_FOLDER)
 
# merge all file groups into one group
FOREACH(FILE_GROUP ${FILE_GROUPS})
    IF(${FILE_GROUP})
        LIST(APPEND TARGET_FILES ${${FILE_GROUP}})
    ENDIF(${FILE_GROUP})
ENDFOREACH(FILE_GROUP ${FILE_GROUPS})
 
After this, you create your own generator where you retrieve the properties and write them to the project files.
Hope that will help you a bit.
 
Sylvain
_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to