Re: [CMake] Where are tests located?

2011-11-11 Thread David Cole
On Thu, Nov 10, 2011 at 4:41 PM, EXT-York, Gantry
 wrote:
> If I'm in a traversed subdirectory, is there a different variable other than 
> ${CMAKE_CURRENT_SOURCE_DIR} that I should be using?
>
> This doesn't seem to work.
>
>
> Gantry York
> Chandler, Arizona
>
>
>
>
> -Original Message-
> From: cmake-boun...@cmake.org [mailto:cmake-boun...@cmake.org] On Behalf Of 
> EXT-York, Gantry
> Sent: Thursday, November 10, 2011 2:34 PM
> To: David Cole
> Cc: cmake@cmake.org
> Subject: Re: [CMake] Where are tests located?
>
> OK, so if I'm trying to add a test do I just
>
> add_executable( run_main.pl IMPORTED )
> set_property(
>    TARGET test_script1
>    PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/run_main.pl"
> )
> add_test( test1 run_main.pl)
>
>
> If run_main.pl is
>
> #!/usr/bin/perl
> system "main --val 24"
>
>
> Main could be in the build tree if it comes from main.cxx or it could be in 
> the source tree if it is a script.  How does cmake know where main is at?
>
>
> -Original Message-
> From: David Cole [mailto:david.c...@kitware.com]
> Sent: Thursday, November 10, 2011 1:09 PM
> To: EXT-York, Gantry
> Cc: cmake@cmake.org
> Subject: Re: [CMake] Where are tests located?
>
> When you add an IMPORTED target, CMake does not know where the
> imported target is AT ALL until you tell it.
>
> After:
>  add_executable(run_main.pl IMPORTED)
>
> You need:
>  set_property(TARGET run_main.pl PROPERTY IMPORTED_LOCATION
> "${CMAKE_CURRENT_SOURCE_DIR}/run_main.pl")
>
> See docs here:
>  http://cmake.org/cmake/help/cmake-2-8-docs.html#command:set_property
>  http://cmake.org/cmake/help/cmake-2-8-docs.html#prop_tgt:IMPORTED_LOCATION
>
>
> HTH,
> David
>
>
> On Thu, Nov 10, 2011 at 3:00 PM, EXT-York, Gantry
>  wrote:
>> When I do an
>>
>>
>>
>> add_executable( run_main.pl IMPORTED)
>>
>> add_test( test1 run_main.pl)
>>
>>
>>
>> How does it know where run_main.pl is located when you do an out of source
>> build?
>>
>>
>>
>> It seems to look in
>>
>> .
>>
>> Releases
>>
>> Debug
>>
>> MinSizeRel
>>
>> RelWithDebInfo
>>
>> Deployment
>>
>> Development
>>
>>
>>
>> which are directories that I don't even see existing.
>>
>>
>>
>> And if run_main.pl is just
>>
>>
>>
>> #!/usr/bin/perl
>>
>> system " ../exec/main"
>>
>>
>>
>>
>>
>> How does it know if ../exec/main is in the src tree or the build tree?  If
>> main is a C binary, it would be in the build tree, if it is just a script it
>> would be in the source tree.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> Gantry York
>>
>> Chandler, Arizona
>>
>>
>>
>> --
>>
>> 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
>>
> --
>
> 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
>

CMAKE_SOURCE_DIR is the value of the top level source tree that you
give to cmake (or cmake-gui, or ccmake) when you configure a build
tree.

CMAKE_CURRENT_SOURCE_DIR starts out as CMAKE_SOURCE_DIR in the top
level CMakeLists.txt file, and then changes value as subdirectories
are traversed via add_subdirectory.


HTH,
David
--

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


Re: [CMake] Where are tests located?

2011-11-11 Thread David Cole
On Thu, Nov 10, 2011 at 4:33 PM, EXT-York, Gantry
 wrote:
