开发者

SCons Binary Directory

开发者 https://www.devze.com 2023-02-04 22:57 出处:网络
How is the binary/executable directory specified in SCons? It\'s easy to do as follows: Program( target = \'bin/helloworld\', source = \'src/helloworld.cc\' )

How is the binary/executable directory specified in SCons? It's easy to do as follows:

Program( target = 'bin/helloworld', source = 'src/helloworld.cc' )

The problem with this approach is when trying to do cross-platform builds. Here's an example that works:

StaticLibrary( target = 'helloworld', source = 'src/helloworldlib.cc' )

The output of this on a Unix system is a library named libhelloworld.a. An example where it doesn't work follows:

StaticLibrary( target = 'lib/helloworld', source = 'src/helloworldlib.cc' )

The output on a Unix system of this is a file helloworld.a in directory lib. This causes problems when LIBS is specif开发者_开发问答ied as ['helloworld'], which is the cross platform way to do it.

What is the parameter name to pass into StaticLibrary, SharedLibrary, and Program to output binaries into a directory other than the base directory?


The manual suggests that you use a variant directory and a SConscript file in the source directory. In your example, place a SConscript file in the src directory:

StaticLibrary(target="helloworld", source="helloworldlib.cc")

and call that from the main SConstruct file:

SConscript("src/SConscript", variant_dir="lib")
0

精彩评论

暂无评论...
验证码 换一张
取 消