[CMake] Add configuration support to include_directories()

Robert Dailey rcdailey at gmail.com
Tue Dec 23 11:33:49 EST 2008


On Tue, Dec 23, 2008 at 10:23 AM, Bill Hoffman <bill.hoffman at kitware.com>wrote:

> 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.


Hey, you're right! This would work, however I failed to appropriately
describe the problem so I've mislead you. I do apologize for this.
Basically, the include directories look like this:

For debug: C:\foo\bar-d
For release: C:\foo\bar

Note that the text "Debug" or "Release" is not used in the include path, so
simply using CFG_INTDIR would not work I don't think (Unless I'm missing
something again). This is why in CMake I need to do something like this:

if( debug )
    include_directories( C:\foo\bar-d )
else()
    include_directories( C:\foo\bar )
endif()

Thanks again to everyone for their continued help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20081223/4a9a2e47/attachment.htm>


More information about the CMake mailing list