Re: [CMake] download file, modify, add test from it

2015-11-23 Thread David Cole via CMake
You're welcome.

I see you have ${file}-2.h5m in only one place, though... Is that a
leftover, or is the other reference to -2 just omitted from your example...?


Cheers,
David C.



On Monday, November 23, 2015, Nico Schlömer 
wrote:

> Thanks David for your explanations. I've now reached a good solution:
>
> Fetch the data:
> ```
> INCLUDE(ExternalData)
> set(
>   ExternalData_URL_TEMPLATES
>   "https://downloads.sourceforge.net/project/noshdata/%(algo)/%(hash)"
>   )
> foreach(file ${input_files})
>   ExternalData_Expand_Arguments(
> noshTestFetchData
> OUT_DATA DATA{${CMAKE_SOURCE_DIR}/test/data/${file}.e}
> )
> endforeach()
> ExternalData_Add_Target(noshTestFetchData)
> ```
> Define conversion commands:
> ```
> foreach(file ${input_files})
>   LIST(APPEND FILES2 ${file}-2.h5m)
>   add_custom_command(
> DEPENDS ${file}.e
> COMMAND convert ${file}.e ${file}.h5m
> OUTPUT ${file}.h5m
> )
> endforeach()
> ```
> Add a custom target with ALL:
> ```
> add_custom_target(split2 ALL
>   SOURCES ${FILES2}
>   )
> ```
> Adding the output files to the SOURCES makes the target do what's its
> supposed to do.
>
> Cheers,
> Nico
>
> On Sun, Nov 22, 2015 at 11:59 PM David Cole  > wrote:
>
>> You don't. You just assume all relevant targets have already been built
>> by the time you run the tests... There's no such thing as a test from
>> an add_test call depending on a target.
>>
>> There **is** a dependency, of course, if you are using one of the build
>> products in your test, but it's assumed that everything is already built at
>> test time.
>>
>> There is not yet a notion of connecting certain tests to certain build
>> targets.
>>
>> So, for example, there is no way to re-run only the tests affected by
>> things which have changed since the last build, because there is no
>> connection between targets and tests.
>>
>> People have artificially created such connections using test labels, and
>> running subsets of tests by label, but there is no official dependency from
>> tests back to targets.
>>
>>
>> D
>>
>>
>>
>> On Sunday, November 22, 2015, Nico Schlömer > > wrote:
>>
>>> Aha, this was a misunderstanding of me then. Thanks!
>>> How do I make a test depend on a target then?
>>>
>>> Cheers,
>>> Nico
>>>
>>>
>>> On Sun, Nov 22, 2015 at 8:58 PM David Cole  wrote:
>>>
 The DEPENDS property of a test is meant to ensure test running order in
 the case of parallel testing... It simply ensures that one test runs before
 another. It is not connected to the build system at all. It's different
 than target dependencies.


 D



 On Sunday, November 22, 2015, David Cole  wrote:

> What do you mean by "depend" in this case? All libs and exes should be
> built during a "make" or "make all" or "make install" ... And all that
> should be done before any tests get run.
>
> Simply typing "ctest" to execute all the tests never does any
> building. The assumed workflow is that you build stuff first and then run
> the tests.
>
> If you want, you can add a custom target that runs a test, and make
> that custom target depend on any other targets, but ctest still won't know
> about it. Only "make custom_test_target" will...
>
>
> D
>
>
>
> On Sunday, November 22, 2015, Nico Schlömer 
> wrote:
>
>> Thanks for the hints!
>> I'm almost there now, the only thing missing is to have my test
>> depend on the custom_target. This
>> ```
>> SET_TESTS_PROPERTIES(testname PROPERTIES DEPENDS convert)
>> ```
>> doesn't do the trick: The target `convert` isn't executed before
>> `ctest`.
>>
>> Any hints?
>>
>> Cheers,
>> Nico
>>
>>
>> On Sun, Nov 22, 2015 at 3:18 AM David Cole  wrote:
>>
>>> Did you try using full path names for the add_custom_command file
>>> names?
>>>
>>> And the NAME/COMMAND form of the add_test command?
>>>
>>> Also, I've always found custom commands to work best when they're
>>> associated with a target. And if it was part of a target you could make 
>>> the
>>> target depend on the external data target with add_dependencies if
>>> necessary.
>>>
>>>
>>> HTH,
>>> David C.
>>>
>>>
>>> On Saturday, November 21, 2015, Nico Schlömer <
>>> nico.schloe...@gmail.com> wrote:
>>>
 Hi everyone,

 I would like to create a CMake test that does the following:
  * Download a file from an external resource
  * Do something with the file
  * compile an executable myTest
  * execute myTest outputfile

 Using ExternalData for 

Re: [CMake] download file, modify, add test from it

2015-11-23 Thread Nico Schlömer
>  Is that a leftover, or is the other reference to -2 just omitted from
your example...?

That's a leftover indeed. :)

--Nico

On Mon, Nov 23, 2015 at 12:45 PM David Cole  wrote:

