target_link_directories for imported targets

In my project I am using MAP_IMPORTED_CONFIG_FINAL for an external library for a custom configuration FINAL . Is there some working example of how to set the target_link_directories for an imported target for the custom configuration FINAL using cmake.

So here are the steps :

  1. The external library is boost-1.67.0 which I am installing using the following commands for Debug and Release respectively:
.\b2 install --prefix=C:\Dev\third-party\vs2017\boost-1.67.0\Debug toolset=msvc-14.1 address-model=64 link=static -j8 variant=debug
.\b2 install --prefix=C:\Dev\third-party\vs2017\boost-1.67.0\Release toolset=msvc-14.1 address-model=64 link=static -j8 variant=release
  1. Here is the example project with following structure
 +-- main.cpp
 +-- CMakeLists.txt
 +-- CMake/
 |  |  
 |  +-- AddConfiguration.cmake
 |  +-- mpIncludeBoost.cmake
 |  +-- mpSetupMSVCRuntime.cmake
 |  +-- SetupConfigurations.cmake

The files are found in this gitlab project:

For the sln file generated note that in Visual Studio in the Linker section in Additional Library Directories I get C:/Dev/third-party/boost-1_67_0/install/lib/$(Configuration) which evaluates to C:/Dev/third-party/boost-1_67_0/install/lib/Final but this directory does not exist since Final is not a valid configuration of boost, it should be C:/Dev/third-party/boost-1_67_0/install/lib/Release instead.

I was thinking a way of getting around this would be to use target_link_directories but how do I use this with cmake generator expressions in this case.


It seems like your Final custom configuration type is not working here. I don’t know if it’s that not all of the bridges in the configuration mapping is done or not.

What are the values of Boost_INCLUDE_DIRS and Boost_LIBRARY_DIRS? I suspect that neither is needed since you’re using imported targets anyways.