> OK, so if I'm trying to add a test do I just
>
> add_executable( run_main.pl IMPORTED )
> set_property(
>    TARGET test_script1
>    PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/run_main.pl"
> )
> add_test( test1 run_main.pl)
>
>
> If run_main.pl is
>
> #!/usr/bin/perl
> system "main --val 24"
>
>
> Main could be in the build tree if it comes from main.cxx or it could be in 
> the source tree if it is a script.  How does cmake know where main is at?
>
>
> -Original Message-
> From: David Cole [mailto:david.c...@kitware.com]
> Sent: Thursday, November 10, 2011 1:09 PM
> To: EXT-York, Gantry
> Cc: cmake@cmake.org
> Subject: Re: [CMake] Where are tests located?
>
> When you add an IMPORTED target, CMake does not know where the
> imported target is AT ALL until you tell it.
>
> After:
>  add_executable(run_main.pl IMPORTED)
>
> You need:
>  set_property(TARGET run_main.pl PROPERTY IMPORTED_LOCATION
> "${CMAKE_CURRENT_SOURCE_DIR}/run_main.pl")
>
> See docs here:
>  http://cmake.org/cmake/help/cmake-2-8-docs.html#command:set_property
>  http://cmake.org/cmake/help/cmake-2-8-docs.html#prop_tgt:IMPORTED_LOCATION
>
>
> HTH,
> David
>
>
> On Thu, Nov 10, 2011 at 3:00 PM, EXT-York, Gantry
>  wrote:
>> When I do an
>>
>>
>>
>> add_executable( run_main.pl IMPORTED)
>>
>> add_test( test1 run_main.pl)
>>
>>
>>
>> How does it know where run_main.pl is located when you do an out of source
>> build?
>>
>>
>>
>> It seems to look in
>>
>> .
>>
>> Releases
>>
>> Debug
>>
>> MinSizeRel
>>
>> RelWithDebInfo
>>
>> Deployment
>>
>> Development
>>
>>
>>
>> which are directories that I don't even see existing.
>>
>>
>>
>> And if run_main.pl is just
>>
>>
>>
>> #!/usr/bin/perl
>>
>> system " ../exec/main"
>>
>>
>>
>>
>>
>> How does it know if ../exec/main is in the src tree or the build tree?  If
>> main is a C binary, it would be in the build tree, if it is just a script it
>> would be in the source tree.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> Gantry York
>>
>> Chandler, Arizona
>>
>>
>>
>> --
>>
>> 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
>>
>

