Creating/using precompiled headers and static libraries

Thore Karlsen <sid-m3MN3Z/L/[email protected]> Sun, 25 Apr 2004 03:24:21 -0500
Newsgroups gmane.comp.tools.aap.user
Organization I've resigned.
Message-ID <[email protected]>
I'm trying to use AAP for the first time, and I'm trying to guess how
things work. I've made some headway, but my project seems to be more
complex than I thought it was!

I'm using MSVC to compile static libraries, DLLs, and executables. I've
modified msvc.py to create static libraries, but I'm not sure how to use
the resulting static library as a dependency for another project.

I have this to build two static libraries, Common.lib and IPP.lib.
Common.lib links with IPP.lib.

COMMON_PROJECT_FILES =
:tree Common { filename = .*\.cp?p? } { reject = Test_.*|stdafx\.cpp }
	COMMON_PROJECT_FILES += $name

# All common project files should use precompiled headers.
:attr { add_CPPFLAGS = /Yu"stdafx.h" } $COMMON_PROJECT_FILES

# All stdafx.cpp should create precompiled headers.
:tree . { filename = stdafx\.cpp }
	:attr { add_CPPFLAGS = /Yc"stdafx.h" } $name

:lib $BDIR/IPP.lib : IPP/*.cpp

:lib $BDIR/Common.lib
	{ add_LIBS = $BDIR/IPP.lib } :
	Common/stdafx.cpp
	$COMMON_PROJECT_FILES

There are a couple of problems with this:

1. IPP.lib is linked correctly with Common.lib, but IPP.lib is not a
dependency, so it's not automatically created. How do I fix this?

2. When I attribute the files using :attr, the C++-flags are added three
times. In other words, I'm getting "/Ycstdafx.h /Ycstdafx.h /Ycstdafx.h"
on the command line. This happens for the :attr in the :tree, and the
:attr not in the tree. Not a big deal in this case, but it certainly
doesn't seem right.

3. How can I print a message before starting a build? I'd like to print
"Creating Common.lib" or something to separate the various subprojects I
need to build.

Also, is there a better/easier/cleaner way to do the above precompiled
header stuff? Basically what I need to do is:

- Compile all the .c/.cpp files in a recursive directory structure
- Compile stdafx.cpp _first_ with an extra flag /Yc"stdafx.h" to create 
  the PCH
- Compile all other files with an extra flag /Yu"stdafx.h" to use PCH

Thanks for any help you can give me. This looks very promising, and
looks like just what I need for my project, but the learning threshold
is very high and the documentation and simple examples hasn't gotten me
far.

-- 
Be seeing you.



-------------------------------------------------------
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek
For a limited time only, get FREE Ground shipping on all orders of $35
or more. Hurry up and shop folks, this offer expires April 30th!
http://www.thinkgeek.com/freeshipping/?cpg=12297