> You're welcome.
>
> I see you have ${file}-2.h5m in only one place, though... Is that a
> leftover, or is the other reference to -2 just omitted from your example...?
>
>
> Cheers,
> David C.
>
>
>
> On Monday, November 23, 2015, Nico Schlömer 
> wrote:
>
>> Thanks David for your explanations. I've now reached a good solution:
>>
>> Fetch the data:
>> ```
>> INCLUDE(ExternalData)
>> set(
>>   ExternalData_URL_TEMPLATES
>>   "https://downloads.sourceforge.net/project/noshdata/%(algo)/%(hash)"
>>   )
>> foreach(file ${input_files})
>>   ExternalData_Expand_Arguments(
>> noshTestFetchData
>> OUT_DATA DATA{${CMAKE_SOURCE_DIR}/test/data/${file}.e}
>> )
>> endforeach()
>> ExternalData_Add_Target(noshTestFetchData)
>> ```
>> Define conversion commands:
>> ```
>> foreach(file ${input_files})
>>   LIST(APPEND FILES2 ${file}-2.h5m)
>>   add_custom_command(
>> DEPENDS ${file}.e
>> COMMAND convert ${file}.e ${file}.h5m
>> OUTPUT ${file}.h5m
>> )
>> endforeach()
>> ```
>> Add a custom target with ALL:
>> ```
>> add_custom_target(split2 ALL
>>   SOURCES ${FILES2}
>>   )
>> ```
>> Adding the output files to the SOURCES makes the target do what's its
>> supposed to do.
>>
>> Cheers,
>> Nico
>>
>> On Sun, Nov 22, 2015 at 11:59 PM David Cole  wrote:
>>
>>> You don't. You just assume all relevant targets have already been built
>>> by the time you run the tests... There's no such thing as a test from
>>> an add_test call depending on a target.
>>>
>>> There **is** a dependency, of course, if you are using one of the build
>>> products in your test, but it's assumed that everything is already built at
>>> test time.
>>>
>>> There is not yet a notion of connecting certain tests to certain build
>>> targets.
>>>
>>> So, for example, there is no way to re-run only the tests affected by
>>> things which have changed since the last build, because there is no
>>> connection between targets and tests.
>>>
>>> People have artificially created such connections using test labels, and
>>> running subsets of tests by label, but there is no official dependency from
>>> tests back to targets.
>>>
>>>
>>> D
>>>
>>>
>>>
>>> On Sunday, November 22, 2015, Nico Schlömer 
>>> wrote:
>>>
 Aha, this was a misunderstanding of me then. Thanks!
 How do I make a test depend on a target then?

 Cheers,
 Nico


 On Sun, Nov 22, 2015 at 8:58 PM David Cole  wrote:

> The DEPENDS property of a test is meant to ensure test running order
> in the case of parallel testing... It simply ensures that one test runs
> before another. It is not connected to the build system at all. It's
> different than target dependencies.
>
>
> D
>
>
>
> On Sunday, November 22, 2015, David Cole  wrote:
>
>> What do you mean by "depend" in this case? All libs and exes should
>> be built during a "make" or "make all" or "make install" ... And all that
>> should be done before any tests get run.
>>
>> Simply typing "ctest" to execute all the tests never does any
>> building. The assumed workflow is that you build stuff first and then run
>> the tests.
>>
>> If you want, you can add a custom target that runs a test, and make
>> that custom target depend on any other targets, but ctest still won't 
>> know
>> about it. Only "make custom_test_target" will...
>>
>>
>> D
>>
>>
>>
>> On Sunday, November 22, 2015, Nico Schlömer 
>> wrote:
>>
>>> Thanks for the hints!
>>> I'm almost there now, the only thing missing is to have my test
>>> depend on the custom_target. This
>>> ```
>>> SET_TESTS_PROPERTIES(testname PROPERTIES DEPENDS convert)
>>> ```
>>> doesn't do the trick: The target `convert` isn't executed before
>>> `ctest`.
>>>
>>> Any hints?
>>>
>>> Cheers,
>>> Nico
>>>
>>>
>>> On Sun, Nov 22, 2015 at 3:18 AM David Cole  wrote:
>>>
 Did you try using full path names for the add_custom_command file
 names?

 And the NAME/COMMAND form of the add_test command?

 Also, I've always found custom commands to work best when they're
 associated with a target. And if it was part of a target you could 
 make the
 target depend on the external data target with add_dependencies if
 necessary.


 HTH,
 David C.


 On Saturday, November 21, 2015, Nico Schlömer <
 nico.schloe...@gmail.com> wrote:

> Hi everyone,
>
> I would 

Re: [CMake] download file, modify, add test from it

2015-11-23 Thread Nico Schlömer
Thanks David for your explanations. I've now reached a good solution:

Fetch the data:
```
INCLUDE(ExternalData)
set(
  ExternalData_URL_TEMPLATES
  "https://downloads.sourceforge.net/project/noshdata/%(algo)/%(hash)"
  )
foreach(file ${input_files})
  ExternalData_Expand_Arguments(
noshTestFetchData
OUT_DATA DATA{${CMAKE_SOURCE_DIR}/test/data/${file}.e}
)
endforeach()
ExternalData_Add_Target(noshTestFetchData)
```
Define conversion commands:
```
foreach(file ${input_files})
  LIST(APPEND FILES2 ${file}-2.h5m)
  add_custom_command(
DEPENDS ${file}.e
COMMAND convert ${file}.e ${file}.h5m
OUTPUT ${file}.h5m
)
endforeach()
```
Add a custom target with ALL:
```
add_custom_target(split2 ALL
  SOURCES ${FILES2}
  )
```
Adding the output files to the SOURCES makes the target do what's its
supposed to do.

