[Cmake-commits] [cmake-commits] king committed CMakeLists.txt NONE 1.3.2.2 Flags.cmake.in NONE 1.2.2.2 test_opt.sh.in NONE 1.1.2.2

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Jan 28 16:48:18 EST 2010


Update of /cvsroot/CMake/CMake/Tests/FortranC
In directory public:/mounts/ram/cvs-serv23913/Tests/FortranC

Added Files:
      Tag: CMake-2-8
	CMakeLists.txt Flags.cmake.in test_opt.sh.in 
Log Message:
CMake 2.8.1-rc1


--- NEW FILE: test_opt.sh.in ---
#!/bin/sh

TEST_OPT_ at ID@_FOUND=0
ARGS=""
for a in "$@"; do
    if [ "x${TEST_OPT_ at ID@}" != "x" -a "x${TEST_OPT_ at ID@}" = "x$a" ]; then
        TEST_OPT_ at ID@_FOUND=1
    else
        ARGS="$ARGS \"$a\""
    fi
done

if [ "x${TEST_OPT_ at ID@}" != "x" -a "x${TEST_OPT_ at ID@_FOUND}" != "x1" ]; then
    echo "Not given option '${TEST_OPT_ at ID@}' as expected!"
    exit 1
fi

eval "\"@COMMAND@\"" "$ARGS"

--- NEW FILE: Flags.cmake.in ---
set(src "@CMAKE_CURRENT_SOURCE_DIR@/FortranC")
set(bld "@CMAKE_CURRENT_BINARY_DIR@/FortranC/Flags")

# Create wrapper scripts for the compilers that check for expected
# flags, remove them, and invoke the real compiler.
set(ID "CC")
set(COMMAND "@CMAKE_C_COMPILER@")
configure_file("${src}/test_opt.sh.in" "${bld}/cc.sh" @ONLY)
set(ID "FC")
set(COMMAND "@CMAKE_Fortran_COMPILER@")
configure_file("${src}/test_opt.sh.in" "${bld}/fc.sh" @ONLY)
set(ID)
set(COMMAND)

execute_process(
  WORKING_DIRECTORY "${bld}"
  COMMAND ${CMAKE_COMMAND} "${src}" -G "@CMAKE_TEST_GENERATOR@"
                           "-DFortranC_TEST_FLAGS=1"
                           "-DCMAKE_C_COMPILER=${bld}/cc.sh"
                           "-DCMAKE_C_FLAGS:STRING=@CMAKE_C_FLAGS@"
                           "-DCMAKE_Fortran_COMPILER=${bld}/fc.sh"
                           "-DCMAKE_Fortran_FLAGS:STRING=@CMAKE_Fortran_FLAGS@"
  RESULT_VARIABLE result
  )

if(NOT "${result}" STREQUAL "0")
  message(FATAL_ERROR "Configuration failed: ${result}")
endif()

--- NEW FILE: CMakeLists.txt ---
cmake_minimum_required(VERSION 2.8)
project(FortranC C Fortran)

# Skip this test for compilers not known to be compatible.
if(NOT ("${CMAKE_C_COMPILER_ID}" STREQUAL "${CMAKE_Fortran_COMPILER_ID}" OR
        "${CMAKE_C_COMPILER_ID}-${CMAKE_Fortran_COMPILER_ID}" MATCHES "^(MSVC-Intel)$"))
  message(STATUS "${CMAKE_C_COMPILER_ID} C and ${CMAKE_Fortran_COMPILER_ID} Fortran not known to be compatible!")
  return()
endif()

# Wipe out all FortranCInterface information to ensure it re-runs.
file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/CMakeFiles/FortranCInterface)

if(FortranC_TEST_FLAGS)
  # Test whether FortranCInterface checks see C flags.
  set(ENV{TEST_OPT_CC} "--test-opt-cc=1")
  set(CMAKE_C_FLAGS "$ENV{TEST_OPT_CC} ${CMAKE_C_FLAGS}")

  # Test whether FortranCInterface checks see Fortran flags.
  set(ENV{TEST_OPT_FC} "--test-opt-fc=1")
  set(CMAKE_Fortran_FLAGS "$ENV{TEST_OPT_FC} ${CMAKE_Fortran_FLAGS}")
endif()

include(FortranCInterface)
FortranCInterface_VERIFY()



More information about the Cmake-commits mailing list