View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0009323CMakeModulespublic2009-07-28 09:172016-06-10 14:30
ReporterMark Stijnman 
Assigned ToBill Hoffman 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionmoved 
PlatformOSOS Version
Product VersionCMake-2-6 
Target VersionFixed in Version 
Summary0009323: Fortran detection gives errors on windows when FFLAGS environment variable contains a path
DescriptionWhen using Intel Fortran with ISML libraries installed, the environment variable FFLAGS is set to FFLAGS=/w /I:"C:\Program Files\VNI\CTT6.0\include\IA32" /fpe:3 /nologo. When running CMake, this causes the errors seen in the attached file errors.txt. It does appear to report that the compiler works, though.
Additional InformationPossible solution: in CMakeFortranInformation.CMake, replace line 113 with:

FILE(TO_CMAKE_PATH "$ENV{FFLAGS}" FFLAGS)
SET(CMAKE_Fortran_FLAGS_INIT "${FFLAGS} ${CMAKE_Fortran_FLAGS_INIT}")

This fizes it for me.
TagsNo tags attached.
Attached Filestxt file icon errors.txt [^] (2,647 bytes) 2009-07-28 09:17 [Show Content]

 Relationships

  Notes
(0016987)
Bill Hoffman (manager)
2009-07-28 11:40

CMake expects posix's paths:

This should work:

FFLAGS=/w /I:"C:/Program Files/VNI/CTT6.0/include/IA32"
(0016988)
Mark Stijnman (reporter)
2009-07-28 12:34

Yes, of course I could change the environment variable, which is why I consider it a minor issue. But in this case, the environment variable is set by the ISML installer. All users with this library will get this problem. Also, if I'd have to re-install or upgrade some time in the future, I'd have to remember to change it again. It would be far better if CMake would simply accept windows paths on windows machines.

The fix I proposed performs that exact translation (I verified using a few message statements), leaving the other flags intact.
(0016989)
Bill Hoffman (manager)
2009-07-28 12:47

I don't think your fix will work, as those flags have other stuff in them, and it is not one path, but some flags and a path, the TO_CMAKE_PATH will fail on that as input.
(0016990)
Mark Stijnman (reporter)
2009-07-28 13:25

Well, I've tried it, and it's actually working for me.

But I'm quite willing to accept that this fix may rely on undefined behavior of TO_CMAKE_PATH, like how it responds to strings that consist of more than just a single path. I've also not checked what it does when you have multiple paths in the FFLAGS variable. Maybe a regex replace of all backward slashes to forward slashes would do the trick just fine too.
(0019000)
Mark Stijnman (reporter)
2009-12-28 13:24
edited on: 2009-12-29 04:38

We've recently migrated to Vista and VS 2008 with Intel Visual Fortran 11.1, and I wanted to upgrade to CMake 2.8.0 as well. It appears that the fix above indeed won't work in all cases, and still gives problem for VS2008 with IVF 11.1, so I had to revisit this issue, and study it in a bit more detail.

It turns out that the temporary CMakeLists.txt file that is generated by the try_compile command doesn't escape the contents of the FFLAGS environment variable. If this environment variable contains a directory with backslashes and quotation marks, as is the case on windows when you have IMSL installed, you will get problems. My earlier suggestion, as well as Bill Hoffman's suggestion in (0016987), only fixes the issues with the backslashes, not with the quotes.

I've tried to just modify the ENV{FFLAGS} variable and escape all quotes and backslashes, but then I get problems later on in the generated project files, where you don't want the extra escape characters.

So the recommended fix would be to add escaping the output for try_compile (in cmCoreTryCompile.cxx, lines 205-211).

For other users who have the same problem when using IMSL, I now have a better workaround, as given in the code below, which I now use in my main CMakeFiles.txt file. It filters out the include directory switches and passes those to the include_directories command instead. All the other parameters in FFLAGS are put back in the environment variable. Make sure it gets called before the enable_language(Fortran) command.

if (WIN32)
    if (DEFINED ENV{FFLAGS})
        separate_arguments(FFLAGS WINDOWS_COMMAND $ENV{FFLAGS})
        FOREACH(FFLAG IN LISTS FFLAGS)
            if (${FFLAG} MATCHES "^/I:.+")
                string (REPLACE "/I:" "" INCLUDE_DIR ${FFLAG})
                include_directories(${INCLUDE_DIR})
            else (${FFLAG} MATCHES "^/I:.+")
                set (FFLAGS2 "${FFLAGS2} ${FFLAG}")
            endif(${FFLAG} MATCHES "^/I:.+")
        ENDFOREACH(FFLAG IN LISTS ${FFLAGS})
        set(ENV{FFLAGS} "${FFLAGS2}")
    endif (DEFINED ENV{FFLAGS})
endif (WIN32)

It's not a generic solution, as it will still fail for any other commandline parameter that uses paths, but it works for all include options and solves the issue with the environment variable as set by the IMSL installer.

(0041581)
Kitware Robot (administrator)
2016-06-10 14:27

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2009-07-28 09:17 Mark Stijnman New Issue
2009-07-28 09:17 Mark Stijnman File Added: errors.txt
2009-07-28 11:40 Bill Hoffman Note Added: 0016987
2009-07-28 11:42 Bill Hoffman Status new => assigned
2009-07-28 11:42 Bill Hoffman Assigned To => Bill Hoffman
2009-07-28 12:34 Mark Stijnman Note Added: 0016988
2009-07-28 12:47 Bill Hoffman Note Added: 0016989
2009-07-28 13:25 Mark Stijnman Note Added: 0016990
2009-12-28 13:24 Mark Stijnman Note Added: 0019000
2009-12-29 04:29 Mark Stijnman Note Edited: 0019000
2009-12-29 04:38 Mark Stijnman Note Edited: 0019000
2016-06-10 14:27 Kitware Robot Note Added: 0041581
2016-06-10 14:27 Kitware Robot Status assigned => resolved
2016-06-10 14:27 Kitware Robot Resolution open => moved
2016-06-10 14:30 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team