Cheers,
Nico

On Sun, Nov 22, 2015 at 11:59 PM David Cole  wrote:

> You don't. You just assume all relevant targets have already been built by
> the time you run the tests... There's no such thing as a test from
> an add_test call depending on a target.
>
> There **is** a dependency, of course, if you are using one of the build
> products in your test, but it's assumed that everything is already built at
> test time.
>
> There is not yet a notion of connecting certain tests to certain build
> targets.
>
> So, for example, there is no way to re-run only the tests affected by
> things which have changed since the last build, because there is no
> connection between targets and tests.
>
> People have artificially created such connections using test labels, and
> running subsets of tests by label, but there is no official dependency from
> tests back to targets.
>
>
> D
>
>
>
> On Sunday, November 22, 2015, Nico Schlömer 
> wrote:
>
>> Aha, this was a misunderstanding of me then. Thanks!
>> How do I make a test depend on a target then?
>>
>> Cheers,
>> Nico
>>
>>
>> On Sun, Nov 22, 2015 at 8:58 PM David Cole  wrote:
>>
>>> The DEPENDS property of a test is meant to ensure test running order in
>>> the case of parallel testing... It simply ensures that one test runs before
>>> another. It is not connected to the build system at all. It's different
>>> than target dependencies.
>>>
>>>
>>> D
>>>
>>>
>>>
>>> On Sunday, November 22, 2015, David Cole  wrote:
>>>
 What do you mean by "depend" in this case? All libs and exes should be
 built during a "make" or "make all" or "make install" ... And all that
 should be done before any tests get run.

 Simply typing "ctest" to execute all the tests never does any building.
 The assumed workflow is that you build stuff first and then run the tests.

 If you want, you can add a custom target that runs a test, and make
 that custom target depend on any other targets, but ctest still won't know
 about it. Only "make custom_test_target" will...


 D



 On Sunday, November 22, 2015, Nico Schlömer 
 wrote:

