Boost logo

Boost-Build :

Subject: [Boost-build] [boost-build] how to link against library conditional on compiler version?
From: Steve Lorimer (steve.lorimer_at_[hidden])
Date: 2016-08-04 11:11:51

I have a vendor supplied library which we need to link against.

gcc-5 is not ABI compatible with gcc-4 and below, so I have two versions of
the vendor library, one for gcc-5 builds, and one for gcc-4 builds.

I need to check which compiler I'm building with, and select the correct

In CMake, I can check CMAKE_CXX_COMPILER_VERSION and set a variable:

        set(API_LOC "gcc-4")
        set(API_LOC "gcc-5")

add_library (foo_api STATIC IMPORTED GLOBAL)
set_target_properties(foo_api PROPERTIES IMPORTED_LOCATION

Now, other components just need to add foo_api as a dependency, and they'll
automatically get the correct version.

I know how to create a similar library in

lib foo_api : : <name>foo <file>foo.a ;

I don't, however, know how to conditionally specify the <file> argument
dependent on compiler version.

How can I check the compiler version and select the correct library?

Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at