[CMake] unexpected behavior with TARGET_FILE_DIR and Visual Studio 2010
Michael Ellery
mellery451 at gmail.com
Fri Dec 5 13:31:47 EST 2014
Hi cmake-users,
I have the following setup:
CMAKE: 3.0.2
Visual Studio 2010
In one of my cmake files, I’m trying to create a preprocessor definition based on the TARGET_FILE_DIR of a different target … so I’m trying this:
target_compile_definitions(my_target_B PUBLIC
-DTARGET_A_DIR="$<TARGET_FILE_DIR:my_target_A>"
)
When I run this for my visual studio build (2010), I get the following settings created in the project file:
test/my_target_B.vcxproj:95: <PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;_DEBUG;TARGET_A_DIR="Y:/work/some_lib/bld_win/src/my_target_A/Debug";CMAKE_INTDIR="Debug";%(PreprocessorDefinitions)</PreprocessorDefinitions>
test/my_target_B.vcxproj:99: <PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;_DEBUG;TARGET_A_DIR=\"Y:/work/some_lib/bld_win/src/my_target_A/Debug\";CMAKE_INTDIR=\"Debug\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
test/my_target_B.vcxproj:392: <PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;TARGET_A_DIR="Y:/work/some_lib/bld_win/src/my_target_A/Debug";CMAKE_INTDIR="Release";%(PreprocessorDefinitions)</PreprocessorDefinitions>
test/my_target_B.vcxproj:396: <PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;TARGET_A_DIR=\"Y:/work/some_lib/bld_win/src/my_target_A/Debug\";CMAKE_INTDIR=\"Release\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
test/my_target_B.vcxproj:689: <PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;TARGET_A_DIR="Y:/work/some_lib/bld_win/src/my_target_A/Debug";CMAKE_INTDIR="MinSizeRel";%(PreprocessorDefinitions)</PreprocessorDefinitions>
test/my_target_B.vcxproj:693: <PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;TARGET_A_DIR=\"Y:/work/some_lib/bld_win/src/my_target_A/Debug\";CMAKE_INTDIR=\"MinSizeRel\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
test/my_target_B.vcxproj:986: <PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;TARGET_A_DIR="Y:/work/some_lib/bld_win/src/my_target_A/Debug";CMAKE_INTDIR="RelWithDebInfo";%(PreprocessorDefinitions)</PreprocessorDefinitions>
test/my_target_B.vcxproj:990: <PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;TARGET_A_DIR=\"Y:/work/some_lib/bld_win/src/my_target_A/Debug\";CMAKE_INTDIR=\"RelWithDebInfo\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
in other words, it looks like the generator expression is only being evaluated once (as Debug) and then used for ALL of the build configs in the visual studio project. This isn’t exactly what I want since I need the actual output dir for each config to be the correct one for that build type.
This same thing works fine on my linux/makefile build since the output dir is the same for all builds.
Can anyone offer advice? Is this how the visual studio generator works or is this possibly a bug in CMake?
Thanks,
Mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://public.kitware.com/pipermail/cmake/attachments/20141205/c44529de/attachment.sig>
More information about the CMake
mailing list