CMake include and source pathes are not the same as the Windows Dirctory pathes

I want to create a libray with Visual Studion 2010 / VC10 and CMake.

The tree of windows is not the same than the CMake project tree. The Problem is that CMake doesn’t creates the foolib with header and soures files in Visual Studio.

I can’t change the tree of the libray because it’s an old grown code with a lot of librays that share several include files.

root
|-'includes
|  '-foo.h
|-'src  
|  '-libprojects
|  | '-foolib
|  | | '-bin
|  | | '-project
|  | | | '-mak100
|  | | | '-CMakeLists01.txt
|  | | '-src
|  | | | '-CMakeLists02.txt
|  | | | '-foo.cxx

The CMakeLists.txt only has a number to explain.

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")

This is a batch file if somebody test it

#doCMake.cmd
@echo off
call "c:Program Files (x86)Microsoft Visual Studio 10.0Common7Toolvsvars32.bat"
mkdir mak100
cd mak100
cmake -G "Visual Studio 10" ..
cd ..
pause


Source: c#

Leave a Reply