From 2e013b44bd743ca21d38a8aab73824a9da03b735 Mon Sep 17 00:00:00 2001 From: AnHeuermann <38031952+AnHeuermann@users.noreply.github.com> Date: Thu, 17 Sep 2026 14:39:38 +0200 Subject: [PATCH] Only require the CXX component of OpenMP find_package(OpenMP REQUIRED) requires OpenMP for all enabled languages. A parent project that also enables C, like OMCompiler-3rdParty, fails to configure if the C compiler has no OpenMP support. Co-Authored-By: Claude Opus 5 --- CMakeLists.txt | 2 +- ChangeLog | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c1a11f..91212f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,7 +91,7 @@ if(COLPACK_ENABLE_OPENMP) if(MSVC AND NOT DEFINED OpenMP_RUNTIME_MSVC) set(OpenMP_RUNTIME_MSVC llvm) endif() - find_package(OpenMP REQUIRED) + find_package(OpenMP REQUIRED COMPONENTS CXX) endif() # Define variables to use for organizing the installation. diff --git a/ChangeLog b/ChangeLog index ac4b4dd..b321f3e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,7 +10,8 @@ CMake 3.12 or newer is required Options are renamed: ENABLE_EXAMPLES is now COLPACK_ENABLE_EXAMPLES, ENABLE_OPENMP is now COLPACK_ENABLE_OPENMP The recovery routines in src/Recovery are now compiled into the library - OpenMP is linked via OpenMP::OpenMP_CXX, which fixes the build on macOS with libomp from Homebrew + OpenMP is linked via OpenMP::OpenMP_CXX, which fixes the build on macOS with libomp from Homebrew. + Only the CXX component of OpenMP is required, also if a parent project enables C or Fortran MSVC is supported. It builds with /openmp:llvm, because OpenMP 2.0 does not support unsigned loop indices. This requires CMake 3.30 or newer. Windows builds use short intermediate paths (CMAKE_INTERMEDIATE_DIR_STRATEGY=SHORT), because the object paths