]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
CMake: Bugfix, use use supplied cxx flags throughout the configure phase, clean up...
authormaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 30 Jul 2013 08:58:51 +0000 (08:58 +0000)
committermaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 30 Jul 2013 08:58:51 +0000 (08:58 +0000)
git-svn-id: https://svn.dealii.org/trunk@30182 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/cmake/checks/check_01_cpu_features.cmake
deal.II/cmake/checks/check_02_system_features.cmake
deal.II/cmake/configure/configure_1_lapack.cmake
deal.II/cmake/configure/configure_1_threads.cmake
deal.II/cmake/configure/configure_2_trilinos.cmake
deal.II/cmake/macros/macro_enable_if_links.cmake
deal.II/cmake/macros/macro_reset_cmake_required.cmake [new file with mode: 0644]
deal.II/cmake/setup_compiler_flags.cmake
deal.II/doc/development/cmake-internals.html

index 90b1e1a93d1b2de2e9f79cde10fc0cc9e0275883..79a5a661b759d80a88976ee9f919f31979a850f6 100644 (file)
@@ -51,14 +51,6 @@ ENDIF()
 
 
 IF(DEAL_II_ALLOW_PLATFORM_INTROSPECTION)
-
-  #
-  # These tests depend on certain cpu instruction sets being enabled, so
-  # use the user supplied compiler flags for the tests as well:
-  #
-  SET(CMAKE_REQUIRED_FLAGS "${CMAKE_CXX_FLAGS_SAVED}")
-
-
   #
   # Take care that the following tests are rerun if CMAKE_REQUIRED_FLAGS
   # changes..
@@ -144,10 +136,9 @@ IF(DEAL_II_ALLOW_PLATFORM_INTROSPECTION)
     }
     "
     DEAL_II_HAVE_AVX)
-
-  SET(CMAKE_REQUIRED_FLAGS "")
 ENDIF()
 
+
 IF(DEAL_II_HAVE_SSE2)
   IF(DEAL_II_HAVE_AVX)
     SET(DEAL_II_COMPILER_VECTORIZATION_LEVEL 2)
@@ -157,4 +148,3 @@ IF(DEAL_II_HAVE_SSE2)
 ELSE()
   SET(DEAL_II_COMPILER_VECTORIZATION_LEVEL 0)
 ENDIF()
-
index 25d54167f5ec48f8e11626840cb79c146c882e4f..84923253446dad0e65b39fc5b224d86978d5fab1 100644 (file)
@@ -68,9 +68,9 @@ SWITCH_LIBRARY_PREFERENCE()
 MARK_AS_ADVANCED(m_LIBRARY)
 
 IF(NOT m_LIBRARY MATCHES "-NOTFOUND")
-  SET(CMAKE_REQUIRED_LIBRARIES ${m_LIBRARY})
+  LIST(APPEND CMAKE_REQUIRED_LIBRARIES ${m_LIBRARY})
   CHECK_CXX_SYMBOL_EXISTS("jn" "math.h" HAVE_JN)
-  SET(CMAKE_REQUIRED_LIBRARIES)
+  RESET_CMAKE_REQUIRED()
   IF(HAVE_JN)
     LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES ${m_LIBRARY})
   ENDIF()
index a319fe155b5fdd9859aa01d7745a31834d77f132..85e063eae08bb7a693e8ca05fb53aca0bf9a6046 100644 (file)
@@ -97,7 +97,7 @@ SET(DEAL_II_LAPACK_FUNCTIONS
   )
 
 MACRO(CHECK_FOR_LAPACK_FUNCTIONS)
-  SET(CMAKE_REQUIRED_LIBRARIES ${LAPACK_LIBRARIES})
+  LIST(APPEND CMAKE_REQUIRED_LIBRARIES ${LAPACK_LIBRARIES})
   ADD_FLAGS(CMAKE_REQUIRED_FLAGS "${LAPACK_LINKER_FLAGS}")
   #
   # Push -pthread as well:
@@ -118,9 +118,7 @@ MACRO(CHECK_FOR_LAPACK_FUNCTIONS)
     ENDFOREACH()
   ENDIF()
 
-  SET(CMAKE_REQUIRED_LIBRARIES)
-  STRIP_FLAG(CMAKE_REQUIRED_FLAGS "${LAPACK_LINKER_FLAGS}")
-  STRIP_FLAG(CMAKE_REQUIRED_FLAGS "-pthread")
+  RESET_CMAKE_REQUIRED()
 ENDMACRO()
 
 
index 8525ad770ea16b5c61560ce9c0203143e94c548b..a21ed1eeb1821d8e95a9bdc2c8f4cc2646443099 100644 (file)
@@ -112,7 +112,7 @@ MACRO(SETUP_THREADING)
     }
     "
     DEAL_II_HAVE_MT_POSIX_BARRIERS)
-    STRIP_FLAG(CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}")
+    RESET_CMAKE_REQUIRED()
     IF(NOT DEAL_II_HAVE_MT_POSIX_BARRIERS)
       SET(DEAL_II_USE_MT_POSIX_NO_BARRIERS TRUE)
     ENDIF()
index 41a5f93bf5bd9988242059a9ee8498f70284f711..10cbe49551a26e256c60b161b4cc56bf9a5f7db4 100644 (file)
@@ -162,7 +162,7 @@ MACRO(FEATURE_TRILINOS_FIND_EXTERNAL var)
     # Test whether that is indeed the case
     #
     IF(${var})
