Include directories for target_precompile_headers

Quoting https://cmake.org/cmake/help/git-stage/command/target_precompile_headers.html:

Header file names specified with angle brackets (e.g. <unordered_map> ) or explicit double quotes (escaped for the cmake-language(7), e.g. [["other_header.h"]] ) will be treated as is, and include directories must be available for the compiler to find them. Other header file names (e.g. project_header.h ) are interpreted as being relative to the current source directory (e.g. CMAKE_CURRENT_SOURCE_DIR) and will be included by absolute path.

So you need to write:

target_precompile_headers(ocv PRIVATE <cppCommon.hpp> <subtCommon.hpp>)

or

target_precompile_headers(ocv PRIVATE [["cppCommon.hpp"]] [["subtCommon.hpp"]])

or

target_precompile_headers(ocv PRIVATE
  ../../include/cppCommon.hpp
  ../../include/subtCommon.hpp
)
1 Like