2

現在、CMakeを使用してダイナミックライブラリを構築していますが、現在直面している問題は、ライブラリのファイルの追加に関連しています。私のプロジェクトの構造は次のとおりです。

----src
     |
  thrid_party---boost_1_50_0----boost
     |       ---   |        ----libs
     |       ---   |        ---- | --- filesystem
     |       ---   |        ---- | ---   |  ------src

私のCMakeLists.txtファイルはsrcディレクトリにあり、ファイルの内容は次のとおりです。

cmake_minimum_required( VERSION 2.6 )
project (temp)
#build the third party library
include_directories( ${irisimp_SOURCE_DIR}/../third_party/boost_1_50_0)
set (boost_path 
${irisimp_SOURCE_DIR}/../third_party/boost_1_50_0/libs)

set (BOOST_LIST
${boost_path}/filesystem/src/codecvt_error_category.cpp 
${boost_path}/filesystem/src/operations.cpp 
${boost_path}/filesystem/src/path.cpp 
${boost_path}/filesystem/src/path_traits.cpp 
${boost_path}/filesystem/src/portability.cpp 
${boost_path}/filesystem/src/unique_path.cpp 
${boost_path}/filesystem/src/utf8_codecvt_facet.cpp 
${boost_path}/filesystem/src/windows_file_codecvt.cpp 
${boost_path}/filesystem/src/windows_file_codecvt.hpp 
)
add_library ( boost SHARED ${BOOST_LIST})

このスクリプトの実行に問題はありませんが、出力のVisualStudio10プロジェクトには ${boost_path}/filesystem/srcフォルダー内のすべてのソースファイルが含まれていません。実際、windows_file_codecvt.cppのみが保持されます。したがって、このプロジェクトのコンパイルは失敗します。Visual Studio 10プロジェクトに、CMakeLists.txtで指示されているすべてのソースファイルを含めることができるようにするには、どうすればよいか疑問に思いました。ありがとうございます。

4

1 に答える 1

2

次のように、パスの間にセミコロンを入れてみてください。

set (BOOST_LIST
  ${boost_path}/filesystem/src/codecvt_error_category.cpp;
  ${boost_path}/filesystem/src/operations.cpp;
  ${boost_path}/filesystem/src/path.cpp;
  ${boost_path}/filesystem/src/path_traits.cpp; 
  ${boost_path}/filesystem/src/portability.cpp;
  ${boost_path}/filesystem/src/unique_path.cpp;
  ${boost_path}/filesystem/src/utf8_codecvt_facet.cpp; 
  ${boost_path}/filesystem/src/windows_file_codecvt.cpp; 
  ${boost_path}/filesystem/src/windows_file_codecvt.hpp;
)

これが機能しない場合は、試してください

add_library(boost SHARED
  ${boost_path}/filesystem/src/codecvt_error_category.cpp
  ${boost_path}/filesystem/src/operations.cpp 
  ${boost_path}/filesystem/src/path.cpp 
  ${boost_path}/filesystem/src/path_traits.cpp
  ...
  ${boost_path}/filesystem/src/windows_file_codecvt.hpp)

これは、問題がどこにあるかをデバッグするのに役立つ場合があります。

于 2012-09-11T21:44:49.313 に答える