From cd2daa69378b84a73f61f76b15ca90fd1901fae5 Mon Sep 17 00:00:00 2001
From: Kubat <mael.martin31@gmail.com>
Date: Wed, 16 Feb 2022 22:01:21 +0100
Subject: [PATCH] FIX: Try more ways to test for OpenMP and rectify the test
 program compilation

---
 CMakeLists.txt | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f9bfbe9f..1c7af52e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,6 +17,7 @@ set(THREADS_PREFER_PTHREAD_FLAG     ON)
 set(CMAKE_COLOR_MAKEFILE            ON)
 
 include(TestBigEndian)  # Needed for endianness tests
+include(FindOpenMP)     # Test OpenMP support
 include(GNUInstallDirs) # Needed for installation things
 
 set(${CMAKE_C_COMPILER_ID}_C_FLAGS)
@@ -233,15 +234,21 @@ set(SQL_SOURCE_FILES
 ###         ###
 
 try_compile(OPENMP_SUPPORT_OK
-    ${CMAKE_BINARY_DIR/___openmp_test_ok
+    ${CMAKE_BINARY_DIR}/___openmp_test_ok
     ${CMAKE_CURRENT_SOURCE_DIR}/utils/cmake/TestOpenMP.c}
     LINK_LIBRARIES -fopenmp
 )
 
 if(OPENMP_SUPPORT_OK)
-    message(STATUS "Compiler has OpenMP support")
+    message(STATUS "Compiler has OpenMP support (test program compiles)")
 else()
-    message(FATAL_ERROR "Compiler doesn't have OpenMP support")
+    message(FATAL_ERROR "Compiler doesn't have OpenMP support (test program doesn't compile)")
+endif()
+
+if(OpenMP_FOUND)
+    message(STATUS "OpenMP found by CMake for C and C++")
+else()
+    message(FATAL_ERROR "OpenMP not found by CMake for C and C++")
 endif()
 
 ###                        ###
-- 
GitLab