[CMake] Re: TRY_COMPILE painful for tool testing

Arjen Markus arjen.markus at wldelft.nl
Thu Sep 21 12:48:56 EDT 2006


Like I promised, here is the information I have on this bug:

A simple Fortran program:

----
! Program to test the CMake utility
! - support for CVF?
!
program hello
    write(*,*) 'Hello'
end program
----
And an equally simple CMakeLists.txt:

----
project (HELLO)
enable_language(Fortran)

add_executable( hello hello.f90 )
----

The Compaq Visual Fortran compiler is described in a module
which contains the following macro for compiling a source file:

----
SET(CMAKE_Fortran_COMPILE_OBJECT
    "<CMAKE_Fortran_COMPILER>  ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}
/object:<OBJECT> <FLAGS> /compile_only <SOURCE>${CMAKE_END_TEMP_FILE}")
----

When I run CMake (with the flags --debug-trycompile and -G "NMake
Makefiles"), I get the following log file:

----
Determining if the Fortran compiler works failed with the following output:
	nmake -f CMakeFiles\cmTryCompileExec.dir/build.make /nologo -L
     CMakeFiles\cmTryCompileExec.dir\build

	c:\arjen\cmake\install\bin\Debug\cmake.exe -E cmake_progress_report
C:\arjen\fortran\f-cmake\CMakeFiles\CMakeTmp\CMakeFiles 1

Building Fortran object
CMakeFiles/cmTryCompileExec.dir/testFortranCompiler.obj
	C:\PROGRA~1\MIAF9D~1\DF98\BIN\DF.EXE
@C:\DOCUME~1\HP_EIG~1\LOCALS~1\Temp\nma04136.

DF: error: Unknown switch: '/cmTryCompileExec.dir'

NMAKE : fatal error U1077: 'C:\PROGRA~1\MIAF9D~1\DF98\BIN\DF.EXE' : return
code '0x1'

Stop.

NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual
Studio\VC98\BIN\nmake.exe"' : return code '0x2'

Stop.


----

The makefile that is used for the TRY_COMPILE step has the following
fragment:
----

CMakeFiles\cmTryCompileExec.dir\testFortranCompiler.obj:
CMakeFiles\cmTryCompileExec.dir\flags.make
CMakeFiles\cmTryCompileExec.dir\testFortranCompiler.obj:
testFortranCompiler.f	$(CMAKE_COMMAND) -E cmake_progress_report
C:\arjen\fortran\f-cmake\CMakeFiles\CMakeTmp\CMakeFiles $(CMAKE_PROGRESS_1)
	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building
Fortran object CMakeFiles/cmTryCompileExec.dir/testFortranCompiler.obj"
	C:\PROGRA~1\MIAF9D~1\DF98\BIN\DF.EXE   @<<
 /nologo /object:CMakeFiles/cmTryCompileExec.dir/testFortranCompiler.obj
$(Fortran_FLAGS) /compile_only
C:\arjen\fortran\f-cmake\CMakeFiles\CMakeTmp\testFortranCompiler.f
<<
----

As you can see, the source file is given with the native (Windows-style)
path, but the object file is specified with forward slashes. This is what
causes the compiler to complain.

(If you need more information on this, just ask)

Regards,

Arjen







More information about the CMake mailing list