View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001492CMakepublic2005-01-17 17:522005-04-05 15:34
ReporterMathieu Malaterre 
Assigned ToKen Martin 
PrioritylowSeverityminorReproducibilityalways
StatusclosedResolutionno change required 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0001492: TRY_COMPILE and WRITE_FILE
DescriptionThis script is creating a CMake Error:

#-----------------------------------------------------------------------------
# Test if os defines a lenght for sockaddr
IF("GDCM_OS_HAVE_SA_LEN" MATCHES "^GDCM_OS_HAVE_SA_LEN$")
  STRING(ASCII 35 POUND)
  FILE(WRITE ${GDCM_BINARY_DIR}/CMakeTmp/gdcmTestHAVESALEN.c
    "${POUND}include <sys/types.h>\n"
    "${POUND}include <sys/socket.h>\n"
    "int main() { struct sockaddr sa; sa.sa_len = 0; }")
  MESSAGE(STATUS "Checking if ifreq has a sa_len")
  TRY_COMPILE(GDCM_OS_HAVE_SA_LEN
              ${GDCM_BINARY_DIR}/CMakeTmp/HaveSaLen
              ${GDCM_BINARY_DIR}/CMakeTmp/gdcmTestHAVESALEN.c
              OUTPUT_VARIABLE OUTPUT)
  IF(GDCM_OS_HAVE_SA_LEN)
    MESSAGE(STATUS "Checking if ifreq has a sa_len -- yes")
    SET(GDCM_OS_HAVE_SA_LEN 1 CACHE INTERNAL "Support if ifreq has a sa_len")
    WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeOutput.log
      "Determining if ifreq has a sa_len"
      "passed with the following output:\n"
      "${OUTPUT}\n" APPEND)
  ELSE(GDCM_OS_HAVE_SA_LEN)
    MESSAGE(STATUS "Checking if ifreq has a sa_len -- no")
    SET(GDCM_OS_HAVE_SA_LEN 0 CACHE INTERNAL "Support if ifreq has a sa_len")
    WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeError.log
      "Determining if ifreq has a sa_len"
      "failed with the following output:\n"
      "${OUTPUT}\n" APPEND)
  ENDIF(GDCM_OS_HAVE_SA_LEN)
ENDIF("GDCM_OS_HAVE_SA_LEN" MATCHES "^GDCM_OS_HAVE_SA_LEN$")
                                                                                                                                                             


CMake error is:

...
-- Checking if ifreq has a sa_len
-- Checking if ifreq has a sa_len -- no
...
-- Using Buildname: SunOS-CC
CMake Error: File /home/kitware/Dashboards/MyTests/gdcm-CC/CMakeTmp/gdcmTestHAVESALEN.c is written by WRITE_FILE (or FILE WRITE) command and should not be used as input to CMake. Please use CONFIGURE_FILE to be safe. Refer to the note next to FILE WRITE command.
CMake Error: File /home/kitware/Dashboards/MyTests/gdcm-CC/CMakeTmp/gdcmTestHAVESALEN.c is written by WRITE_FILE (or FILE WRITE) command and should not be used as input to CMake. Please use CONFIGURE_FILE to be safe. Refer to the note next to FILE WRITE command.
CMake Error: File /home/kitware/Dashboards/MyTests/gdcm-CC/CMakeTmp/gdcmTestHAVESALEN.c is written by WRITE_FILE (or FILE WRITE) command and should not be used as input to CMake. Please use CONFIGURE_FILE to be safe. Refer to the note next to FILE WRITE command.
...




Solution to fix the problem replace:
  TRY_COMPILE(GDCM_OS_HAVE_SA_LEN
              ${GDCM_BINARY_DIR}/CMakeTmp/HaveSaLen
              ${GDCM_BINARY_DIR}/CMakeTmp/gdcmTestHAVESALEN.c
              OUTPUT_VARIABLE OUTPUT)

by

  TRY_COMPILE(GDCM_OS_HAVE_SA_LEN
              ${GDCM_BINARY_DIR}
              ${GDCM_BINARY_DIR}/CMakeTmp/gdcmTestHAVESALEN.c
              OUTPUT_VARIABLE OUTPUT)

Doing the try compile within a different directory seems to be the problem.

Can reproduce it on MacOSX + cmake 2.0.3.
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0002291)
Bill Hoffman (manager)
2005-04-05 15:34

This seems to work in cvs and 2.0.5:

(if it can be reproduced with a small example, please re-open)
PROJECT(GDCM)

FILE(WRITE ${GDCM_BINARY_DIR}/CMakeTmp/gdcmTestHAVESALEN.c
    "#include <sys/types.h>n"
    "#include <sys/socket.h>n"
    "int main() { struct sockaddr sa; sa.sa_len = 0; }")
TRY_COMPILE(GDCM_OS_HAVE_SA_LEN
              ${GDCM_BINARY_DIR}/CMakeTmp/HaveSaLen
              ${GDCM_BINARY_DIR}/CMakeTmp/gdcmTestHAVESALEN.c
              OUTPUT_VARIABLE OUTPUT)
MESSAGE("${OUTPUT}")

 Issue History
Date Modified Username Field Change


Copyright © 2000 - 2018 MantisBT Team