CMake没有生成Make文件

时间:2013-09-18 21:00:59

标签: c++ macos cmake

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

修改

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

CMake输出是否提供任何错误消息?不可以.CMake GUI的唯一输出是:配置完成和生成完成。

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

CMake GUI

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

CMake Files

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

我删除了所有构建文件夹并再次运行了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的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)

果然,它没有找到通向世界项目的路径。这是在我的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

1 个答案:

答案 0 :(得分: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环境变量。