0

I'm developing a library and I need to add a third party header-only library for debug build only. It's only used for development.

Is there an easy way to do this in CMake?

I know we can do the same for linking libraries,

add_executable( MyEXE ${SOURCES})

target_link_libraries( MyEXE debug 3PDebugLib)
target_link_libraries( MyEXE optimized 3PReleaseLib)

But there seems no such option for target_include_directories.

Using CMake 3.11.4 and VS2017.

zwcloud
  • 4,546
  • 3
  • 40
  • 69

1 Answers1

4

While target_include_directories itself does not provide the possibility to distinguish between different build types, you can use generator expressions, e.g.:

target_include_directories(MyEXE
    PRIVATE
        $<$<CONFIG:Debug>:3PDebugLib>
        $<$<CONFIG:Release>:3PReleaseLib>
)
Stanley F.
  • 1,846
  • 16
  • 29