diff --git a/CMakeLists.txt b/CMakeLists.txt index b77c045c..b0063307 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -133,6 +133,15 @@ target_include_directories(${PROJECT_NAME} PUBLIC target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11) +if(UVATLAS_USE_OPENMP) + find_package(OpenMP) + if(OpenMP_CXX_FOUND) + target_link_libraries(${PROJECT_NAME} PUBLIC OpenMP::OpenMP_CXX) + else() + set(UVATLAS_USE_OPENMP OFF) + endif() +endif() + target_include_directories(${PROJECT_NAME} PRIVATE UVAtlas UVAtlas/geodesics UVAtlas/isochart) if(NOT MINGW) @@ -251,6 +260,10 @@ if(BUILD_TOOLS AND WIN32) Microsoft::DirectXMesh::Utilities) source_group(uvatlastool REGULAR_EXPRESSION UVAtlasTool/*.*) + if(UVATLAS_USE_OPENMP) + target_link_libraries(uvatlastool OpenMP::OpenMP_CXX) + endif() + if(directxmath_FOUND) target_link_libraries(uvatlastool Microsoft::DirectXMath) endif() @@ -367,8 +380,9 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") endif() if(UVATLAS_USE_OPENMP) + # OpenMP in MSVC is not compatible with /permissive- unless you disable two-phase lookup foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) - target_compile_options(${t} PRIVATE /openmp /Zc:twoPhase-) + target_compile_options(${t} PRIVATE /Zc:twoPhase-) endforeach() endif() diff --git a/UVAtlas/isochart/isochartengine.cpp b/UVAtlas/isochart/isochartengine.cpp index 8ed7f54b..c0687bea 100644 --- a/UVAtlas/isochart/isochartengine.cpp +++ b/UVAtlas/isochart/isochartengine.cpp @@ -311,9 +311,9 @@ HRESULT CIsochartEngine::ParameterizeChartsInHeapParallelized( for (int n = 0; n < static_cast(parent.size()); ++n) { if (FAILED(hrOut)) // for the other threads - break; + continue; - auto pChart = parent[n]; + auto pChart = parent[static_cast(n)]; assert(pChart != nullptr); _Analysis_assume_(pChart != nullptr); @@ -323,7 +323,7 @@ HRESULT CIsochartEngine::ParameterizeChartsInHeapParallelized( if (FAILED(hr)) { hrOut = hr; // doesn't need pragma atomic as all changes to hrOut are to set it to FAILED - break; + continue; } // If current chart has been partitoned, just children add to heap to be diff --git a/build/UVAtlas-config.cmake.in b/build/UVAtlas-config.cmake.in index 1ae14b42..f6b4a8f0 100644 --- a/build/UVAtlas-config.cmake.in +++ b/build/UVAtlas-config.cmake.in @@ -3,10 +3,9 @@ include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake) include(CMakeFindDependencyMacro) -set(BUILD_TOOLS @BUILD_TOOLS@) -if(BUILD_TOOLS AND WIN32 AND (NOT WINDOWS_STORE)) - find_dependency(directxmesh) - find_dependency(directxtex) +set(UVATLAS_USE_OPENMP @UVATLAS_USE_OPENMP@) +if(UVATLAS_USE_OPENMP) + find_dependency(OpenMP) endif() set(ENABLE_USE_EIGEN @ENABLE_USE_EIGEN@)