[Cmake] Help!

Richard Wackerbarth rkw at Dataplex.Net
Sat, 20 Mar 2004 19:40:41 -0600


--Apple-Mail-1-594309640
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed

OK, I throw in the towel after spending the day trying to figure out 
what is going on.

I had observed a problem in the tclsh and set out to "fix" it.

First, I recognized that I needed a command to validate a particular 
shell.
As Andy pointed out, it is not difficult to run a test case through the 
intended
target and examine the output.

I put together a simple test and ran it against the various tcl shells 
available to me.

     EXEC_PROGRAM( tclsh ARGS "${CMAKE_ROOT}/Modules/TestTclShell.tcl"
	  OUTPUT_VARIABLE OUTPUT)

performs as expected

${OUTPUT}

gives the expected result. For example,

TCL version 8.4

I then tried to paraphrase other test commands.
But, although a null value gets added to the cache, this seems to 
totally fail.

MACRO(TEST_TCL_SHELL SHELL VARIABLE)
   IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
     MESSAGE(STATUS "Validating Tcl Shell ${SHELL}")
     EXEC_PROGRAM("${SHELL}" ARGS 
"${CMAKE_ROOT}/Modules/TestTclShell.tcl"
	  OUTPUT_VARIABLE OUTPUT)
	IF("${OUTPUT}" MATCHES "^TCL version ")
       SET(${VARIABLE} 1 CACHE INTERNAL "Is ${SHELL} a valid tcl shell")
       MESSAGE(STATUS "Validating Tcl Shell ${SHELL} - passed")
       FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeOutput.log
         "Validating Tcl Shell ${SHELL} -- passed with the following 
output:\n"
         "${OUTPUT}\n\n")
     ELSE("${OUTPUT}" MATCHES "^TCL version ")
       MESSAGE(STATUS "Validating Tcl Shell ${SHELL} - failed")
       SET(${VARIABLE} "" CACHE INTERNAL "Is ${SHELL} a valid tcl shell")
       FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log
         "Validating Tcl Shell ${SHELL} -- failed with the following 
output:\n"
         "${OUTPUT}\n\n")
     ENDIF("${OUTPUT}" MATCHES "^TCL version ")
   ENDIF("${VARIABLE}" MATCHES "^${VARIABLE}$")
ENDMACRO(TEST_TCL_SHELL)

I have two questions:

(1) What does this accomplish? If VARIABLE doesn't contain any 
non-alphanumeric characters, it seems that it should always match.

(2) I must be overlooking something trivial. The routine always fails 
with a null string for ${OUTPUT}.

Advise welcome,

Richard
--Apple-Mail-1-594309640
Content-Transfer-Encoding: 7bit
Content-Type: text/enriched;
	charset=US-ASCII

OK, I throw in the towel after spending the day trying to figure out
what is going on.


I had observed a problem in the tclsh and set out to "fix" it.


First, I recognized that I needed a command to validate a particular
shell.

As Andy pointed out, it is not difficult to run a test case through
the intended

target and examine the output.


I put together a simple test and ran it against the various tcl shells
available to me.


<fixed>    EXEC_PROGRAM( tclsh ARGS
"${CMAKE_ROOT}/Modules/TestTclShell.tcl"

	  OUTPUT_VARIABLE OUTPUT)

</fixed>

performs as expected


<fixed>${OUTPUT} </fixed>


gives the expected result. For example,


<fixed>TCL version 8.4

</fixed>

I then tried to paraphrase other test commands.

But, although a null value gets added to the cache, this seems to
totally fail.


<fixed>MACRO(TEST_TCL_SHELL SHELL VARIABLE)

  IF("${VARIABLE}" MATCHES "^${VARIABLE}$")

    MESSAGE(STATUS "Validating Tcl Shell ${SHELL}")

    EXEC_PROGRAM("${SHELL}" ARGS
"${CMAKE_ROOT}/Modules/TestTclShell.tcl"

	  OUTPUT_VARIABLE OUTPUT)

	IF("${OUTPUT}" MATCHES "^TCL version ")

      SET(${VARIABLE} 1 CACHE INTERNAL "Is ${SHELL} a valid tcl shell")

      MESSAGE(STATUS "Validating Tcl Shell ${SHELL} - passed")

      FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeOutput.log 

        "Validating Tcl Shell ${SHELL} -- passed with the following
output:\n"

        "${OUTPUT}\n\n")

    ELSE("${OUTPUT}" MATCHES "^TCL version ")

      MESSAGE(STATUS "Validating Tcl Shell ${SHELL} - failed")

      SET(${VARIABLE} "" CACHE INTERNAL "Is ${SHELL} a valid tcl
shell")

      FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log 

        "Validating Tcl Shell ${SHELL} -- failed with the following
output:\n"

        "${OUTPUT}\n\n")

    ENDIF("${OUTPUT}" MATCHES "^TCL version ")

  ENDIF("${VARIABLE}" MATCHES "^${VARIABLE}$")

ENDMACRO(TEST_TCL_SHELL)

</fixed>

I have two questions:


(1) What does this accomplish? If VARIABLE doesn't contain any
non-alphanumeric characters, it seems that it should always match.


(2) I must be overlooking something trivial. The routine always fails
with a null string for ${OUTPUT}.


Advise welcome,


Richard
--Apple-Mail-1-594309640--