使用CMake构建库时出错

时间:2014-04-28 06:41:42

标签: c++ cmake

我正在尝试为我正在处理的库执行CMake文件。 “项目”非常简单:2个类,以及Boost库的使用。

我用这种方式完成了CMakeLists:

project("TFTP Server")

cmake_minimum_required(VERSION 2.8)

set(Boost_DEFAULT_VERSION 1.53)
set(Boost_COMPONENTS "system")
include(FindBoostHelper.cmake)

include_directories(${INCLUDE_DIRECTORIES} ${Boost_INCLUDE_DIRS})

add_library(
    bin/tftp_server
    SHARED
    src/tftp_server.cpp
)

# set up the main project
set(tftp_server_SOURCES
    ${tftp_server_SOURCES}
    src/tftp_server.h
    src/tftp_server.cpp
    src/tftp_connection.h
    src/tftp_connection.cpp
    )

它找到了Boost库,然后我得到了:

> cmake .. -G "Xcode"
-- Boost version: 1.53.0
-- Found the following Boost libraries:
--   system
-- Found boost in /usr/local/include/boost-1_53, using libraries /usr/local/lib/libboost_system-clang-darwin42-mt-1_53.a
-- Configuring done
-- Generating done
CMake Error:
  Error evaluating generator expression:

    $<TARGET_FILE:bin/tftp_server>

  Expression syntax not recognized.


CMake Error:
  Error evaluating generator expression:

    $<TARGET_SONAME_FILE:bin/tftp_server>

  Expression syntax not recognized.


CMake Error:
  Error evaluating generator expression:

    $<TARGET_LINKER_FILE:bin/tftp_server>

  Expression syntax not recognized.


CMake Error:
  Error evaluating generator expression:

    $<TARGET_FILE:bin/tftp_server>

  Expression syntax not recognized.


CMake Error:
  Error evaluating generator expression:

    $<TARGET_SONAME_FILE:bin/tftp_server>

  Expression syntax not recognized.


CMake Error:
  Error evaluating generator expression:

    $<TARGET_LINKER_FILE:bin/tftp_server>

  Expression syntax not recognized.


CMake Error:
  Error evaluating generator expression:

    $<TARGET_FILE:bin/tftp_server>

  Expression syntax not recognized.


CMake Error:
  Error evaluating generator expression:

    $<TARGET_SONAME_FILE:bin/tftp_server>

  Expression syntax not recognized.


CMake Error:
  Error evaluating generator expression:

    $<TARGET_LINKER_FILE:bin/tftp_server>

  Expression syntax not recognized.


CMake Error:
  Error evaluating generator expression:

    $<TARGET_FILE:bin/tftp_server>

  Expression syntax not recognized.


CMake Error:
  Error evaluating generator expression:

    $<TARGET_SONAME_FILE:bin/tftp_server>

  Expression syntax not recognized.


CMake Error:
  Error evaluating generator expression:

    $<TARGET_LINKER_FILE:bin/tftp_server>

  Expression syntax not recognized.

没有“SHARE”选项,它会构建项目(但我没有任何库目标)。

对我做错了什么的想法? 我在OSX下使用CMake 2.8.12.2并尝试构建一个xcode项目。

谢谢!

1 个答案:

答案 0 :(得分:1)

name参数add_library用于创建共享库的名称

  

对应于逻辑目标名称,并且在项目中必须是全局唯一的。构建的库的实际文件名是基于本机平台的约定(例如lib.a或.lib)构建的。

因此它不应包含字符/

相关问题