[CMake] adding files to a custom target

Timenkov Yuri ytimenkov at gmail.com
Sat Oct 4 00:50:42 EDT 2008


On Thu, Oct 2, 2008 at 6:41 PM, Jesse Corrington <jesse.corrington at gmail.com
> wrote:

> Ok, I got a little further, but still not exactly what I wanted. I had some
> sloppy quotes after doing a poor job of converting my old post build step
> into this new way of doing things. It is now partially functional. I can
> compile the script if I right click on the project and do build. I have two
> problems. One is that the script file is still not listed under the project
> in visual studio. The other is that when I rebuild the whole solution, this
> project doesn't get built. I have explicitly select to build it. Below is my
> new code. Thanks for all the help.
> ADD_CUSTOM_COMMAND(
> OUTPUT ${binDirNative}\\main.js.bin
> COMMAND ${COMPILE_SCRIPT} ${binDirNative}\\main.js -o
> ${binDirNative}\\main.js.bin
>  DEPENDS ${binDirNative}\\main.js VERBATIM )
>
 Why not using ${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_CURRENT_BINARY_DIR}?
Also, you should use native paths here (that is forward slashes).
Also, you may use MAIN_DEPENDENCY in one of these commands, cmake will put
this file directly into project (see help for more information).

> ADD_CUSTOM_TARGET(
>  Test DEPENDS ${binDirNative}\\main.js.bin VERBATIM )
>
>
>
> On Thu, Oct 2, 2008 at 7:15 AM, Jesse Corrington <
> jesse.corrington at gmail.com> wrote:
>
>> I have been playing around with this, and can't seem to figure it out. My
>> project gets created, but it doesn't compile the script and in visual studio
>> the script is not listed under the project in the solution explorer. There
>> is a .rule file, which almost points to my script, but has a strange path.
>> It's path ends up as CMAKE_SOURCE_PATH/full path to script/.rule, which is
>> bad because it has c:\ in it twice. Any ideas what I'm doing wrong. If done
>> correctly, will I be able to see the scripts listed in visual studio for
>> editing inside the IDE? Below is my source. Thanks
>> ADD_CUSTOM_COMMAND(
>> OUTPUT "\"${binDirNative}\\main.js.bin\""
>> COMMAND ${COMPILE_SCRIPT} "-o \"${binDirNative}\\main.js.bin\""
>>  DEPENDS "\"${binDirNative}\\main.js\"" )
>> ADD_CUSTOM_TARGET(
>>  Test DEPENDS "\"${binDirNative}\\mo\\main.sjs.bin\"" VERBATIM )
>>
>> On Wed, Sep 24, 2008 at 7:48 AM, Timenkov Yuri <ytimenkov at gmail.com>wrote:
>>
>>> Use add_custom_command to compile your files. This one accepts source and
>>> destination file names for proper dependency handling.
>>> Next, use add_custom_target command with dependencies on
>>> add_custom_target's output.
>>> For example:
>>> add_custom_command(OUTPUT myscript.compiled
>>>  COMMAND compile_script myscript.src
>>>  DEPENDS myscript.src)
>>> add_custom_target(BuildScripts DEPENDS myscript.compiled VERBATIM)
>>>
>>> Something like this. See documentation for both commands. Of course, you
>>> can use single custom target for all your scripts, and you can write macro
>>> to wrap script's sources with add_custom_command.
>>>
>>>
>>> On Tue, Sep 23, 2008 at 1:43 AM, Jesse Corrington <
>>> jesse.corrington at gmail.com> wrote:
>>>
>>>> I'm trying to create a custom target for compiling scripts in MSVC, but
>>>> I can't seem to find anyway to add the files to the project when using
>>>> ADD_CUSTOM_TARGET. I just want to be able to add files to a custom target
>>>> project and then specify a post build step to compile the scripts with our
>>>> internal script compiler. The current hack I have in place is to use
>>>> ADD_EXECUTABLE and just use a dummy cpp file with an empty main. I figure
>>>> there must be a better way than this.
>>>>
>>>> _______________________________________________
>>>> CMake mailing list
>>>> CMake at cmake.org
>>>> http://www.cmake.org/mailman/listinfo/cmake
>>>>
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20081004/faa536b9/attachment.htm>


More information about the CMake mailing list