On 02/10/2012 09:41 AM, Eric Noulard wrote: > 2012/2/10 Stefan Fendt <ste...@sfendt.de>: >> Hi, >> >> I'm (still) quite unsure if this isn't an FAQ (or if not maybe should be >> one), but I have read through everything I could google-up regarding >> this topic and found nothing usable... >> >> I'm writing an x-platform-project which will be compiled using different >> compilers and or under different systems... for this project I am >> required to move some files from some location (source/data) into the >> build-directory. Whileas this works under Linux/Codeblocks/GCC as well >> as Windows/Codeblocks/MinGW it doesn't for Visual Studio... Under Visual >> Studio the files always are copied to some directory-location directly >> above the actual binary-directory. >> >> I've tried using ${CMAKE_CURRENT_BINARY} and it copies the files to the >> marked position: >> >> build/ <--- copies into this directory >> build/Debug >> build/Release >> build/source >> >> After that I tried to do it with GET_TARGET_PROPERTY(... PROPERTY >> LOCATION). I then get something like this... >> >> 'build/$(Configuration)' >> >> ...which of course doesn't solve the problem, too... because the >> configuration under Visual Studio is only known after CMake-Generation >> of the solution and running the compiler... >> >> So, what is the suggested method of (if you can't avoid it) copying >> files from anywhere into the build-directory, which is as compiler >> agnostic as possible..? > > You may use CMAKE_CFG_INTDIR. > > Try: > cmake --help-variable CMAKE_CFG_INTDIR > > You'll get some example with custom command/target.
Alternatively, you might use generator expressions in custom commands/ targets like $<TARGET_FILE_DIR:...>. Both, a generator expression and CMAKE_CFG_INTDIR, are evaluated at build time, but the former is able to handle the case of targets with individual output directories, i.e. with RUNTIME_OUTPUT_DIRECTORY[_<CONFIG>] properties set. Thus, if you actually intend to copy the files to the build directories of certain targets instead of "the" build directory, generator expressions might be the more robust choice. Regards, Michael -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake