1

好的。我能够从 CMake GUI 成功配置和生成,它似乎在我的构建文件夹中生成了一堆文件。但它不是创建 Make 文件。有任何想法吗?

编辑:

我所做的只是在 Eclipse 中创建一个工作区,其中包含一个主项目和一个静态库项目。这是一个简单的 HelloWorld 应用程序,其中主项目生成输出的“Hello”部分,静态库生成输出的“World”部分。

CMake 输出是否给出任何错误消息?不,CMake GUI 的唯一输出是:配置完成和生成完成。

是否选择了正确的发电机?你使用什么设置?我是 CMake 的新手,所以我不完全确定你在问什么,但我可以给你一个屏幕截图:

CMake 图形用户界面

上面的屏幕截图在后台显示了 Eclipse 项目结构,在前台显示了带有配置的 CMake GUI。下面的屏幕截图显示了生成的文件。

CMake 文件

-------------------------------------------------- ---更多信息--------------------------------------------- --

我删除了所有构建文件夹并再次运行 cmake。这次我收到以下错误输出:

-- The C compiler identification is Clang 4.2.0
-- The CXX compiler identification is Clang 4.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
World_INCLUDE_DIRS
   used as include directory in directory /Users/pdl/Development/Patricia's New World Sandbox/HelloWorldCMake/Hello/src
World_LIBRARIES
   linked by target "hello" in directory /Users/pdl/Development/Patricia's New World Sandbox/HelloWorldCMake/Hello/src

-- Configuring incomplete, errors occurred!

这是我的 FindWorld.cmake 文件的内容:

find_path(World_INCLUDE_DIRS World.h /usr/include "$ENV{WORLD_ROOT}/src")

find_library(World_LIBRARIES libWorld.a /usr/lib "$ENV{WORLD_ROOT}/Debug")

set(World_FOUND TRUE)

if (NOT World_INCLUDE_DIRS)
  set(World_FOUND FALSE)
endif (NOT World_INCLUDE_DIRS)

if (NOT World_LIBRARIES)
  set(World_FOUND FALSE)
endif (NOT World_LIBRARIES)

WORLD_ROOT 在我的 Eclipse Hello 项目中设置为环境变量,目录设置为“/Users/pdl/Development/Patricia's New World Sandbox/HelloWorldCMake/World”。 啊哈! 会不会是 CMake 不知道我的 Eclipse 环境变量是什么?

这是我的 Hello CMakeLists.txt 文件的内容:

cmake_minimum_required(VERSION 2.8.6)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}")
find_package(World REQUIRED)
include_directories("${World_INCLUDE_DIRS}")
add_executable(hello Hello.cpp)
target_link_libraries(hello ${World_LIBRARIES})

这是我的 World CMakeLists.txt 文件的内容:

cmake_minimum_required(VERSION 2.8.6)
project(World)
include_directories("${CMAKE_SOURCE_DIR}")
add_library(namer World.cpp World.h)

果然,它没有找到通往 World 项目的路径。这是在我的 CMakeCache.txt 文件中:

//Value Computed by CMake
Project_BINARY_DIR:STATIC=/Users/pdl/Development/Patricia's New World Sandbox/hello_world_build

//Value Computed by CMake
Project_SOURCE_DIR:STATIC=/Users/pdl/Development/Patricia's New World Sandbox/HelloWorldCMake/Hello/src

//Path to a file.
World_INCLUDE_DIRS:PATH=World_INCLUDE_DIRS-NOTFOUND

//Path to a library.
World_LIBRARIES:FILEPATH=World_LIBRARIES-NOTFOUND
4

1 回答 1

2

我的第一个问题是我不小心在不同的构建目录中运行了 make。我删除了所有构建目录并再次尝试。然后我收到以下错误:

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
World_INCLUDE_DIRS 
    used as include directory in directory /Users/pdl/Development/Patricia's New World Sandbox/HelloWorldCMake/Hello/src
World_LIBRARIES 
    linked by target "hello" in directory /Users/pdl/Development/Patricia's New World Sandbox/HelloWorldCMake/Hello/src

-- Configuring incomplete, errors occurred!

考虑到这个错误,我突然想到 CMake 当然不知道我的 Eclipse 环境变量。

于 2013-09-24T16:28:51.240 回答