[CMake] (no subject)

Johan Knutzen knutzen_johan2 at yahoo.se
Wed Dec 16 11:57:05 EST 2009


Hi John,

Thank you! This looks very nice, and uses a bit different approach than the one used in PCHSupport. 

Will use this!

Johan

--- Den tis 2009-12-15 skrev John Drescher <drescherjm at gmail.com>:

Från: John Drescher <drescherjm at gmail.com>
Ämne: Re: [CMake] (no subject)
Till: "Johan Knutzen" <knutzen_johan2 at yahoo.se>
Kopia: cmake at cmake.org
Datum: tisdag 15 december 2009 15.08

On Tue, Dec 15, 2009 at 4:13 AM, Johan Knutzen <knutzen_johan2 at yahoo.se> wrote:
>
> Hi!
>
> What is the status of scripts enabling precompiled headers for gcc/visual studio? I've tried out PCHSupport_26 from http://www.cmake.org/Bug/view.php?id=1260 but I couldn't get it to work. Does anyone have any up to date script that works with 2.8?
>

I have not bothered in linux since I can use ccache to speed up
builds. In windows I use the following macro:

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

macro( SM_PCH_SUPPORT ProjectName )
if (MSVC)
    if (USE_MSVC_PCH)
    
        set_source_files_properties(${ProjectName}PCH.cxx
            PROPERTIES
            COMPILE_FLAGS "/Yc${ProjectName}PCH.h"
            )
        foreach( src_file ${${ProjectName}_SRCS} )
            set_source_files_properties(
                ${src_file}
                PROPERTIES
                COMPILE_FLAGS "/Yu${ProjectName}PCH.h"
                )
        endforeach( src_file ${${ProjectName}_SRCS} )
        
        list(APPEND ${ProjectName}_SRCS ${ProjectName}PCH.cxx)
        list(APPEND ${ProjectName}_EXT_HDRS ${ProjectName}PCH.h)

    endif(USE_MSVC_PCH)
endif (MSVC)
endmacro (SM_PCH_SUPPORT)

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


And this requires me to have my source variable named ${ProjectName}_SRCS

And my header variable to be named ${ProjectName}_EXT_HDRS

and the following files to exist in the same folder as the CMakeLists.txt

${ProjectName}PCH.cxx ${ProjectName}PCH.h

I generally put this macro in the main project before my first
add_subdirectory so that all subprojects can use the macro as well.

Then to activate this in a project. I place the macro call after I
define the list variables.

SET( smDataManagement_SRCS
    ./src/smData.cxx
    ./src/smDataOperation.cxx
    ./src/smCounterBalanceOperation.cxx
)

SET( smDataManagement_EXT_HDRS
    ./Include/smData.h
    ./Include/smDataOperation.h
    ./Include/smCounterBalanceOperation.h
)

SET( smDataManagement_MOC_HDRS
    
)

# some .ui files
SET( smDataManagement_UIS
)

# and finally an resource file
SET( smDataManagement_RCS
)

SET( smDataManagement_INT_HDRS

)

#Add precompiled header support
SM_PCH_SUPPORT(smDataManagement)

This works in cmake-2.6 and above.
John



      __________________________________________________________
Låna pengar utan säkerhet. Jämför vilkor online hos Kelkoo.
http://www.kelkoo.se/c-100390123-lan-utan-sakerhet.html?partnerId=96915014
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20091216/55fb6029/attachment-0001.htm>


More information about the CMake mailing list