-      SET(CMAKE_REQUIRED_INCLUDES ${TRILINOS_INCLUDE_DIRS})
+      LIST(APPEND CMAKE_REQUIRED_INCLUDES ${TRILINOS_INCLUDE_DIRS})
       PUSH_TEST_FLAG("${DEAL_II_CXX11_FLAG}")
 
       CHECK_CXX_SOURCE_COMPILES(
@@ -203,8 +203,7 @@ MACRO(FEATURE_TRILINOS_FIND_EXTERNAL var)
         ENDIF()
       ENDIF()
 
-      POP_TEST_FLAG()
-      SET(CMAKE_REQUIRED_INCLUDES)
+      RESET_CMAKE_REQUIRED()
 
       #
       # Remove the following variables from the cache to force a recheck:
index 0f4ef07e965dd60217f757a4ba4df91f94f88735..6c2bfeb6d1b667cfa182cba1d6fd465c6f4d49af 100644 (file)
@@ -30,7 +30,7 @@ MACRO(ENABLE_IF_LINKS _variable _flag)
     STRING(REPLACE "," "" _flag_name "${_flag_name}")
     STRING(REPLACE "--" "__" _flag_name "${_flag_name}")
     SET(_backup ${CMAKE_REQUIRED_LIBRARIES})
-    SET(CMAKE_REQUIRED_LIBRARIES "${_flag_stripped}")
+    LIST(APPEND CMAKE_REQUIRED_LIBRARIES "${_flag_stripped}")
     CHECK_CXX_COMPILER_FLAG(
       ""
       DEAL_II_HAVE_FLAG_${_flag_name}
diff --git a/deal.II/cmake/macros/macro_reset_cmake_required.cmake b/deal.II/cmake/macros/macro_reset_cmake_required.cmake
new file mode 100644 (file)
index 0000000..0f2865a
--- /dev/null
@@ -0,0 +1,30 @@
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2013 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
+
+#
+# A small macro to reset the CMAKE_REQUIRED_* variables to its default
+# values
+#
+# Usage:
+#     RESET_CMAKE_REQUIRED_FLAGS
+#
+
+MACRO(RESET_CMAKE_REQUIRED)
+  SET(CMAKE_REQUIRED_FLAGS ${CMAKE_CXX_FLAGS_SAVED})
+  SET(CMAKE_REQUIRED_INCLUDES)
+  SET(CMAKE_REQUIRED_LIBRARIES)
+ENDMACRO()
+
index 4815abf65fafa4af54fa8ac1da7d89f2afa25a42..f82147f9e816f215f3a142bb4d2d2531bb573606 100644 (file)
 #
 # Check the user provided CXX flags:
 #
+
 MESSAGE(STATUS "")
 IF(NOT "${CMAKE_CXX_FLAGS_SAVED}" STREQUAL "${DEAL_II_CXX_FLAGS_SAVED}")
+  # Rerun this test if cxx flags changed:
   UNSET(DEAL_II_HAVE_USABLE_CXX_FLAGS CACHE)
 ENDIF()
 SET(DEAL_II_CXX_FLAGS_SAVED "${CMAKE_CXX_FLAGS_SAVED}" CACHE INTERNAL "" FORCE)
 
-SET(CMAKE_REQUIRED_FLAGS "${CMAKE_CXX_FLAGS_SAVED}")
+# Initialize all CMAKE_REQUIRED_* variables a this point:
+RESET_CMAKE_REQUIRED()
+
 CHECK_CXX_SOURCE_COMPILES(
   "int main(){ return 0; }"
   DEAL_II_HAVE_USABLE_CXX_FLAGS)
-SET(CMAKE_REQUIRED_FLAGS "")
 
 IF(NOT DEAL_II_HAVE_USABLE_CXX_FLAGS)
   UNSET(DEAL_II_HAVE_USABLE_CXX_FLAGS CACHE)
   MESSAGE(FATAL_ERROR "\n"
-    "Configuration error: Cannot compile with the specified CXX flags: "
+    "Configuration error: Cannot compile with the user supplied CXX flags:\n"
     "${CMAKE_CXX_FLAGS_SAVED}\n"
     )
 ENDIF()
index e889a4ea82fcf8a319e0d214c5227065968b1d68..1822169adbc4a92090546a4399f49b0e89106bdd 100644 (file)
     POP_TEST_FLAG()
          </pre>
 
-       <li> Libraries necessary for linkage can be set in the list variable
-         <code>CMAKE_REQUIRED_LIBRARIES</code>. It is best two hard set
-         this variable to a specific value and later on cleaning it,
-         instead of appending/removing:
+        <li> Necessary include directories and libraries necessary for
+        linkage can be set in the list variables
+        <code>CMAKE_REQUIRED_INCLUDES</code> and
+        <code>CMAKE_REQUIRED_LIBRARIES</code>. It is best ot append these
+        lists and later on reset <code>CMAKE_REQUIRED_*</code> (including
+        <code>CMAKE_REQUIRED_FLAGS</code>) to their default values:
          <pre>
 
-    SET(CMAKE_REQUIRED_LIBRARIES &lt;a list of libraries&gt;
+    LIST(APPEND CMAKE_REQUIRED_INCLUDES &lt;a list of includes&gt;)
+    LIST(APPEND CMAKE_REQUIRED_LIBRARIES &lt;a list of libraries&gt;)
     CHECK_CXX_SOURCE_COMPILES(...)
-    SET(CMAKE_REQUIRED_LIBRARIES)
+    RESET_CMAKE_REQUIRED()
          </pre>
       </ul>
     </p>

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.