[build] Conditional sources and compiler options
Hi, I'm trying to add some SIMD support to my library and I'm having problems with setting up my Jamfile properly. Basically, I have a number of source files that only need to be compiled when the compiler is of a specific version or later (say, gcc >= 4.7 or msvc >= 12 or intel >= X.Y on x86 but not for other compilers/architectures and not for older versions of the mentioned compilers). Next, I need to add special compiler options (specific for each compiler) just for these files. Natuarlly, I also have other source files that need not these tricks and should be compiled normally, without any special options. All source files have to be compiled into a single library (static or dynamic). Is there any way to do it in Boost.Build? I've read about alternatives in the docs, but they require duplicating the library target, which I'd like to avoid. I also read about conditional requirements, but as I understand they don't allow to specify version conditions (like <toolset>gcc >= 4.7). Also I didn't find any way to specify special build options for particular files. Thanks in advance.
Le 04/05/13 10:39, Andrey Semashev a écrit :
Hi,
I'm trying to add some SIMD support to my library and I'm having problems with setting up my Jamfile properly.
Basically, I have a number of source files that only need to be compiled when the compiler is of a specific version or later (say, gcc >= 4.7 or msvc >= 12 or intel >= X.Y on x86 but not for other compilers/architectures and not for older versions of the mentioned compilers). Next, I need to add special compiler options (specific for each compiler) just for these files. Natuarlly, I also have other source files that need not these tricks and should be compiled normally, without any special options. All source files have to be compiled into a single library (static or dynamic).
Is there any way to do it in Boost.Build? I've read about alternatives in the docs, but they require duplicating the library target, which I'd like to avoid. I also read about conditional requirements, but as I understand they don't allow to specify version conditions (like <toolset>gcc >= 4.7). Also I didn't find any way to specify special build options for particular files.
Hi, Boost.Thread uses the following rule usage-requirements ( properties * ) { local result ; if <threadapi>pthread in $(properties) { result += <define>BOOST_THREAD_POSIX ; if <target-os>windows in $(properties) { result += [ win32_pthread_paths $(properties) ] ; # TODO: What is for static linking? Is the <library> also needed # in that case? } } if ! <toolset>vacpp in $(properties) || toolset-vacpp:version11.1 in $(properties) || toolset-vacpp:version12.1.0.1 in $(properties) || toolset-vacpp:version12.1 in $(properties) { result += <library>/boost/chrono//boost_chrono ; } return $(result) ; } The problem is that (if I'm not wrong) * the version is dependent on the user_config file :( * I don't know how to compare them HTH, Vicente
On Sat, May 4, 2013 at 1:21 PM, Vicente J. Botet Escriba < vicente.botet@wanadoo.fr> wrote:
Hi,
The problem is that (if I'm not wrong) * the version is dependent on the user_config file :( * I don't know how to compare them
Thanks, Vicente. I've done what I wanted (you can see the result in
libs/log/build/Jamfile.v2), although this took a whole day long and the
result is far more verbose than I'd like. My experience with Boost.Build is
really terrible so far.
But I'm facing a new problem. While it works as expected on Linux and
Windows with 64 bit MSVC, with 32 bit MSVC I get the following error:
E:/Sources/_SVN/boost-trunk/tools/build/v2/build\virtual-target.jam:1099:
in virtual-target.register-actual-name from module virtual-target
error: Duplicate name of actual target:
participants (2)
-
Andrey Semashev
-
Vicente J. Botet Escriba