If I were running a perl script as a test, here's how I would write
the CMakeLists.txt file:

  cmake_minimum_required(VERSION 2.8)
  project(perl_test)

  include(CTest)

  find_package(Perl)

  message("PERL_EXECUTABLE='${PERL_EXECUTABLE}'")

  add_test(NAME test1 COMMAND ${PERL_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/run_main.pl)

By default the working directory will be in CMAKE_CURRENT_BINARY_DIR
when the test runs. You can control it on a per-test basis by adding
the WORKING_DIRECTORY keyword to the add_test command if you know in
the CMakeLists file which test has main in the source tree and which
test has main.exe in the binary tree.

Something like this:
  add_test(NAME test_of_script COMMAND ${PERL_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/run_main.pl
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

  add_test(NAME test_of_exe COMMAND ${PERL_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/run_main.pl
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

However, CMake has no idea where "main" is, and for that matter,
neither does perl unless you tell it.

I would recommend structuring the perl script so that it takes in a
directory argument of where to look for the "main" script or
executable. Then you could use an expression like this to pass it
along to the perl script:

  add_test(NAME test_passing_dir COMMAND ${PERL_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/run_main.pl
--dir $
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

Of course, use the actual target name for the target that produces
"main" in that last example, not the actual string "main".

CMake enforces name uniqueness among all targets in the whole tree.


Hopefully, this sheds a little more light on things for you.

HTH,
David
--

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


Re: [CMake] Where are tests located?

2011-11-10 Thread EXT-York, Gantry
If I'm in a traversed subdirectory, is there a different variable other than 
${CMAKE_CURRENT_SOURCE_DIR} that I should be using?

This doesn't seem to work.


Gantry York
Chandler, Arizona




-Original Message-
From: cmake-boun...@cmake.org [mailto:cmake-boun...@cmake.org] On Behalf Of 
EXT-York, Gantry
Sent: Thursday, November 10, 2011 2:34 PM
To: David Cole
Cc: cmake@cmake.org
Subject: Re: [CMake] Where are tests located?

OK, so if I'm trying to add a test do I just

add_executable( run_main.pl IMPORTED )
set_property(
TARGET test_script1
PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/run_main.pl"
)
add_test( test1 run_main.pl)


If run_main.pl is 

#!/usr/bin/perl
system "main --val 24"


Main could be in the build tree if it comes from main.cxx or it could be in the 
source tree if it is a script.  How does cmake know where main is at?


-Original Message-
From: David Cole [mailto:david.c...@kitware.com] 
Sent: Thursday, November 10, 2011 1:09 PM
To: EXT-York, Gantry
Cc: cmake@cmake.org
Subject: Re: [CMake] Where are tests located?

When you add an IMPORTED target, CMake does not know where the
imported target is AT ALL until you tell it.

After:
  add_executable(run_main.pl IMPORTED)

You need:
  set_property(TARGET run_main.pl PROPERTY IMPORTED_LOCATION
"${CMAKE_CURRENT_SOURCE_DIR}/run_main.pl")

See docs here:
  http://cmake.org/cmake/help/cmake-2-8-docs.html#command:set_property
  http://cmake.org/cmake/help/cmake-2-8-docs.html#prop_tgt:IMPORTED_LOCATION


HTH,
David


On Thu, Nov 10, 2011 at 3:00 PM, EXT-York, Gantry
 wrote:
> When I do an
>
>
>
> add_executable( run_main.pl IMPORTED)
>
> add_test( test1 run_main.pl)
>
>
>
> How does it know where run_main.pl is located when you do an out of source
> build?
>
>
>
> It seems to look in
>
> .
>
> Releases
>
> Debug
>
> MinSizeRel
>
> RelWithDebInfo
>
> Deployment
>
> Development
>
>
>
> which are directories that I don't even see existing.
>
>
>
> And if run_main.pl is just
>
>
>
> #!/usr/bin/perl
>
> system " ../exec/main"
>
>
>
>
>
> How does it know if ../exec/main is in the src tree or the build tree?  If
> main is a C binary, it would be in the build tree, if it is just a script it
> would be in the source tree.
>
>
>
>
>
>
>
>
>
> Gantry York
>
> Chandler, Arizona
>
>
>
> --
>
> 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
>
--

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
--

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


Re: [CMake] Where are tests located?

2011-11-10 Thread EXT-York, Gantry
OK, so if I'm trying to add a test do I just

add_executable( run_main.pl IMPORTED )
set_property(
TARGET test_script1
PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/run_main.pl"
)
add_test( test1 run_main.pl)


If run_main.pl is 

#!/usr/bin/perl
system "main --val 24"


Main could be in the build tree if it comes from main.cxx or it could be in the 
source tree if it is a script.  How does cmake know where main is at?


-Original Message-
From: David Cole [mailto:david.c...@kitware.com] 
Sent: Thursday, November 10, 2011 1:09 PM
To: EXT-York, Gantry
Cc: cmake@cmake.org
Subject: Re: [CMake] Where are tests located?

When you add an IMPORTED target, CMake does not know where the
imported target is AT ALL until you tell it.

After:
  add_executable(run_main.pl IMPORTED)

You need:
  set_property(TARGET run_main.pl PROPERTY IMPORTED_LOCATION
"${CMAKE_CURRENT_SOURCE_DIR}/run_main.pl")

See docs here:
  http://cmake.org/cmake/help/cmake-2-8-docs.html#command:set_property
  http://cmake.org/cmake/help/cmake-2-8-docs.html#prop_tgt:IMPORTED_LOCATION


HTH,
David


On Thu, Nov 10, 2011 at 3:00 PM, EXT-York, Gantry
 wrote:
> When I do an
>
>
>
> add_executable( run_main.pl IMPORTED)
>
> add_test( test1 run_main.pl)
>
>
>
> How does it know where run_main.pl is located when you do an out of source
> build?
>
>
>
> It seems to look in
>
> .
>
> Releases
>
> Debug
>
> MinSizeRel
>
> RelWithDebInfo
>
> Deployment
>
> Development
>
>
>
> which are directories that I don't even see existing.
>
>
>
> And if run_main.pl is just
>
>
>
> #!/usr/bin/perl
>
> system " ../exec/main"
>
>
>
>
>
> How does it know if ../exec/main is in the src tree or the build tree?  If
> main is a C binary, it would be in the build tree, if it is just a script it
> would be in the source tree.
>
>
>
>
>
>
>
>
>
> Gantry York
>
> Chandler, Arizona
>
>
>
> --
>
> 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
>
--

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


Re: [CMake] Where are tests located?

2011-11-10 Thread EXT-York, Gantry
add_test seems to work if you are adding an executable that is built, but if it 
is just a script that is imported, the cmake system is comfused as to where it 
is located and the script its doesn't know where the executable is.

Gantry York
Chandler, Arizona



From: cmake-boun...@cmake.org [mailto:cmake-boun...@cmake.org] On Behalf Of 
EXT-York, Gantry
Sent: Thursday, November 10, 2011 1:01 PM
To: cmake@cmake.org
Subject: [CMake] Where are tests located?

When I do an

add_executable( run_main.pl IMPORTED)
add_test( test1 run_main.pl)

How does it know where run_main.pl is located when you do an out of source 
build?

It seems to look in
.
Releases
Debug
MinSizeRel
RelWithDebInfo
Deployment
Development

which are directories that I don't even see existing.

And if run_main.pl is just

#!/usr/bin/perl
system " ../exec/main"


How does it know if ../exec/main is in the src tree or the build tree?  If main 
is a C binary, it would be in the build tree, if it is just a script it would 
be in the source tree.




Gantry York
Chandler, Arizona

--

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

Re: [CMake] Where are tests located?

2011-11-10 Thread David Cole
When you add an IMPORTED target, CMake does not know where the
imported target is AT ALL until you tell it.

After:
  add_executable(run_main.pl IMPORTED)

You need:
  set_property(TARGET run_main.pl PROPERTY IMPORTED_LOCATION
"${CMAKE_CURRENT_SOURCE_DIR}/run_main.pl")

See docs here:
  http://cmake.org/cmake/help/cmake-2-8-docs.html#command:set_property
  http://cmake.org/cmake/help/cmake-2-8-docs.html#prop_tgt:IMPORTED_LOCATION


HTH,
David


On Thu, Nov 10, 2011 at 3:00 PM, EXT-York, Gantry
 wrote:
> When I do an
>
>
>
> add_executable( run_main.pl IMPORTED)
>
> add_test( test1 run_main.pl)
>
>
>
> How does it know where run_main.pl is located when you do an out of source
> build?
>
>
>
> It seems to look in
>
> .
>
> Releases
>
> Debug
>
> MinSizeRel
>
> RelWithDebInfo
>
> Deployment
>
> Development
>
>
>
> which are directories that I don’t even see existing.
>
>
>
> And if run_main.pl is just
>
>
>
> #!/usr/bin/perl
>
> system “ ../exec/main”
>
>
>
>
>
> How does it know if ../exec/main is in the src tree or the build tree?  If
> main is a C binary, it would be in the build tree, if it is just a script it
> would be in the source tree.
>
>
>
>
>
>
>
>
>
> Gantry York
>
> Chandler, Arizona
>
>
>
> --
>
> 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
>
--

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


[CMake] Where are tests located?

2011-11-10 Thread EXT-York, Gantry
When I do an

add_executable( run_main.pl IMPORTED)
add_test( test1 run_main.pl)

How does it know where run_main.pl is located when you do an out of source 
build?

It seems to look in
.
Releases
Debug
MinSizeRel
RelWithDebInfo
Deployment
Development

which are directories that I don't even see existing.

And if run_main.pl is just

#!/usr/bin/perl
system " ../exec/main"


How does it know if ../exec/main is in the src tree or the build tree?  If main 
is a C binary, it would be in the build tree, if it is just a script it would 
be in the source tree.




Gantry York
Chandler, Arizona

--

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