summaryrefslogtreecommitdiffstats
path: root/Tests/FortranC/Flags.cmake.in
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-12-14 17:36:25 (GMT)
committerBrad King <brad.king@kitware.com>2009-12-14 17:36:25 (GMT)
commit555fcbd2e2e5cafbb7cbf55b88093cc8f73a8009 (patch)
tree2ab8a9c2032c7ce1a9c27b31570e02cfd8b69af2 /Tests/FortranC/Flags.cmake.in
parent126c93cddae95f46060f6d88af9c92dc6297f88d (diff)
downloadCMake-555fcbd2e2e5cafbb7cbf55b88093cc8f73a8009.zip
CMake-555fcbd2e2e5cafbb7cbf55b88093cc8f73a8009.tar.gz
CMake-555fcbd2e2e5cafbb7cbf55b88093cc8f73a8009.tar.bz2
Test FortranCInterface flag propagation
We create test FortranC.Flags to try passing per-language flags from a project into its FortranCInterface detect/verify checks. We wrap the compilers with scripts that enforce presence of expected flags.
Diffstat (limited to 'Tests/FortranC/Flags.cmake.in')
-rw-r--r--Tests/FortranC/Flags.cmake.in29
1 files changed, 29 insertions, 0 deletions
diff --git a/Tests/FortranC/Flags.cmake.in b/Tests/FortranC/Flags.cmake.in
new file mode 100644
index 0000000..8bf0c5c
--- /dev/null
+++ b/Tests/FortranC/Flags.cmake.in
@@ -0,0 +1,29 @@
+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)
+
+set(ENV{CFLAGS})
+set(ENV{FFLAGS})
+
+execute_process(
+ WORKING_DIRECTORY "${bld}"
+ COMMAND ${CMAKE_COMMAND} "${src}" -G "@CMAKE_TEST_GENERATOR@"
+ "-DFortranC_TEST_FLAGS=1"
+ "-DCMAKE_C_COMPILER=${bld}/cc.sh"
+ "-DCMAKE_Fortran_COMPILER=${bld}/fc.sh"
+ RESULT_VARIABLE result
+ )
+
+if(NOT "${result}" STREQUAL "0")
+ message(FATAL_ERROR "Configuration failed: ${result}")
+endif()