Quick question.

I am trying to add precompiled headers to a project that has been converted to 
use Cmake.

In our library directory, we include all our source and build two targets (one 
static and one dynamic), but setting multiple source values only affects the 
source and not the source associated to a particular target.  Is there a way to 
get around this issue or something in the works to correct this, like an 
optional target command?

Thanks...

Code below describing the issue:

FUNCTION (ADD_MSVC_PRECOMPILED_HEADERS
          PrecompiledSource PrecompiledHeader TargetProject)
  IF (MSVC)
    # define the location of the precompiled header
    SET(PrecompiledBinary "${CMAKE_CURRENT_BINARY_DIR}/${TargetProject}.pch")
    # set the target project to use the precompiled binary
    SET_PROPERTY(TARGET ${TargetProject}
                 APPEND
                 PROPERTY COMPILE_FLAGS
                 "/Yu\"${PrecompiledHeader}\" /Fp\"${PrecompiledBinary}\"")
    # set the source file to compile out the pch
    SET_PROPERTY(SOURCE ${PrecompiledSource}
                 APPEND
                 PROPERTY COMPILE_FLAGS
                 "/Yc\"${PrecompiledHeader}\" /Fp\"${PrecompiledBinary}\"")
  ENDIF (MSVC)
ENDFUNCTION (ADD_MSVC_PRECOMPILED_HEADERS)

ADD_LIBRARY(MyLibDynamic SHARED ${SRC})
ADD_LIBRARY(MyLibStatic STATIC ${SRC})

ADD_MSVC_PRECOMPILED_HEADERS(StdAfx.cpp StdAfx.h MyLibDynamic)
ADD_MSVC_PRECOMPILED_HEADERS(StdAfx.cpp StdAfx.h MyLibStatic)

When MyLibDynamic builds, it builds MyLibStatic.pch but tries to find 
MyLibDynamic.pch.
This is because the second function call to setup precompiled headers modifies
what appears to be a property that is not unique to all targets added at the 
same
directory level of the CMakeLists.

Thanks again. . .

Ryan H. Kawicki
The Boeing Company
Training Systems & Services
Software Engineer


_______________________________________________
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

Reply via email to