Copying source file required by target

Mateusz Loskot via Boost-build <[email protected]>
Newsgroups gmane.comp.lib.boost.build
Message-ID <CABUeae8d4ZWBuBawJTZU1-nUv4Z55Vq2-E-mRMSg6fTbAH1Q9g@mail.gmail.com>
Hi,

I'm trying to replicate this CMake'ism for BBv2

f(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/mwe.cpp)
  configure_file(
    ${CMAKE_CURRENT_SOURCE_DIR}/mwe.cpp.in
    ${CMAKE_CURRENT_SOURCE_DIR}/mwe.cpp
    COPYONLY)
endif()

I'm trying to achieve that with the make rule and simple actions:

make mwe.cpp : mwe.cpp.in : @copy_mwe_if_not_exists ;
actions copy_mwe_if_not_exists { cp $(>) $(<) }
exe mwe : mwe.cpp :  ;

Basically, this works, but there is one major issue"
- it creates source file in bin/mwe.cpp.
How can I force it to create mwe.cpp in the same directory as mwe.cpp.in?

I've tried to hack it modifying target path using the variables
expansion, but without luck.

I have also tried to follow the BBv2 generate example based on
file-target and common.copy action:
https://github.com/boostorg/build/tree/develop/example/generate
But constructing a target seems like an overkill for my purpose.
And, the rule (or common.copy) also creates file in `bin` directory.


BTW, I am aware the `copy_mwe_if_not_exists` is incomplete regarding its name:
- it will have to use cp or copy depending on OS
- it will have to check if file exists

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net
_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.