Skip to content

Commit 37a5a09

Browse files
treegardelclaude
andcommitted
Fix macOS CMake: respect install dir + OpenMP/HDF5 option semantics
- Drop the INSTALL_DATA_DIR override in Intern/rayx-core/CMakeLists.txt that clobbered the platform-specific value computed at top level (and broke RAYX_CUSTOM_DATA_DIR) on all platforms. - Reduce the APPLE block to OpenMP/HDF5 hint variables only; let the gated find_package calls in Extern/CMakeLists.txt do discovery (honoring RAYX_ENABLE_*/RAYX_REQUIRE_*) and link via OpenMP::OpenMP_CXX instead of global flags / double libomp linking. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 6dbb136 commit 37a5a09

2 files changed

Lines changed: 11 additions & 22 deletions

File tree

CMakeLists.txt

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -64,35 +64,28 @@ if(APPLE)
6464
set(OpenMP_LIBRARY "${MACOS_PKG_PREFIX}/opt/libomp/lib/libomp.dylib")
6565
endif()
6666

67-
# Common OpenMP settings
67+
# Hints for FindOpenMP. The system AppleClang/Homebrew clang needs the
68+
# -Xpreprocessor invocation and an explicit libomp path. These are only
69+
# hints: the actual find_package(OpenMP) call lives in Extern/CMakeLists.txt,
70+
# where it is gated by RAYX_ENABLE_OPENMP / RAYX_REQUIRE_OPENMP and linked
71+
# via the OpenMP::OpenMP_CXX target. We deliberately do not call
72+
# find_package here, nor add global compile/link flags, to keep the option
73+
# semantics intact and avoid linking libomp twice.
6874
set(OpenMP_C_FLAGS "-Xpreprocessor -fopenmp -I${OpenMP_INCLUDE_DIR}")
6975
set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp -I${OpenMP_INCLUDE_DIR}")
7076
set(OpenMP_C_LIB_NAMES "omp")
7177
set(OpenMP_CXX_LIB_NAMES "omp")
7278
set(OpenMP_omp_LIBRARY "${OpenMP_LIBRARY}")
7379
set(OpenMP_omp_INCLUDE_DIRS "${OpenMP_INCLUDE_DIR}")
74-
75-
if(RAYX_ENABLE_OPENMP)
76-
find_package(OpenMP REQUIRED)
77-
if(OpenMP_CXX_FOUND)
78-
message(STATUS "OpenMP found:")
79-
message(STATUS " Include dirs: ${OpenMP_CXX_INCLUDE_DIRS}")
80-
message(STATUS " Libraries: ${OpenMP_CXX_LIBRARIES}")
81-
82-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
83-
include_directories(${OpenMP_omp_INCLUDE_DIRS})
84-
link_libraries(${OpenMP_omp_LIBRARY})
85-
endif()
86-
endif()
87-
88-
# HDF5: MacPorts installs into /opt/local directly; Homebrew uses opt/hdf5.
80+
81+
# HDF5 hint: MacPorts installs into /opt/local directly; Homebrew uses
82+
# opt/hdf5. The actual find_package(HDF5) is done in Extern/CMakeLists.txt
83+
# (gated by RAYX_ENABLE_H5 / RAYX_REQUIRE_H5); HDF5_ROOT is inherited there.
8984
if(MACOS_PKG_KIND STREQUAL "macports")
9085
set(HDF5_ROOT "${MACOS_PKG_PREFIX}")
9186
else()
9287
set(HDF5_ROOT "${MACOS_PKG_PREFIX}/opt/hdf5")
9388
endif()
94-
find_package(HDF5 REQUIRED COMPONENTS C HL)
95-
9689
endif()
9790

9891

Intern/rayx-core/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
22

3-
# ---- Install directories ----
4-
include(GNUInstallDirs)
5-
set(INSTALL_DATA_DIR ${CMAKE_INSTALL_DATADIR})
6-
73
# ---- for files compiled with cuda compiler, prepend -Xcompiler flags ----
84
function(prepend_xcompiler FLAG_LIST PREPENDED_FLAG_LIST)
95
set(SRC ${${FLAG_LIST}})

0 commit comments

Comments
 (0)