将 PNG_INCLUDE_DIRS 定义为路径列表,但我不能只使用 include_directories()来包含它方法(找不到 png.h )
find_package(PNG REQUIRED)
message("include dirs: " ${PNG_INCLUDE_DIRS})
include_directories(${PNG_INCLUDE_DIRS})
foreach(include_dir ${PNG_INCLUDE_DIRS})
message("in loop: " ${include_dir})
include_directories(${include_dir})
endforeach(include_dir)
它产生输出:
include dirs: /usr/local/include/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include
in loop: /usr/local/include
in loop: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include
有趣的是,如果我添加这一行
include_directories("/usr/local/include")
然后标题可见。看起来像cmake中列表的一些棘手的东西。 我在OSX 10.11上使用CLion