diff --git a/CMakeLists.txt b/CMakeLists.txt index 16385371..eddb727f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -165,6 +165,17 @@ find_package(LibXml2 REQUIRED) #--- check for OpenMP --------------------------------------------------------- if (try_OpenMP) + #--- AppleClang has no built-in OpenMP runtime; MacPorts' 'libomp' port + #--- nests its headers/library one level deeper (include/libomp, lib/libomp) + #--- than the /include, /lib layout FindOpenMP.cmake looks + #--- for by default, so point it there directly if the port is installed. - + #--- (Only takes effect if the user hasn't already set OpenMP_ROOT.) ------ + if (APPLE AND NOT DEFINED OpenMP_ROOT AND EXISTS "/opt/local/lib/libomp") + set(OpenMP_ROOT "/opt/local/lib/libomp" CACHE PATH "OpenMP root directory") + endif () + if (APPLE AND EXISTS "/opt/local/include/libomp") + list(APPEND CMAKE_PREFIX_PATH "/opt/local/include/libomp") + endif () find_package(OpenMP) if (OpenMP_CXX_FOUND) add_compile_definitions(HAVE_GOMP) @@ -210,6 +221,12 @@ endif (DKS_FOUND) #--- check for Qt ------------------------------------------------------------- if (qt_based_tools) + #--- MacPorts installs the actual Qt6 tree, including its CMake package + #--- config files, under libexec/qt6 rather than directly under lib/cmake, + #--- so find_package(Qt6...) below would not see it otherwise. ------------ + if (APPLE AND EXISTS "/opt/local/libexec/qt6/lib/cmake") + list(APPEND CMAKE_PREFIX_PATH "/opt/local/libexec/qt6/lib/cmake") + endif () # check for any Qt, i.e. AUTO if (qt_version STREQUAL AUTO) # try Qt6 @@ -383,7 +400,8 @@ if (UNIX AND NOT APPLE) set(CMAKE_INSTALL_RPATH "${rpath}") elseif (APPLE) #--- on macOS the 3rd party libs typically come from Homebrew, which lives in - #--- /opt/homebrew (Apple silicon) or /usr/local (Intel) ------------------- + #--- /opt/homebrew (Apple silicon) or /usr/local (Intel), or from MacPorts, + #--- which lives in /opt/local on both architectures ----------------------- set(rpath ${CMAKE_INSTALL_RPATH}) if (EXISTS "/opt/homebrew/lib") string(APPEND rpath ";/opt/homebrew/lib") @@ -391,6 +409,9 @@ elseif (APPLE) if (EXISTS "/usr/local/lib") string(APPEND rpath ";/usr/local/lib") endif () + if (EXISTS "/opt/local/lib") + string(APPEND rpath ";/opt/local/lib") + endif () set(CMAKE_INSTALL_RPATH "${rpath}") endif () diff --git a/src/classes/CMakeLists.txt b/src/classes/CMakeLists.txt index 260f2df8..1fcb00be 100644 --- a/src/classes/CMakeLists.txt +++ b/src/classes/CMakeLists.txt @@ -6,8 +6,9 @@ set(MUSRFIT_INC ${CMAKE_SOURCE_DIR}/src/include) # Hence, target_include_directories cannot be used here because, targets are # setup only afterwards. include_directories(${MUSRFIT_INC}) -#--- note: FFTW3_INCLUDE is deliberately NOT added here. On a Homebrew based -#--- macOS it is /opt/homebrew/include, i.e. the complete 3rd party header tree, +#--- note: FFTW3_INCLUDE is deliberately NOT added here. On a Homebrew or +#--- MacPorts based macOS it is /opt/homebrew/include or /opt/local/include, +#--- i.e. the complete 3rd party header tree, #--- and a global include_directories() would put it in front of the headers of #--- every target below. The dictionaries below get it via their OPTIONS, and #--- everything else via the FFTW3::FFTW3 imported target. ---------------------