我希望使用Visual Studio 2010 / VC10和CMake创建一个库。
Windows的树与CMake项目树不同。问题在于,CMake没有在Visual Studio中创建包含头文件和源文件的foolib。
我无法更改库的树形结构,因为它是一个旧的成熟代码,有许多库共享多个包含文件。
CMakeLists.txt只有一个数字进行解释。
CMakeLists01.txt
Windows的树与CMake项目树不同。问题在于,CMake没有在Visual Studio中创建包含头文件和源文件的foolib。
我无法更改库的树形结构,因为它是一个旧的成熟代码,有许多库共享多个包含文件。
root
|-'includes
| '-foo.h
|-'src
| '-libprojects
| | '-foolib
| | | '-bin
| | | '-project
| | | | '-mak100
| | | | '-CMakeLists01.txt
| | | '-src
| | | | '-CMakeLists02.txt
| | | | '-foo.cxx
CMakeLists.txt只有一个数字进行解释。
CMakeLists01.txt
cmake_minimum_required (VERSION 2.8)
cmake_policy (SET CMP0015 NEW)
project (foolib)
set (CMAKE_BUILD_TYPE Debug)
include_directories ("${PROJECT_SOURCE_DIR}/../../../../include")
# This dosen't works and CMake can't find the CMakeLists02.txt ???
add_subdirectory("${PROJECT_SOURCE_DIR}/../src")
CMakeLists02.txt
# CMakeLists02.txt
set (QueryHeader
"./../../../../include/foo.h")
set (QuerySources
"foo.cxx")
问题:如何使用add_subdirectory()将CMakeLists02.txt包含到CMakeLists01.txt中
以下是一个批处理文件,如果有人想要测试它
#doCMake.cmd
@echo off
call "c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tool\vsvars32.bat"
mkdir mak100
cd mak100
cmake -G "Visual Studio 10" ..
cd ..
pause
CMakeLists01.txt
放入foolib
文件夹中?然后我认为您甚至不需要CMakeLists02.txt
。执行类似于add_library(foo src/foo.cxx)
的操作是完全可以的。 - Florian