[Cmake-commits] CMake branch, next, updated. v3.0.1-4937-g6cb7b0c

Brad King brad.king at kitware.com
Mon Aug 18 11:26:00 EDT 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  6cb7b0c64de916b439dfe060a723462536ad6e91 (commit)
       via  d0678408543d362f127b9ee45453283e38c25415 (commit)
      from  cfe1c3f8f842b25da627e959d26077ef35b118fc (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6cb7b0c64de916b439dfe060a723462536ad6e91
commit 6cb7b0c64de916b439dfe060a723462536ad6e91
Merge: cfe1c3f d067840
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Aug 18 11:25:59 2014 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Aug 18 11:25:59 2014 -0400

    Merge topic 'FindOpenMP-add-Fortran-support' into next
    
    d0678408 FindOpenMP: Add support for Fortran (#14656)


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d0678408543d362f127b9ee45453283e38c25415
commit d0678408543d362f127b9ee45453283e38c25415
Author:     Nicolas Bock <nicolasbock at gmail.com>
AuthorDate: Wed Aug 6 10:08:00 2014 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Aug 18 11:25:21 2014 -0400

    FindOpenMP: Add support for Fortran (#14656)

diff --git a/Help/release/dev/FindOpenMP-add-Fortran-support.rst b/Help/release/dev/FindOpenMP-add-Fortran-support.rst
new file mode 100644
index 0000000..0205718
--- /dev/null
+++ b/Help/release/dev/FindOpenMP-add-Fortran-support.rst
@@ -0,0 +1,4 @@
+FindOpenMP-add-Fortran-support
+------------------------------
+
+* The :module:`FindOpenMP` module learned to support Fortran.
diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake
index 935a0ca..801b4f8 100644
--- a/Modules/FindOpenMP.cmake
+++ b/Modules/FindOpenMP.cmake
@@ -16,6 +16,7 @@
 #
 #    OpenMP_C_FLAGS - flags to add to the C compiler for OpenMP support
 #    OpenMP_CXX_FLAGS - flags to add to the CXX compiler for OpenMP support
+#    OpenMP_Fortran_FLAGS - flags to add to the Fortran compiler for OpenMP support
 #    OPENMP_FOUND - true if openmp is detected
 #
 #
@@ -27,6 +28,7 @@
 # Copyright 2009 Kitware, Inc.
 # Copyright 2008-2009 André Rigland Brodtkorb <Andre.Brodtkorb at ifi.uio.no>
 # Copyright 2012 Rolf Eike Beer <eike at sf-mail.de>
+# Copyright 2014 Nicolas Bock <nicolasbock at gmail.com>
 #
 # Distributed under the OSI-approved BSD License (the "License");
 # see accompanying file Copyright.txt for details.
@@ -106,6 +108,17 @@ int main() {
 }
 ")
 
+# same in Fortran
+set(OpenMP_Fortran_TEST_SOURCE
+  "
+program test
+use omp_lib
+integer :: n
+n = omp_get_num_threads()
+end program test
+  "
+  )
+
 # check c compiler
 if(CMAKE_C_COMPILER_LOADED)
   # if these are set then do not try to find them again,
@@ -176,6 +189,40 @@ if(CMAKE_CXX_COMPILER_LOADED)
   unset(OpenMP_CXX_TEST_SOURCE)
 endif()
 
+# check Fortran compiler
+if(CMAKE_Fortran_COMPILER_LOADED)
+  # if these are set then do not try to find them again,
+  # by avoiding any try_compiles for the flags
+  if(OpenMP_Fortran_FLAGS)
+    unset(OpenMP_Fortran_FLAG_CANDIDATES)
+  else()
+    _OPENMP_FLAG_CANDIDATES("Fortran")
+    include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranSourceCompiles.cmake)
+  endif()
+
+  foreach(FLAG IN LISTS OpenMP_Fortran_FLAG_CANDIDATES)
+    set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
+    set(CMAKE_REQUIRED_FLAGS "${FLAG}")
+    unset(OpenMP_FLAG_DETECTED CACHE)
+    if(NOT CMAKE_REQUIRED_QUIET)
+      message(STATUS "Try OpenMP Fortran flag = [${FLAG}]")
+    endif()
+    check_fortran_source_compiles("${OpenMP_Fortran_TEST_SOURCE}" OpenMP_FLAG_DETECTED)
+    set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")
+    if(OpenMP_FLAG_DETECTED)
+      set(OpenMP_Fortran_FLAGS_INTERNAL "${FLAG}")
+      break()
+    endif()
+  endforeach()
+
+  set(OpenMP_Fortran_FLAGS "${OpenMP_Fortran_FLAGS_INTERNAL}"
+    CACHE STRING "Fortran compiler flags for OpenMP parallization")
+
+  list(APPEND _OPENMP_REQUIRED_VARS OpenMP_Fortran_FLAGS)
+  unset(OpenMP_Fortran_FLAG_CANDIDATES)
+  unset(OpenMP_Fortran_TEST_SOURCE)
+endif()
+
 set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
 
 if(_OPENMP_REQUIRED_VARS)

-----------------------------------------------------------------------

Summary of changes:
 .../release/dev/FindOpenMP-add-Fortran-support.rst |    4 ++
 Modules/FindOpenMP.cmake                           |   47 ++++++++++++++++++++
 2 files changed, 51 insertions(+)
 create mode 100644 Help/release/dev/FindOpenMP-add-Fortran-support.rst


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list