ENH: make the test pass when fortran is gnu and c is cl

This commit is contained in:
Bill Hoffman 2008-11-06 17:33:42 -05:00
parent 86b123ba27
commit 49f393074c
1 changed files with 44 additions and 34 deletions

View File

@ -1,13 +1,13 @@
cmake_minimum_required (VERSION 2.6) cmake_minimum_required (VERSION 2.6)
PROJECT(testf C Fortran) project(testf Fortran C)
message("CTEST_FULL_OUTPUT ") message("CTEST_FULL_OUTPUT ")
SET(CMAKE_VERBOSE_MAKEFILE 1) set(CMAKE_VERBOSE_MAKEFILE 1)
MESSAGE("ENV_FLAGS = $ENV{FFLAGS}") message("ENV_FLAGS = $ENV{FFLAGS}")
MESSAGE("CMAKE_Fortran_COMPILER_INIT = ${CMAKE_Fortran_COMPILER_INIT}") message("CMAKE_Fortran_COMPILER_INIT = ${CMAKE_Fortran_COMPILER_INIT}")
MESSAGE("CMAKE_Fortran_COMPILER_FULLPATH = ${CMAKE_Fortran_COMPILER_FULLPATH}") message("CMAKE_Fortran_COMPILER_FULLPATH = ${CMAKE_Fortran_COMPILER_FULLPATH}")
MESSAGE("CMAKE_Fortran_COMPILER = ${CMAKE_Fortran_COMPILER}") message("CMAKE_Fortran_COMPILER = ${CMAKE_Fortran_COMPILER}")
MESSAGE("CMAKE_Fortran_FLAGS = ${CMAKE_Fortran_FLAGS}") message("CMAKE_Fortran_FLAGS = ${CMAKE_Fortran_FLAGS}")
ADD_EXECUTABLE(testf hello.f) add_executable(testf hello.f)
function(test_fortran_c_interface_module) function(test_fortran_c_interface_module)
@ -87,42 +87,52 @@ else()
message("Fortran does not match c compiler") message("Fortran does not match c compiler")
message("Fortran = ${CMAKE_Fortran_COMPILER_ID}") message("Fortran = ${CMAKE_Fortran_COMPILER_ID}")
message("C = ${CMAKE_C_COMPILER_ID}") message("C = ${CMAKE_C_COMPILER_ID}")
# hack to make g77 work after CL has been enabled
# as a languge, cmake needs language specific versions
# of these variables....
if(WIN32 AND "${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU")
set(CMAKE_CREATE_CONSOLE_EXE )
set(CMAKE_LIBRARY_PATH_FLAG "-L")
set(CMAKE_LINK_LIBRARY_FLAG "-l")
set(CMAKE_LINK_LIBRARY_SUFFIX )
endif()
endif() endif()
SET(TEST_MODULE_DEPENDS 0) set(TEST_MODULE_DEPENDS 0)
IF(CMAKE_Fortran_COMPILER_SUPPORTS_F90) if(CMAKE_Fortran_COMPILER_SUPPORTS_F90)
ADD_EXECUTABLE(test_module add_executable(test_module
test_module_main.f90 test_module_main.f90
test_module_implementation.f90 test_module_implementation.f90
test_module_interface.f90) test_module_interface.f90)
ADD_EXECUTABLE(test_use_in_comment_fixedform add_executable(test_use_in_comment_fixedform
test_use_in_comment_fixedform.f) test_use_in_comment_fixedform.f)
ADD_EXECUTABLE(test_use_in_comment_freeform add_executable(test_use_in_comment_freeform
test_use_in_comment_freeform.f90) test_use_in_comment_freeform.f90)
ADD_EXECUTABLE(test_in_interface add_executable(test_in_interface
in_interface/main.f90 in_interface/main.f90
in_interface/module.f90) in_interface/module.f90)
ADD_DEFINITIONS(-DFOO -DBAR=1) add_definitions(-DFOO -DBAR=1)
ADD_EXECUTABLE(test_preprocess test_preprocess.F90) add_executable(test_preprocess test_preprocess.F90)
SET(TEST_MODULE_DEPENDS 1) set(TEST_MODULE_DEPENDS 1)
ENDIF(CMAKE_Fortran_COMPILER_SUPPORTS_F90) endif(CMAKE_Fortran_COMPILER_SUPPORTS_F90)
IF(TEST_MODULE_DEPENDS) if(TEST_MODULE_DEPENDS)
# Build the external project separately using a custom target. # Build the external project separately using a custom target.
# Make sure it uses the same build configuration as this test. # Make sure it uses the same build configuration as this test.
IF(CMAKE_CONFIGURATION_TYPES) if(CMAKE_CONFIGURATION_TYPES)
SET(External_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}") set(External_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}")
ELSE(CMAKE_CONFIGURATION_TYPES) else(CMAKE_CONFIGURATION_TYPES)
SET(External_CONFIG_TYPE) set(External_CONFIG_TYPE)
ENDIF(CMAKE_CONFIGURATION_TYPES) endif(CMAKE_CONFIGURATION_TYPES)
ADD_CUSTOM_COMMAND( add_custom_command(
OUTPUT ${testf_BINARY_DIR}/ExternalProject OUTPUT ${testf_BINARY_DIR}/ExternalProject
COMMAND ${CMAKE_CTEST_COMMAND} COMMAND ${CMAKE_CTEST_COMMAND}
ARGS ${External_CONFIG_TYPE} ARGS ${External_CONFIG_TYPE}
@ -141,15 +151,15 @@ IF(TEST_MODULE_DEPENDS)
-DCMAKE_Fortran_FLAGS_MINSIZEREL:STRING=${CMAKE_Fortran_FLAGS_MINSIZEREL} -DCMAKE_Fortran_FLAGS_MINSIZEREL:STRING=${CMAKE_Fortran_FLAGS_MINSIZEREL}
-DCMAKE_Fortran_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_Fortran_FLAGS_RELWITHDEBINFO} -DCMAKE_Fortran_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_Fortran_FLAGS_RELWITHDEBINFO}
) )
ADD_CUSTOM_TARGET(ExternalTarget ALL DEPENDS ${testf_BINARY_DIR}/ExternalProject) add_custom_target(ExternalTarget ALL DEPENDS ${testf_BINARY_DIR}/ExternalProject)
# Test module output directory if available. # Test module output directory if available.
IF(CMAKE_Fortran_MODDIR_FLAG) if(CMAKE_Fortran_MODDIR_FLAG)
SET(Library_MODDIR "${testf_BINARY_DIR}/Library/modules") set(Library_MODDIR "${testf_BINARY_DIR}/Library/modules")
ELSE(CMAKE_Fortran_MODDIR_FLAG) else(CMAKE_Fortran_MODDIR_FLAG)
SET(Library_MODDIR "${testf_BINARY_DIR}/Library") set(Library_MODDIR "${testf_BINARY_DIR}/Library")
ENDIF(CMAKE_Fortran_MODDIR_FLAG) endif(CMAKE_Fortran_MODDIR_FLAG)
ADD_SUBDIRECTORY(Library) add_subdirectory(Library)
ADD_SUBDIRECTORY(Executable) add_subdirectory(Executable)
ENDIF(TEST_MODULE_DEPENDS) endif(TEST_MODULE_DEPENDS)