Skip to content

Commit

Permalink
Merge pull request #49 from ViennaTools/legacy-openmp
Browse files Browse the repository at this point in the history
Legacy openmp
  • Loading branch information
Curve authored Mar 25, 2024
2 parents 1f06be4 + fc67673 commit c91c071
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
21 changes: 17 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
project(
ViennaRay
LANGUAGES CXX
VERSION 2.0.1)
VERSION 2.0.3)

# --------------------------------------------------------------------------------------------------------
# Library switches
Expand All @@ -11,11 +11,20 @@ project(
option(EMBREE_ISPC_SUPPORT "Enable Intel's SPMD Compiler" OFF)
option(EMBREE_RAY_MASK "Enable Embree Ray Masking" OFF)

option(VIENNARAY_USE_WDIST "Enable weighted distribution of ray weights" OFF)
option(VIENNARAY_DISABLE_COPY "Disable Embree Environment setup" OFF)
option(VIENNARAY_LEGACY_OPENMP "Use legacy OpenMP flags" OFF)

option(VIENNARAY_USE_WDIST "Enable weighted distribution of ray weights" OFF)
option(VIENNARAY_BUILD_EXAMPLES "Build examples" OFF)
option(VIENNARAY_BUILD_TESTS "Build tests" OFF)

if (VIENNARAY_LEGACY_OPENMP)
message(STATUS "[ViennaRay] Using legacy OpenMP flags")

find_package(OpenMP REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()

# --------------------------------------------------------------------------------------------------------
# Library options
# --------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -124,8 +133,12 @@ CPMFindPackage(
GIT_REPOSITORY "https://github.com/embree/embree"
OPTIONS "EMBREE_TUTORIALS OFF")

find_package(OpenMP REQUIRED)
target_link_libraries(${PROJECT_NAME} INTERFACE OpenMP::OpenMP_CXX embree)
if (NOT VIENNARAY_LEGACY_OPENMP)
find_package(OpenMP REQUIRED)
target_link_libraries(${PROJECT_NAME} INTERFACE OpenMP::OpenMP_CXX)
endif()

target_link_libraries(${PROJECT_NAME} INTERFACE embree)

# --------------------------------------------------------------------------------------------------------
# Setup Examples
Expand Down
4 changes: 4 additions & 0 deletions cmake/openmp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ if(APPLE)
set(OpenMP_omp_LIBRARY ${HOMEBREW_LIBOMP_PREFIX}/lib/libomp.dylib)
endif()
endif()

if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -openmp:llvm /bigobj")
endif()

0 comments on commit c91c071

Please sign in to comment.