查找Boost标头时出错



我有一个问题与CMake找到Boost头(特别是thread)。

在我的CMakeLists.txt文件中…(为了简洁,省略了与boost无关的脚本)

… 
find_package(Boost COMPONENTS thread REQUIRED)
…
#this prints /Users/thomas/boost_1_47_0/boost
MESSAGE(${Boost_INCLUDE_DIR}) 
include_directories(${Boost_INCLUDE_DIR})
…
target_link_libraries(MY_PROG ${Boost_THREAD_LIBRARY})

CMake配置和生成makefile很好,但我得到这个编译错误:

error: boost/thread.hpp: No such file or directory

谢谢,Dragonwrenn

p。S:这是生成的Makefile,如果它有用的话

# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 2.8
# Default target executed when no arguments are given to make.
default_target: all
.PHONY : default_target
#=============================================================================
# Special targets provided by cmake.
# Disable implicit rules so canoncical targets will work.
.SUFFIXES:
# Remove some rules from gmake that .SUFFIXES does not remove.
SUFFIXES =
.SUFFIXES: .hpux_make_needs_suffix_list
# Suppress display of executed commands.
$(VERBOSE).SILENT:
# A target that is always out of date.
cmake_force:
.PHONY : cmake_force
#=============================================================================
# Set environment variables for the build.
# The shell in which to execute make rules.
SHELL = /bin/sh
# The CMake executable.
CMAKE_COMMAND = "/Applications/CMake 2.8-3.app/Contents/bin/cmake"
# The command to remove a file.
RM = "/Applications/CMake 2.8-3.app/Contents/bin/cmake" -E remove -f
# The program to use to edit the cache.
CMAKE_EDIT_COMMAND = "/Applications/CMake 2.8-3.app/Contents/bin/ccmake"
# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = /Users/thomas/svn/simple-atlas-texture-generator
# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = /Users/thomas/svn/simple-atlas-texture-generator/unix_makefiles
#=============================================================================
# Targets provided globally by CMake.
# Special rule for the target edit_cache
edit_cache:
    @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..."
    "/Applications/CMake 2.8-3.app/Contents/bin/ccmake" -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : edit_cache
# Special rule for the target edit_cache
edit_cache/fast: edit_cache
.PHONY : edit_cache/fast
# Special rule for the target rebuild_cache
rebuild_cache:
    @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
    "/Applications/CMake 2.8-3.app/Contents/bin/cmake" -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : rebuild_cache
# Special rule for the target rebuild_cache
rebuild_cache/fast: rebuild_cache
.PHONY : rebuild_cache/fast
# The main all target
all: cmake_check_build_system
    $(CMAKE_COMMAND) -E cmake_progress_start /Users/thomas/svn/simple-atlas-texture-generator/unix_makefiles/CMakeFiles /Users/thomas/svn/simple-atlas-texture-generator/unix_makefiles/CMakeFiles/progress.marks
    $(MAKE) -f CMakeFiles/Makefile2 all
    $(CMAKE_COMMAND) -E cmake_progress_start /Users/thomas/svn/simple-atlas-texture-generator/unix_makefiles/CMakeFiles 0
.PHONY : all
# The main clean target
clean:
    $(MAKE) -f CMakeFiles/Makefile2 clean
.PHONY : clean
# The main clean target
clean/fast: clean
.PHONY : clean/fast
# Prepare targets for installation.
preinstall: all
    $(MAKE) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall
# Prepare targets for installation.
preinstall/fast:
    $(MAKE) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall/fast
# clear depends
depend:
    $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
.PHONY : depend
#=============================================================================
# Target rules for targets named Atlas_Texture_Generator
# Build rule for target.
Atlas_Texture_Generator: cmake_check_build_system
    $(MAKE) -f CMakeFiles/Makefile2 Atlas_Texture_Generator
.PHONY : Atlas_Texture_Generator
# fast build rule for target.
Atlas_Texture_Generator/fast:
    $(MAKE) -f CMakeFiles/Atlas_Texture_Generator.dir/build.make CMakeFiles/Atlas_Texture_Generator.dir/build
.PHONY : Atlas_Texture_Generator/fast
src/Controller.o: src/Controller.cpp.o
.PHONY : src/Controller.o
# target to build an object file
src/Controller.cpp.o:
    $(MAKE) -f CMakeFiles/Atlas_Texture_Generator.dir/build.make CMakeFiles/Atlas_Texture_Generator.dir/src/Controller.cpp.o
.PHONY : src/Controller.cpp.o
src/Controller.i: src/Controller.cpp.i
.PHONY : src/Controller.i
# target to preprocess a source file
src/Controller.cpp.i:
    $(MAKE) -f CMakeFiles/Atlas_Texture_Generator.dir/build.make CMakeFiles/Atlas_Texture_Generator.dir/src/Controller.cpp.i
.PHONY : src/Controller.cpp.i
src/Controller.s: src/Controller.cpp.s
.PHONY : src/Controller.s
# target to generate assembly for a file
src/Controller.cpp.s:
    $(MAKE) -f CMakeFiles/Atlas_Texture_Generator.dir/build.make CMakeFiles/Atlas_Texture_Generator.dir/src/Controller.cpp.s
.PHONY : src/Controller.cpp.s
src/ImageHandler.o: src/ImageHandler.cpp.o
.PHONY : src/ImageHandler.o
# target to build an object file
src/ImageHandler.cpp.o:
    $(MAKE) -f CMakeFiles/Atlas_Texture_Generator.dir/build.make CMakeFiles/Atlas_Texture_Generator.dir/src/ImageHandler.cpp.o
.PHONY : src/ImageHandler.cpp.o
src/ImageHandler.i: src/ImageHandler.cpp.i
.PHONY : src/ImageHandler.i
# target to preprocess a source file
src/ImageHandler.cpp.i:
    $(MAKE) -f CMakeFiles/Atlas_Texture_Generator.dir/build.make CMakeFiles/Atlas_Texture_Generator.dir/src/ImageHandler.cpp.i
.PHONY : src/ImageHandler.cpp.i
src/ImageHandler.s: src/ImageHandler.cpp.s
.PHONY : src/ImageHandler.s
# target to generate assembly for a file
src/ImageHandler.cpp.s:
    $(MAKE) -f CMakeFiles/Atlas_Texture_Generator.dir/build.make CMakeFiles/Atlas_Texture_Generator.dir/src/ImageHandler.cpp.s
.PHONY : src/ImageHandler.cpp.s
# Help Target
help:
    @echo "The following are some of the valid targets for this Makefile:"
    @echo "... all (the default if no target is provided)"
    @echo "... clean"
    @echo "... depend"
    @echo "... Atlas_Texture_Generator"
    @echo "... edit_cache"
    @echo "... rebuild_cache"
    @echo "... src/Controller.o"
    @echo "... src/Controller.i"
    @echo "... src/Controller.s"
    @echo "... src/ImageHandler.o"
    @echo "... src/ImageHandler.i"
    @echo "... src/ImageHandler.s"
.PHONY : help

#=============================================================================
# Special targets to cleanup operation of make.
# Special rule to run CMake to check the build system integrity.
# No rule that depends on this can have commands that come from listfiles
# because they might be regenerated.
cmake_check_build_system:
    $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
.PHONY : cmake_check_build_system

由于错误状态为error: boost/thread.hpp: No such file or directory,您的Boost_INCLUDE_DIR应该从/Users/thomas/boost_1_47_0/boost更改为/Users/thomas/boost_1_47_0

那应该能解决问题。

最新更新