[CMake] Add configuration support to include_directories()

Bill Hoffman bill.hoffman at kitware.com
Tue Dec 23 11:23:10 EST 2008


Robert Dailey wrote:
> Why I need this feature is irrelevant, the important thing is that I 
> need the feature. I know a couple of other people who've posted on 
> various other mailing lists that have asked for this as well.
> 
> However, if you must know, I need this mainly because of wxWidgets. 
> wxWidgets has a setup.h file that is located in a directory specific to 
> the configuration in which wxWidgets was built. For the respective 
> configuration, I need to tell the compiler to use a different setup.h, 
> which means I need to specify a different include directory per 
> configuration. There's other ways to solve this problem other than using 
> include directories, but this is the most trivial and simplified way.
> 

I still don't see why CMAKE_CFG_INTDIR would not work???

I just tried this:

project(foo)
cmake_minimum_required(VERSION 2.6)
include_directories(${foo_SOURCE_DIR}/${CMAKE_CFG_INTDIR})
add_library(foo foo.cxx)


In VS, the build line is this:

Command Lines      Creating temporary file 
"c:\hoffman\foo\src\b\foo.dir\Debug\RSP00000336725368.rsp" with contents
[
/Od /I "C:\hoffman\foo\src\Debug" /D "WIN32" /D "_WINDOWS" /D "_DEBUG" 
/D "CMAKE_INTDIR=\"Debug\"" /D "_MBCS" /FD /EHsc /RTC1 /MDd 
/Fo"foo.dir\Debug\\" /Fd"C:/hoffman/foo/src/b/Debug/foo.pdb" /W3 /c /Zi 
/TP   /Zm1000

..\foo.cxx
]

If I do the same project with Unix Makefiles I get this:

[100%] Building CXX object CMakeFiles/foo.dir/foo.cxx.obj
"C:/Program Files/Microsoft Visual Studio 9.0/VC/bin/cl.exe"   /nologo 
/DWIN32 /D_WINDOWS /W3 /Zm1000 /EHsc /GR /D_DEBUG /MDd /Zi /Ob0 /Od 
/RTC1 -IC:/hoffman/foo/src/.    /TP /FoCMakeFiles/foo.dir/foo.cxx.obj 
/FdC:/hoffman/foo/src/b2/foo.pdb -c C:/hoffman/foo/src/foo.cxx
foo.cxx


So the -I will work for both VS IDE and Unix makefiles correctly.

-Bill




More information about the CMake mailing list