> Thanks for the hints!
> I'm almost there now, the only thing missing is to have my test depend
> on the custom_target. This
> ```
> SET_TESTS_PROPERTIES(testname PROPERTIES DEPENDS convert)
> ```
> doesn't do the trick: The target `convert` isn't executed before
> `ctest`.
>
> Any hints?
>
> Cheers,
> Nico
>
>
> On Sun, Nov 22, 2015 at 3:18 AM David Cole  wrote:
>
>> Did you try using full path names for the add_custom_command file
>> names?
>>
>> And the NAME/COMMAND form of the add_test command?
>>
>> Also, I've always found custom commands to work best when they're
>> associated with a target. And if it was part of a target you could make 
>> the
>> target depend on the external data target with add_dependencies if
>> necessary.
>>
>>
>> HTH,
>> David C.
>>
>>
>> On Saturday, November 21, 2015, Nico Schlömer <
>> nico.schloe...@gmail.com> wrote:
>>
>>> Hi everyone,
>>>
>>> I would like to create a CMake test that does the following:
>>>  * Download a file from an external resource
>>>  * Do something with the file
>>>  * compile an executable myTest
>>>  * execute myTest outputfile
>>>
>>> Using ExternalData for downloading the file works well, but the
>>> second step (file conversion, in this example cp for simplicity) does 
>>> not
>>> work:
>>> ```
>>> cmake_minimum_required(VERSION 3.2)
>>>
>>> project(mytest)
>>>
>>> # Download the files
>>> INCLUDE(ExternalData)
>>> set(
>>>   ExternalData_URL_TEMPLATES
>>>   "
>>> https://downloads.sourceforge.net/project/noshdata/%(algo)/%(hash)"
>>>   )
>>> ExternalData_Expand_Arguments(
>>>   testFetchData
>>>   OUT_DATA DATA{${CMAKE_SOURCE_DIR}/test.e}
>>>   

Re: [CMake] download file, modify, add test from it

2015-11-22 Thread David Cole via CMake
You don't. You just assume all relevant targets have already been built by
the time you run the tests... There's no such thing as a test from
an add_test call depending on a target.

There **is** a dependency, of course, if you are using one of the build
products in your test, but it's assumed that everything is already built at
test time.

There is not yet a notion of connecting certain tests to certain build
targets.

So, for example, there is no way to re-run only the tests affected by
things which have changed since the last build, because there is no
connection between targets and tests.

People have artificially created such connections using test labels, and
running subsets of tests by label, but there is no official dependency from
tests back to targets.


D



On Sunday, November 22, 2015, Nico Schlömer 
wrote:

> Aha, this was a misunderstanding of me then. Thanks!
> How do I make a test depend on a target then?
>
> Cheers,
> Nico
>
>
> On Sun, Nov 22, 2015 at 8:58 PM David Cole  > wrote:
>
>> The DEPENDS property of a test is meant to ensure test running order in
>> the case of parallel testing... It simply ensures that one test runs before
>> another. It is not connected to the build system at all. It's different
>> than target dependencies.
>>
>>
>> D
>>
>>
>>
>> On Sunday, November 22, 2015, David Cole > > wrote:
>>
>>> What do you mean by "depend" in this case? All libs and exes should be
>>> built during a "make" or "make all" or "make install" ... And all that
>>> should be done before any tests get run.
>>>
>>> Simply typing "ctest" to execute all the tests never does any building.
>>> The assumed workflow is that you build stuff first and then run the tests.
>>>
>>> If you want, you can add a custom target that runs a test, and make that
>>> custom target depend on any other targets, but ctest still won't know about
>>> it. Only "make custom_test_target" will...
>>>
>>>
>>> D
>>>
>>>
>>>
>>> On Sunday, November 22, 2015, Nico Schlömer 
>>> wrote:
>>>
 Thanks for the hints!
 I'm almost there now, the only thing missing is to have my test depend
 on the custom_target. This
 ```
 SET_TESTS_PROPERTIES(testname PROPERTIES DEPENDS convert)
 ```
 doesn't do the trick: The target `convert` isn't executed before
 `ctest`.

 Any hints?

 Cheers,
 Nico


 On Sun, Nov 22, 2015 at 3:18 AM David Cole  wrote:

> Did you try using full path names for the add_custom_command file
> names?
>
> And the NAME/COMMAND form of the add_test command?
>
> Also, I've always found custom commands to work best when they're
> associated with a target. And if it was part of a target you could make 
> the
> target depend on the external data target with add_dependencies if
> necessary.
>
>
> HTH,
> David C.
>
>
> On Saturday, November 21, 2015, Nico Schlömer <
> nico.schloe...@gmail.com> wrote:
>
>> Hi everyone,
>>
>> I would like to create a CMake test that does the following:
>>  * Download a file from an external resource
>>  * Do something with the file
>>  * compile an executable myTest
>>  * execute myTest outputfile
>>
>> Using ExternalData for downloading the file works well, but the
>> second step (file conversion, in this example cp for simplicity) does not
>> work:
>> ```
>> cmake_minimum_required(VERSION 3.2)
>>
>> project(mytest)
>>
>> # Download the files
>> INCLUDE(ExternalData)
>> set(
>>   ExternalData_URL_TEMPLATES
>>   "https://downloads.sourceforge.net/project/noshdata/%(algo)/%(hash)
>> "
>>   )
>> ExternalData_Expand_Arguments(
>>   testFetchData
>>   OUT_DATA DATA{${CMAKE_SOURCE_DIR}/test.e}
>>   )
>> ExternalData_Add_Target(testFetchData)
>>
>> add_custom_command(
>>   OUTPUT test.g
>>   COMMAND cp test.e test.g
>>   DEPENDS test.e
>>   )
>>
>> ADD_EXECUTABLE("myTest" main.cpp)
>>
>> add_test(myTest test.g)
>> ```
>> I suppose I'm missing something about the dependencies here; after
>> all, the `add_custom_command` has to wait for `testFetchData` to 
>> complete.
>> Likewise, `add_test` has to wait for `add_custom_command` to complete.
>>
>> Hints appreciated.
>>
>> Cheers,
>> Nico
>>
>
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake 

Re: [CMake] download file, modify, add test from it

2015-11-22 Thread David Cole via CMake
Use ALL to include your custom target in the default build of all.

https://cmake.org/cmake/help/v3.4/command/add_custom_target.html


D


On Sunday, November 22, 2015, Nico Schlömer 
wrote:

> I was under the impression that if I don't explicitly build a target, it
> won't get build. Perhaps I'm wrong here. In any case, this
> ```
> add_custom_target(convert)
> add_dependencies(convert testFetchData)
> add_custom_command(
>   TARGET convert
>   COMMAND cp test.e test.g
>   )
> ```
> never gets executed on `make`, unlike all other targets (e.g., `
> testFetchData`). (Full CMakeLists.txt at [1].) Explicitly calling `make
> convert` works alright.
>
> Any idea why that might be?
>
> Cheers,
> Nico
>
> [1] http://chunk.io/f/729beeab41fb4a7385ceb98b31a2ea0a
>
> On Sun, Nov 22, 2015 at 8:46 PM David Cole  > wrote:
>
>> What do you mean by "depend" in this case? All libs and exes should be
>> built during a "make" or "make all" or "make install" ... And all that
>> should be done before any tests get run.
>>
>> Simply typing "ctest" to execute all the tests never does any building.
>> The assumed workflow is that you build stuff first and then run the tests.
>>
>> If you want, you can add a custom target that runs a test, and make that
>> custom target depend on any other targets, but ctest still won't know about
>> it. Only "make custom_test_target" will...
>>
>>
>> D
>>
>>
>>
>> On Sunday, November 22, 2015, Nico Schlömer > > wrote:
>>
>>> Thanks for the hints!
>>> I'm almost there now, the only thing missing is to have my test depend
>>> on the custom_target. This
>>> ```
>>> SET_TESTS_PROPERTIES(testname PROPERTIES DEPENDS convert)
>>> ```
>>> doesn't do the trick: The target `convert` isn't executed before `ctest`.
>>>
>>> Any hints?
>>>
>>> Cheers,
>>> Nico
>>>
>>>
>>> On Sun, Nov 22, 2015 at 3:18 AM David Cole  wrote:
>>>
 Did you try using full path names for the add_custom_command file names?

 And the NAME/COMMAND form of the add_test command?

 Also, I've always found custom commands to work best when they're
 associated with a target. And if it was part of a target you could make the
 target depend on the external data target with add_dependencies if
 necessary.


 HTH,
 David C.


 On Saturday, November 21, 2015, Nico Schlömer 
 wrote:

> Hi everyone,
>
> I would like to create a CMake test that does the following:
>  * Download a file from an external resource
>  * Do something with the file
>  * compile an executable myTest
>  * execute myTest outputfile
>
> Using ExternalData for downloading the file works well, but the second
> step (file conversion, in this example cp for simplicity) does not work:
> ```
> cmake_minimum_required(VERSION 3.2)
>
> project(mytest)
>
> # Download the files
> INCLUDE(ExternalData)
> set(
>   ExternalData_URL_TEMPLATES
>   "https://downloads.sourceforge.net/project/noshdata/%(algo)/%(hash)"
>   )
> ExternalData_Expand_Arguments(
>   testFetchData
>   OUT_DATA DATA{${CMAKE_SOURCE_DIR}/test.e}
>   )
> ExternalData_Add_Target(testFetchData)
>
> add_custom_command(
>   OUTPUT test.g
>   COMMAND cp test.e test.g
>   DEPENDS test.e
>   )
>
> ADD_EXECUTABLE("myTest" main.cpp)
>
> add_test(myTest test.g)
> ```
> I suppose I'm missing something about the dependencies here; after
> all, the `add_custom_command` has to wait for `testFetchData` to complete.
> Likewise, `add_test` has to wait for `add_custom_command` to complete.
>
> Hints appreciated.
>
> Cheers,
> Nico
>

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] download file, modify, add test from it

2015-11-22 Thread David Cole via CMake
What do you mean by "depend" in this case? All libs and exes should be
built during a "make" or "make all" or "make install" ... And all that
should be done before any tests get run.

Simply typing "ctest" to execute all the tests never does any building. The
assumed workflow is that you build stuff first and then run the tests.

If you want, you can add a custom target that runs a test, and make that
custom target depend on any other targets, but ctest still won't know about
it. Only "make custom_test_target" will...


D



On Sunday, November 22, 2015, Nico Schlömer 
wrote:

> Thanks for the hints!
> I'm almost there now, the only thing missing is to have my test depend on
> the custom_target. This
> ```
> SET_TESTS_PROPERTIES(testname PROPERTIES DEPENDS convert)
> ```
> doesn't do the trick: The target `convert` isn't executed before `ctest`.
>
> Any hints?
>
> Cheers,
> Nico
>
>
> On Sun, Nov 22, 2015 at 3:18 AM David Cole  > wrote:
>
>> Did you try using full path names for the add_custom_command file names?
>>
>> And the NAME/COMMAND form of the add_test command?
>>
>> Also, I've always found custom commands to work best when they're
>> associated with a target. And if it was part of a target you could make the
>> target depend on the external data target with add_dependencies if
>> necessary.
>>
>>
>> HTH,
>> David C.
>>
>>
>> On Saturday, November 21, 2015, Nico Schlömer > > wrote:
>>
>>> Hi everyone,
>>>
>>> I would like to create a CMake test that does the following:
>>>  * Download a file from an external resource
>>>  * Do something with the file
>>>  * compile an executable myTest
>>>  * execute myTest outputfile
>>>
>>> Using ExternalData for downloading the file works well, but the second
>>> step (file conversion, in this example cp for simplicity) does not work:
>>> ```
>>> cmake_minimum_required(VERSION 3.2)
>>>
>>> project(mytest)
>>>
>>> # Download the files
>>> INCLUDE(ExternalData)
>>> set(
>>>   ExternalData_URL_TEMPLATES
>>>   "https://downloads.sourceforge.net/project/noshdata/%(algo)/%(hash)"
>>>   )
>>> ExternalData_Expand_Arguments(
>>>   testFetchData
>>>   OUT_DATA DATA{${CMAKE_SOURCE_DIR}/test.e}
>>>   )
>>> ExternalData_Add_Target(testFetchData)
>>>
>>> add_custom_command(
>>>   OUTPUT test.g
>>>   COMMAND cp test.e test.g
>>>   DEPENDS test.e
>>>   )
>>>
>>> ADD_EXECUTABLE("myTest" main.cpp)
>>>
>>> add_test(myTest test.g)
>>> ```
>>> I suppose I'm missing something about the dependencies here; after all,
>>> the `add_custom_command` has to wait for `testFetchData` to complete.
>>> Likewise, `add_test` has to wait for `add_custom_command` to complete.
>>>
>>> Hints appreciated.
>>>
>>> Cheers,
>>> Nico
>>>
>>
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] download file, modify, add test from it

2015-11-22 Thread Nico Schlömer
I was under the impression that if I don't explicitly build a target, it
won't get build. Perhaps I'm wrong here. In any case, this
```
add_custom_target(convert)
add_dependencies(convert testFetchData)
add_custom_command(
  TARGET convert
  COMMAND cp test.e test.g
  )
