我正在尝试创建一个CMAKE项目,其中包括其他第三方项目(OGRE3D、CEGUI等)和我的特定项目(或项目)。更具体地说,我有这样一个目录树:
+ myMasterProject
-----+ OGRE3D_DEPENDENCIES
-----+ OGRE3D_CORE
-----+ CEGUI
-----+ myProject如果我按正确的顺序手动构建库,一切都可以正常工作(甚至myProject)。每个项目都有自己的CMakeLists.txt文件,它们几乎都使用find_package函数。例如,CEGUI需要为OGRE呈现器查找OGRE,如果在find_package(OGRE REQUIRED)中找不到它,则返回一个错误。myProject需要食人魔和CEGUI。
一个重要的细节是,我不会修改子项目的CMakeLists.txt文件,因为我使用mercurial或svn将它们作为子项目导入(取决于它们各自的CVS),而且我更喜欢定期更新它们,而不进行修改(我没有足够的专家来修改它们)。
有谁知道如何达到这个结果吗?我应该在我的OGRE_FOUND文件中手动定义"Boost_FOUND“、”Boost_FOUND“等所有变量以及它们各自的子变量("OGRE_LIB”、"OGRE_H_PATH“等),还是有一种”更聪明“或”更干净“的方法?无论如何,必须以某种方式定义这些变量,因为它们是项目所需要的.
目前,myMasterProject/CMakeLists.txt只包含:
project(myMasterProject)
add_subdirectory("OGRE3D_DEPENDENCIES")
add_subdirectory("OGRE3D_CORE")
add_subdirectory("CEGUI")
add_subdirectory("myProject")下面是我得到的CMAKE输出:
-- Configuring OGRE 1.8.2
-- Detected g++ 4.6.1
-- Enabling GCC visibility flags
-- Search path: /home/me/myMasterProject/build/OGRE3D_CORE/Dependencies;/home/me/myMasterProject/sources/OGRE3D_CORE/Dependencies;/home/me/myMasterProject/build/OGRE3D_CORE/../Dependencies;/home/me/myMasterProject/sources/OGRE3D_CORE/../Dependencies
-- Looking for ZLIB...
-- Found ZLIB: optimized;zlib;debug;zlib
-- Looking for ZZip...
-- Found ZZip: optimized;zziplib;debug;zziplib
-- Looking for FreeImage...
-- checking for module 'freeimage'
-- package 'freeimage' not found
-- Found FreeImage: optimized;FreeImage;debug;FreeImage
-- Looking for FREETYPE...
-- CMAKE_PREFIX_PATH: /home/me/myMasterProject/build/OGRE3D_CORE/Dependencies;/home/me/myMasterProject/sources/OGRE3D_CORE/Dependencies;/home/me/myMasterProject/build/OGRE3D_CORE/../Dependencies;/home/me/myMasterProject/sources/OGRE3D_CORE/../Dependencies;/usr/local;/usr/lib/x86_64-linux-gnu
-- CMAKE_PREFIX_PATH: /home/me/myMasterProject/build/OGRE3D_CORE/Dependencies;/home/me/myMasterProject/sources/OGRE3D_CORE/Dependencies;/home/me/myMasterProject/build/OGRE3D_CORE/../Dependencies;/home/me/myMasterProject/sources/OGRE3D_CORE/../Dependencies;/usr/local;/usr/lib/x86_64-linux-gnu
-- Found FREETYPE: optimized;freetype;debug;freetype
-- Looking for Cg...
-- checking for module 'Cg'
-- package 'Cg' not found
-- Found Cg: optimized;/usr/lib/libCg.so;debug;/usr/lib/libCg.so
-- Looking for POCO...
-- checking for module 'POCO'
-- package 'POCO' not found
-- Could not locate POCO
-- Looking for TBB...
-- Could not locate TBB
-- Looking for GLSL_Optimizer...
-- checking for module 'GLSL_Optimizer'
-- package 'GLSL_Optimizer' not found
-- Could not locate GLSL_Optimizer
-- Looking for HLSL2GLSL...
-- checking for module 'HLSL2GLSL'
-- package 'HLSL2GLSL' not found
-- Could not locate HLSL2GLSL
-- Looking for OIS...
-- Found OIS: optimized;OIS;debug;OIS
-- Looking for Softimage...
-- Could not locate Softimage
-- Looking for CppUnit...
-- Found CppUnit: optimized;/usr/lib/libcppunit.so;debug;/usr/lib/libcppunit.so
--
-----------------------------------------------------------------------------
-- The following external packages were located on your system.
-- This installation will have the extra features provided by these packages.
+ zlib
+ zziplib
+ freeimage
+ freetype
+ X11
+ Xt
+ Xaw
+ OpenGL
+ OpenGL ES 2.x
+ cg
+ boost
+ boost-thread
+ boost-date_time
+ OIS
+ Doxygen
+ CppUnit
-----------------------------------------------------------------------------
-- The following OPTIONAL packages could NOT be located on your system.
-- Consider installing them to enable more features from this software.
+ OpenGL ES 1.x: Support for the OpenGL ES 1.x render system (DEPRECATED) <http://www.khronos.org/opengles/>
+ POCO: POCO framework <http://pocoproject.org/>
+ tbb: Threading Building Blocks <http://www.threadingbuildingblocks.org/>
+ GLSL Optimizer: GLSL Optimizer <http://github.com/aras-p/glsl-optimizer/>
+ HLSL2GLSL: HLSL2GLSL <http://hlsl2glslfork.googlecode.com/>
+ Softimage: Softimage SDK needed for building XSIExporter <FALSE>
-----------------------------------------------------------------------------
--
----------------------------------------------------------------------------
FEATURE SUMMARY
----------------------------------------------------------------------------
Building components:
+ Paging
+ Property
+ Terrain
+ RTShader System
+ RTShader System Core Shaders
+ RTShader System Extensions Shaders
Building plugins:
+ BSP scene manager
+ Cg program manager
+ Octree scene manager
+ Portal connected zone scene manager
+ Particle FX
Building rendersystems:
+ OpenGL
Building executables:
+ Samples
+ Tools
Building core features:
+ DDS image codec
+ FreeImage codec
+ ZIP archives
Build type: dynamic
Threading support: background (boost)
Use double precision: disabled
Allocator type: nedmalloc (pooling)
STL containers use allocator: enabled
Strings use allocator: disabled
Memory tracker (debug): disabled
Memory tracker (release): disabled
Use new script compilers: enabled
Use Boost: enabled
----------------------------------------------------------------------------
OGRE_LIB = OGRE_LIB-NOTFOUND
OGRE_H_PATH = OGRE_H_PATH-NOTFOUND
OGRE_H_BUILD_SETTINGS_PATH = OGRE_H_BUILD_SETTINGS_PATH-NOTFOUND
CMAKE_MODULE_PATH = /home/me/myMasterProject/sources/CEGUI/cmake
-- Could NOT find PCRE (missing: PCRE_LIB PCRE_H_PATH)
-- Could NOT find MINIZIP (missing: MINIZIP_LIB MINIZIP_H_PATH)
-- Could NOT find GLFW (missing: GLFW_LIB GLFW_H_PATH)
-- Could NOT find DIRECTXSDK (missing: DIRECTXSDK_LIB_PATH DIRECTXSDK_H_PATH DIRECTXSDK_MAX_D3D)
-- Could NOT find D3DX11EFFECTS (missing: D3DX11EFFECTS_LIB D3DX11EFFECTS_H_PATH)
-- Could NOT find IRRLICHT (missing: IRRLICHT_LIB IRRLICHT_H_PATH)
-- Could NOT find OGRE (missing: OGRE_LIB OGRE_H_PATH OGRE_H_BUILD_SETTINGS_PATH)
-- Could NOT find DIRECTFB (missing: DIRECTFB_LIB DIRECTFB_H_PATH)
-- Could NOT find OPENGLES (missing: OPENGLES_LIB OPENGLES_H_PATH)
-- Could NOT find XERCESC (missing: XERCESC_LIB XERCESC_H_PATH)
-- Could NOT find LibXml2 (missing: LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR)
-- Could NOT find TINYXML (missing: TINYXML_LIB TINYXML_H_PATH)
-- Could NOT find RAPIDXML (missing: RAPIDXML_H_PATH)
-- Could NOT find IL (missing: IL_LIB IL_H_PATH)
-- Could NOT find ILU (missing: ILU_LIB)
-- Could NOT find SILLY (missing: SILLY_LIB SILLY_H_PATH)
-- Could NOT find CORONA (missing: CORONA_LIB CORONA_H_PATH)
-- Could NOT find PVRTOOLS (missing: PVRTOOLS_LIB PVRTOOLS_H_PATH)
-- Could NOT find LUA51 (missing: LUA_LIB LUA_H_PATH)
-- Could NOT find TOLUAPP (missing: TOLUAPP_LIB TOLUAPP_H_PATH)
-- Could NOT find Boost
CMake Error at /usr/share/cmake-2.8/Modules/CPack.cmake:338 (message):
CPack package description file:
"/home/me/myMasterProject/sources/doc/README" could not be
found.
Call Stack (most recent call first):
/usr/share/cmake-2.8/Modules/CPack.cmake:342 (cpack_check_file_exists)
CEGUI/CMakeLists.txt:574 (include)
CMake Error at /usr/share/cmake-2.8/Modules/CPack.cmake:338 (message):
CPack license resource file:
"/home/me/myMasterProject/sources/doc/COPYING" could not be
found.
Call Stack (most recent call first):
/usr/share/cmake-2.8/Modules/CPack.cmake:343 (cpack_check_file_exists)
CEGUI/CMakeLists.txt:574 (include)
CMAKE_MODULE_PATH =/home/me/myMasterProject/sources/myProject/cmake
CEGUI LIBRARY:
CEGUI OGRE LIBRARY:
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 2.8)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring incomplete, errors occurred!您可以注意到,当构建OGRE时,一切看起来都很好,但是之后,当CEGUI正在构建时,它不识别OGRE和相关变量。myProject..。
提前谢谢你的回答,干杯
免责声明:我几乎是CMAKE的新手。此外,我知道类似的问题已经张贴在这里,但我没有找到一个有效的答案.
发布于 2014-01-17 09:54:15
在主项目中自己为find脚本设置变量是一种有效的方法。从某种意义上说,它有点脆弱,因为您依赖于各自的项目而不更改它们的查找脚本,但否则这似乎是非常好的。
另一种选择可能是使用CMake的ExternalProject功能。使用这种方法,它们不是构建来自主项目的所有依赖项,而是在CMake配置时生成的。这里的优点是,构建依赖关系时就好像您将直接从命令行构建它们一样,因此避免了问题中描述的影响。它也不依赖于依赖项的任何构建系统内部。
https://stackoverflow.com/questions/21141406
复制相似问题