summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorulrich.bauer@gmail.com <ulrich.bauer@gmail.com@8e3bb3c2-eed4-f18f-5264-0b6c94e6926d>2013-03-29 09:41:53 +0000
committerulrich.bauer@gmail.com <ulrich.bauer@gmail.com@8e3bb3c2-eed4-f18f-5264-0b6c94e6926d>2013-03-29 09:41:53 +0000
commit49fb804f7b91874157dd079a4a25d25de611613c (patch)
treeae64f46bf2b82ff356a3b9672cdc9be011e5f42e /CMakeLists.txt
parent21a0ff691cd5470aa7e8ddee01ee45142679b3c0 (diff)
OpenMP version check
git-svn-id: https://phat.googlecode.com/svn/trunk@11 8e3bb3c2-eed4-f18f-5264-0b6c94e6926d
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt29
1 files changed, 26 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e670d81..98ffc17 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,15 +1,38 @@
cmake_minimum_required(VERSION 2.8)
+set(CMAKE_BUILD_TYPE "Release")
+
+INCLUDE(CheckCXXSourceCompiles)
+
include_directories (include)
FIND_PACKAGE(OpenMP)
-if(OPENMP_FOUND)
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
+set (CMAKE_REQUIRED_FLAGS ${OpenMP_CXX_FLAGS})
+CHECK_CXX_SOURCE_COMPILES("
+#include <omp.h>
+int main() {
+#if (_OPENMP >= 200805)
+ return 0;
+#else
+ breaks_on_purpose
+#endif
+}
+" OPENMP_VERSION)
+
+if(OPENMP_VERSION)
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
else()
-message("OpenMP not supported by the compiler! \nTo get optimal performance for the \"chunk\" algorithm, use a C++ compiler with OpenMP support (e.g., GCC).\nTo use a different compiler, pass it to cmake in the variable CMAKE_CXX_COMPILER: \n cmake . -DCMAKE_CXX_COMPILER=g++")
+message("
+
+OpenMP 3.0 not supported by the compiler (${CMAKE_CXX_COMPILER})!
+To get optimal performance for the \"chunk\" algorithm, use a C++ compiler with OpenMP 3.0 support (e.g., GCC >=4.4).
+To use a different compiler, pass it to cmake in the variable CMAKE_CXX_COMPILER:
+ cmake . -DCMAKE_CXX_COMPILER=g++-4.7
+
+")
endif()
add_executable (simple_example src/simple_example.cpp)