```
never gets executed on `make`, unlike all other targets (e.g., `
testFetchData`). (Full CMakeLists.txt at [1].) Explicitly calling `make
convert` works alright.

Any idea why that might be?

Cheers,
Nico

[1] http://chunk.io/f/729beeab41fb4a7385ceb98b31a2ea0a

On Sun, Nov 22, 2015 at 8:46 PM David Cole  wrote:

> What do you mean by "depend" in this case? All libs and exes should be
> built during a "make" or "make all" or "make install" ... And all that
> should be done before any tests get run.
>
> Simply typing "ctest" to execute all the tests never does any building.
> The assumed workflow is that you build stuff first and then run the tests.
>
> If you want, you can add a custom target that runs a test, and make that
> custom target depend on any other targets, but ctest still won't know about
> it. Only "make custom_test_target" will...
>
>
> D
>
>
>
> On Sunday, November 22, 2015, Nico Schlömer 
> wrote:
>
>> Thanks for the hints!
>> I'm almost there now, the only thing missing is to have my test depend on
>> the custom_target. This
>> ```
>> SET_TESTS_PROPERTIES(testname PROPERTIES DEPENDS convert)
>> ```
>> doesn't do the trick: The target `convert` isn't executed before `ctest`.
>>
>> Any hints?
>>
>> Cheers,
>> Nico
>>
>>
>> On Sun, Nov 22, 2015 at 3:18 AM David Cole  wrote:
>>
>>> Did you try using full path names for the add_custom_command file names?
>>>
>>> And the NAME/COMMAND form of the add_test command?
>>>
>>> Also, I've always found custom commands to work best when they're
>>> associated with a target. And if it was part of a target you could make the
>>> target depend on the external data target with add_dependencies if
>>> necessary.
>>>
>>>
>>> HTH,
>>> David C.
>>>
>>>
>>> On Saturday, November 21, 2015, Nico Schlömer 
>>> wrote:
>>>
 Hi everyone,

 I would like to create a CMake test that does the following:
  * Download a file from an external resource
  * Do something with the file
  * compile an executable myTest
  * execute myTest outputfile

 Using ExternalData for downloading the file works well, but the second
 step (file conversion, in this example cp for simplicity) does not work:
 ```
 cmake_minimum_required(VERSION 3.2)

 project(mytest)

 # Download the files
 INCLUDE(ExternalData)
 set(
   ExternalData_URL_TEMPLATES
   "https://downloads.sourceforge.net/project/noshdata/%(algo)/%(hash)"
   )
 ExternalData_Expand_Arguments(
   testFetchData
   OUT_DATA DATA{${CMAKE_SOURCE_DIR}/test.e}
   )
 ExternalData_Add_Target(testFetchData)

 add_custom_command(
   OUTPUT test.g
   COMMAND cp test.e test.g
   DEPENDS test.e
   )

 ADD_EXECUTABLE("myTest" main.cpp)

 add_test(myTest test.g)
 ```
 I suppose I'm missing something about the dependencies here; after all,
 the `add_custom_command` has to wait for `testFetchData` to complete.
 Likewise, `add_test` has to wait for `add_custom_command` to complete.

 Hints appreciated.

 Cheers,
 Nico

>>>
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] download file, modify, add test from it

2015-11-22 Thread David Cole via CMake
The DEPENDS property of a test is meant to ensure test running order in the
case of parallel testing... It simply ensures that one test runs before
another. It is not connected to the build system at all. It's different
than target dependencies.


D



On Sunday, November 22, 2015, David Cole  wrote:

> What do you mean by "depend" in this case? All libs and exes should be
> built during a "make" or "make all" or "make install" ... And all that
> should be done before any tests get run.
>
> Simply typing "ctest" to execute all the tests never does any building.
> The assumed workflow is that you build stuff first and then run the tests.
>
> If you want, you can add a custom target that runs a test, and make that
> custom target depend on any other targets, but ctest still won't know about
> it. Only "make custom_test_target" will...
>
>
> D
>
>
>
> On Sunday, November 22, 2015, Nico Schlömer  > wrote:
>
>> Thanks for the hints!
>> I'm almost there now, the only thing missing is to have my test depend on
>> the custom_target. This
>> ```
>> SET_TESTS_PROPERTIES(testname PROPERTIES DEPENDS convert)
>> ```
>> doesn't do the trick: The target `convert` isn't executed before `ctest`.
>>
>> Any hints?
>>
>> Cheers,
>> Nico
>>
>>
>> On Sun, Nov 22, 2015 at 3:18 AM David Cole  wrote:
>>
>>> Did you try using full path names for the add_custom_command file names?
>>>
>>> And the NAME/COMMAND form of the add_test command?
>>>
>>> Also, I've always found custom commands to work best when they're
>>> associated with a target. And if it was part of a target you could make the
>>> target depend on the external data target with add_dependencies if
>>> necessary.
>>>
>>>
>>> HTH,
>>> David C.
>>>
>>>
>>> On Saturday, November 21, 2015, Nico Schlömer 
>>> wrote:
>>>
 Hi everyone,

 I would like to create a CMake test that does the following:
  * Download a file from an external resource
  * Do something with the file
  * compile an executable myTest
  * execute myTest outputfile

 Using ExternalData for downloading the file works well, but the second
 step (file conversion, in this example cp for simplicity) does not work:
 ```
 cmake_minimum_required(VERSION 3.2)

 project(mytest)

 # Download the files
 INCLUDE(ExternalData)
 set(
   ExternalData_URL_TEMPLATES
   "https://downloads.sourceforge.net/project/noshdata/%(algo)/%(hash)"
   )
 ExternalData_Expand_Arguments(
   testFetchData
   OUT_DATA DATA{${CMAKE_SOURCE_DIR}/test.e}
   )
 ExternalData_Add_Target(testFetchData)

 add_custom_command(
   OUTPUT test.g
   COMMAND cp test.e test.g
   DEPENDS test.e
   )

 ADD_EXECUTABLE("myTest" main.cpp)

 add_test(myTest test.g)
 ```
 I suppose I'm missing something about the dependencies here; after all,
 the `add_custom_command` has to wait for `testFetchData` to complete.
 Likewise, `add_test` has to wait for `add_custom_command` to complete.

 Hints appreciated.

 Cheers,
 Nico

>>>
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] download file, modify, add test from it

2015-11-22 Thread Nico Schlömer
Aha, this was a misunderstanding of me then. Thanks!
How do I make a test depend on a target then?

Cheers,
Nico


On Sun, Nov 22, 2015 at 8:58 PM David Cole  wrote:

> The DEPENDS property of a test is meant to ensure test running order in
> the case of parallel testing... It simply ensures that one test runs before
> another. It is not connected to the build system at all. It's different
> than target dependencies.
>
>
> D
>
>
>
> On Sunday, November 22, 2015, David Cole  wrote:
>
>> What do you mean by "depend" in this case? All libs and exes should be
>> built during a "make" or "make all" or "make install" ... And all that
>> should be done before any tests get run.
>>
>> Simply typing "ctest" to execute all the tests never does any building.
>> The assumed workflow is that you build stuff first and then run the tests.
>>
>> If you want, you can add a custom target that runs a test, and make that
>> custom target depend on any other targets, but ctest still won't know about
>> it. Only "make custom_test_target" will...
>>
>>
>> D
>>
>>
>>
>> On Sunday, November 22, 2015, Nico Schlömer 
>> wrote:
>>
>>> Thanks for the hints!
>>> I'm almost there now, the only thing missing is to have my test depend
>>> on the custom_target. This
>>> ```
>>> SET_TESTS_PROPERTIES(testname PROPERTIES DEPENDS convert)
>>> ```
>>> doesn't do the trick: The target `convert` isn't executed before `ctest`.
>>>
>>> Any hints?
>>>
>>> Cheers,
>>> Nico
>>>
>>>
>>> On Sun, Nov 22, 2015 at 3:18 AM David Cole  wrote:
>>>
 Did you try using full path names for the add_custom_command file names?

 And the NAME/COMMAND form of the add_test command?

 Also, I've always found custom commands to work best when they're
 associated with a target. And if it was part of a target you could make the
 target depend on the external data target with add_dependencies if
 necessary.


 HTH,
 David C.


 On Saturday, November 21, 2015, Nico Schlömer 
 wrote:

> Hi everyone,
>
> I would like to create a CMake test that does the following:
>  * Download a file from an external resource
>  * Do something with the file
>  * compile an executable myTest
>  * execute myTest outputfile
>
> Using ExternalData for downloading the file works well, but the second
> step (file conversion, in this example cp for simplicity) does not work:
> ```
> cmake_minimum_required(VERSION 3.2)
>
> project(mytest)
>
> # Download the files
> INCLUDE(ExternalData)
> set(
>   ExternalData_URL_TEMPLATES
>   "https://downloads.sourceforge.net/project/noshdata/%(algo)/%(hash)"
>   )
> ExternalData_Expand_Arguments(
>   testFetchData
>   OUT_DATA DATA{${CMAKE_SOURCE_DIR}/test.e}
>   )
> ExternalData_Add_Target(testFetchData)
>
> add_custom_command(
>   OUTPUT test.g
>   COMMAND cp test.e test.g
>   DEPENDS test.e
>   )
>
> ADD_EXECUTABLE("myTest" main.cpp)
>
> add_test(myTest test.g)
> ```
> I suppose I'm missing something about the dependencies here; after
> all, the `add_custom_command` has to wait for `testFetchData` to complete.
> Likewise, `add_test` has to wait for `add_custom_command` to complete.
>
> Hints appreciated.
>
> Cheers,
> Nico
>

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] download file, modify, add test from it

2015-11-22 Thread Nico Schlömer
Thanks for the hints!
I'm almost there now, the only thing missing is to have my test depend on
the custom_target. This
```
SET_TESTS_PROPERTIES(testname PROPERTIES DEPENDS convert)
```
doesn't do the trick: The target `convert` isn't executed before `ctest`.

Any hints?

Cheers,
Nico


On Sun, Nov 22, 2015 at 3:18 AM David Cole  wrote:

> Did you try using full path names for the add_custom_command file names?
>
> And the NAME/COMMAND form of the add_test command?
>
> Also, I've always found custom commands to work best when they're
> associated with a target. And if it was part of a target you could make the
> target depend on the external data target with add_dependencies if
> necessary.
>
>
> HTH,
> David C.
>
>
> On Saturday, November 21, 2015, Nico Schlömer 
> wrote:
>
>> Hi everyone,
>>
>> I would like to create a CMake test that does the following:
>>  * Download a file from an external resource
>>  * Do something with the file
>>  * compile an executable myTest
>>  * execute myTest outputfile
>>
>> Using ExternalData for downloading the file works well, but the second
>> step (file conversion, in this example cp for simplicity) does not work:
>> ```
>> cmake_minimum_required(VERSION 3.2)
>>
>> project(mytest)
>>
>> # Download the files
>> INCLUDE(ExternalData)
>> set(
>>   ExternalData_URL_TEMPLATES
>>   "https://downloads.sourceforge.net/project/noshdata/%(algo)/%(hash)"
>>   )
>> ExternalData_Expand_Arguments(
>>   testFetchData
>>   OUT_DATA DATA{${CMAKE_SOURCE_DIR}/test.e}
>>   )
>> ExternalData_Add_Target(testFetchData)
>>
>> add_custom_command(
>>   OUTPUT test.g
>>   COMMAND cp test.e test.g
>>   DEPENDS test.e
>>   )
>>
>> ADD_EXECUTABLE("myTest" main.cpp)
>>
>> add_test(myTest test.g)
>> ```
>> I suppose I'm missing something about the dependencies here; after all,
>> the `add_custom_command` has to wait for `testFetchData` to complete.
>> Likewise, `add_test` has to wait for `add_custom_command` to complete.
>>
>> Hints appreciated.
>>
>> Cheers,
>> Nico
>>
>
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] download file, modify, add test from it

2015-11-21 Thread David Cole via CMake
Did you try using full path names for the add_custom_command file names?

And the NAME/COMMAND form of the add_test command?

Also, I've always found custom commands to work best when they're
associated with a target. And if it was part of a target you could make the
target depend on the external data target with add_dependencies if
necessary.


HTH,
David C.


On Saturday, November 21, 2015, Nico Schlömer 
wrote:

> Hi everyone,
>
> I would like to create a CMake test that does the following:
>  * Download a file from an external resource
>  * Do something with the file
>  * compile an executable myTest
>  * execute myTest outputfile
>
> Using ExternalData for downloading the file works well, but the second
> step (file conversion, in this example cp for simplicity) does not work:
> ```
> cmake_minimum_required(VERSION 3.2)
>
> project(mytest)
>
> # Download the files
> INCLUDE(ExternalData)
> set(
>   ExternalData_URL_TEMPLATES
>   "https://downloads.sourceforge.net/project/noshdata/%(algo)/%(hash)"
>   )
> ExternalData_Expand_Arguments(
>   testFetchData
>   OUT_DATA DATA{${CMAKE_SOURCE_DIR}/test.e}
>   )
> ExternalData_Add_Target(testFetchData)
>
> add_custom_command(
>   OUTPUT test.g
>   COMMAND cp test.e test.g
>   DEPENDS test.e
>   )
>
> ADD_EXECUTABLE("myTest" main.cpp)
>
> add_test(myTest test.g)
> ```
> I suppose I'm missing something about the dependencies here; after all,
> the `add_custom_command` has to wait for `testFetchData` to complete.
> Likewise, `add_test` has to wait for `add_custom_command` to complete.
>
> Hints appreciated.
>
> Cheers,
> Nico
>
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

[CMake] download file, modify, add test from it

2015-11-21 Thread Nico Schlömer
Hi everyone,

I would like to create a CMake test that does the following:
 * Download a file from an external resource
 * Do something with the file
 * compile an executable myTest
 * execute myTest outputfile

Using ExternalData for downloading the file works well, but the second step
(file conversion, in this example cp for simplicity) does not work:
```
cmake_minimum_required(VERSION 3.2)

project(mytest)

# Download the files
INCLUDE(ExternalData)
set(
  ExternalData_URL_TEMPLATES
  "https://downloads.sourceforge.net/project/noshdata/%(algo)/%(hash)"
  )
ExternalData_Expand_Arguments(
  testFetchData
  OUT_DATA DATA{${CMAKE_SOURCE_DIR}/test.e}
  )
ExternalData_Add_Target(testFetchData)

add_custom_command(
  OUTPUT test.g
  COMMAND cp test.e test.g
  DEPENDS test.e
  )

ADD_EXECUTABLE("myTest" main.cpp)

add_test(myTest test.g)
```
I suppose I'm missing something about the dependencies here; after all, the
`add_custom_command` has to wait for `testFetchData` to complete. Likewise,
`add_test` has to wait for `add_custom_command` to complete.

Hints appreciated.

Cheers,
Nico
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake