From 4731e8e0a853b3f10250e700dc55432c000ab24d Mon Sep 17 00:00:00 2001 From: Micah Acinapura Date: Fri, 12 May 2023 03:35:59 -0400 Subject: [PATCH] MacOS build fixes (#2622) Co-authored-by: Alexander Bock Co-authored-by: Joakim Kilby --- .../mars/layers/colorlayers/ctx_mosaic_newyork.wms | 2 +- .../mars/layers/colorlayers/ctx_mosaic_sweden.wms | 2 +- .../mars/layers/colorlayers/ctx_mosaic_utah.wms | 2 +- modules/base/rendering/renderabletrail.cpp | 4 ++-- modules/fitsfilereader/CMakeLists.txt | 3 +++ .../globebrowsing/src/geojson/geojsoncomponent.cpp | 6 +++++- .../src/geojson/globegeometryhelper.cpp | 12 ++++++++++-- modules/kameleon/ext/kameleon | 2 +- modules/space/speckloader.cpp | 10 +++++----- modules/webbrowser/CMakeLists.txt | 7 +++++-- modules/webbrowser/cmake/webbrowser_helpers.cmake | 4 +++- modules/webbrowser/src/webbrowserapp.cpp | 4 ++++ modules/webbrowser/webbrowsermodule.cpp | 2 +- src/scene/scene.cpp | 7 ++++++- 14 files changed, 48 insertions(+), 19 deletions(-) diff --git a/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/ctx_mosaic_newyork.wms b/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/ctx_mosaic_newyork.wms index 0137b7f61f..2ea0a1940f 100644 --- a/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/ctx_mosaic_newyork.wms +++ b/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/ctx_mosaic_newyork.wms @@ -12,7 +12,7 @@ 13 top - GEOGCS["Mars 2000", DATUM["D_Mars_2000", SPHEROID["MARS_2000_IAU_IAG",3396190.0,169.894447222361179]],PRIMEM["Greenwich"0],UNIT["Decimal_Degree",0.0174532925199433]] + GEOGCS["Mars2000",DATUM["D_Mars_2000",SPHEROID["MARS_2000_IAU_IAG",3396190,169.8944472236118]],PRIMEM["Greenwich",0],UNIT["Decimal_Degree",0.0174532925199433]] 256 256 2 diff --git a/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/ctx_mosaic_sweden.wms b/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/ctx_mosaic_sweden.wms index 6a715034d5..5d4c6b0622 100644 --- a/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/ctx_mosaic_sweden.wms +++ b/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/ctx_mosaic_sweden.wms @@ -12,7 +12,7 @@ 13 top - GEOGCS["Mars 2000", DATUM["D_Mars_2000", SPHEROID["MARS_2000_IAU_IAG",3396190.0,169.894447222361179]],PRIMEM["Greenwich"0], UNIT["Decimal_Degree",0.0174532925199433]] + GEOGCS["Mars2000",DATUM["D_Mars_2000",SPHEROID["MARS_2000_IAU_IAG",3396190,169.8944472236118]],PRIMEM["Greenwich",0],UNIT["Decimal_Degree",0.0174532925199433]] 256 256 2 diff --git a/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/ctx_mosaic_utah.wms b/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/ctx_mosaic_utah.wms index fc91aa4f7e..eb57ecb39f 100644 --- a/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/ctx_mosaic_utah.wms +++ b/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/ctx_mosaic_utah.wms @@ -12,7 +12,7 @@ 13 top - GEOGCS["Mars 2000", DATUM["D_Mars_2000", SPHEROID["MARS_2000_IAU_IAG",3396190.0,169.894447222361179]],PRIMEM["Greenwich"0],UNIT["Decimal_Degree",0.0174532925199433]] + GEOGCS["Mars2000",DATUM["D_Mars_2000",SPHEROID["MARS_2000_IAU_IAG",3396190,169.8944472236118]],PRIMEM["Greenwich",0],UNIT["Decimal_Degree",0.0174532925199433]] 256 256 2 diff --git a/modules/base/rendering/renderabletrail.cpp b/modules/base/rendering/renderabletrail.cpp index 873b8d17c6..accd13c3cd 100644 --- a/modules/base/rendering/renderabletrail.cpp +++ b/modules/base/rendering/renderabletrail.cpp @@ -242,10 +242,10 @@ void RenderableTrail::initializeGL() { #ifdef __APPLE__ _programObject = BaseModule::ProgramObjectManager.request( - ProgramName, + "EphemerisProgram", []() -> std::unique_ptr { return global::renderEngine->buildRenderProgram( - ProgramName, + "EphemerisProgram", absPath("${MODULE_BASE}/shaders/renderabletrail_apple_vs.glsl"), absPath("${MODULE_BASE}/shaders/renderabletrail_apple_fs.glsl") ); diff --git a/modules/fitsfilereader/CMakeLists.txt b/modules/fitsfilereader/CMakeLists.txt index d534344961..72613a82ae 100644 --- a/modules/fitsfilereader/CMakeLists.txt +++ b/modules/fitsfilereader/CMakeLists.txt @@ -59,6 +59,9 @@ if (MSVC) target_compile_options(CCfits PRIVATE "/W0") target_compile_definitions(CCfits PRIVATE "_SCL_SECURE_NO_WARNINGS") else () + if (APPLE) + target_compile_options(cfitsio PRIVATE "-Wno-implicit-function-declaration") + endif () target_compile_options(cfitsio PRIVATE "-w") target_compile_options(CCfits PRIVATE "-w") endif () diff --git a/modules/globebrowsing/src/geojson/geojsoncomponent.cpp b/modules/globebrowsing/src/geojson/geojsoncomponent.cpp index 05b6fd73bc..06920f7427 100644 --- a/modules/globebrowsing/src/geojson/geojsoncomponent.cpp +++ b/modules/globebrowsing/src/geojson/geojsoncomponent.cpp @@ -671,7 +671,11 @@ void GeoJsonComponent::addMetaPropertiesToFeature(SubFeatureProps& feature, int const geos::geom::Geometry* geometry) { std::unique_ptr centroid = geometry->getCentroid(); - geos::geom::CoordinateXY centroidCoord = *centroid->getCoordinate(); + // Using `auto` here as on MacOS `getCoordinate` returns: + // geos::geom::Coordinate + // but on Windows it returns + // geos::geom::CoordinateXY + auto centroidCoord = *centroid->getCoordinate(); glm::vec2 centroidLatLong = glm::vec2(centroidCoord.y, centroidCoord.x); feature.centroidLatLong = centroidLatLong; diff --git a/modules/globebrowsing/src/geojson/globegeometryhelper.cpp b/modules/globebrowsing/src/geojson/globegeometryhelper.cpp index 190058a571..deba59cb2f 100644 --- a/modules/globebrowsing/src/geojson/globegeometryhelper.cpp +++ b/modules/globebrowsing/src/geojson/globegeometryhelper.cpp @@ -295,8 +295,16 @@ subdivideTriangle(const glm::vec3& v0, const glm::vec3& v1, const glm::vec3& v2, using namespace geos::geom; GeometryFactory::Ptr geometryFactory = GeometryFactory::create(); - std::unique_ptr points = geometryFactory->createMultiPoint(pointCoords); - + // @TODO (emmbr, 2023-04-18): This is a bit of a temporary workaround to make the + // createMultiPoint call compile on Mac. It should work with just passing in the + // pointCoords variable directly, but for some reason it didn't. We should come up + // with a solution that does not iterate over the (quite big) std::vector an extra time + std::vector> geosPoints; + geosPoints.reserve(pointCoords.size()); + for (const Coordinate& c : pointCoords) { + geosPoints.emplace_back(geometryFactory->createPoint(c)); + } + std::unique_ptr points = geometryFactory->createMultiPoint(std::move(geosPoints)); // Create triangulation of points geos::triangulate::DelaunayTriangulationBuilder builder; builder.setSites(*points->getCoordinates()); diff --git a/modules/kameleon/ext/kameleon b/modules/kameleon/ext/kameleon index 08b0e5dbfc..ae831dc372 160000 --- a/modules/kameleon/ext/kameleon +++ b/modules/kameleon/ext/kameleon @@ -1 +1 @@ -Subproject commit 08b0e5dbfc142ebb77d05409115d9df335d8abf7 +Subproject commit ae831dc372c3713f97658cf1ff5f50ffeb23e54f diff --git a/modules/space/speckloader.cpp b/modules/space/speckloader.cpp index 9a8282865c..8997c27fde 100644 --- a/modules/space/speckloader.cpp +++ b/modules/space/speckloader.cpp @@ -152,17 +152,17 @@ Dataset loadFile(std::filesystem::path path, SkipAllZeroLines skipAllZeroLines) while (std::getline(file, line)) { currentLineNumber++; - // Ignore empty line or commented-out lines - if (line.empty() || line[0] == '#') { - continue; - } - // Guard against wrong line endings (copying files from Windows to Mac) causes // lines to have a final \r if (line.back() == '\r') { line = line.substr(0, line.length() - 1); } + // Ignore empty line or commented-out lines + if (line.empty() || line[0] == '#') { + continue; + } + strip(line); // If the first character is a digit, we have left the preamble and are in the diff --git a/modules/webbrowser/CMakeLists.txt b/modules/webbrowser/CMakeLists.txt index 46cf185070..612d621aa9 100644 --- a/modules/webbrowser/CMakeLists.txt +++ b/modules/webbrowser/CMakeLists.txt @@ -54,7 +54,6 @@ set(CEF_VERSION "102.0.10+gf249b2e+chromium-102.0.5005.115") if (WIN32 OR UNIX) option(USE_SANDBOX OFF) endif () - # Add this project's cmake/ directory to the module path. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(cef_support) @@ -163,7 +162,11 @@ set(WEBBROWSER_RESOURCES_SRCS # Place Helper in separate executable # The naming style " Helper" is required by Chromium. -set(CEF_HELPER_TARGET "OpenSpace_Helper" CACHE INTERNAL "CEF_HELPER_TARGET") +if (OS_MACOSX) + set(CEF_HELPER_TARGET "OpenSpace Helper" CACHE INTERNAL "CEF_HELPER_TARGET") +else () + set(CEF_HELPER_TARGET "OpenSpace_Helper" CACHE INTERNAL "CEF_HELPER_TARGET") +endif () set(CEF_HELPER_TARGET_GPU "OpenSpace Helper (GPU)" CACHE INTERNAL "CEF_HELPER_TARGET_GPU") set(CEF_HELPER_TARGET_RENDERER "OpenSpace Helper (Renderer)" CACHE INTERNAL "CEF_HELPER_TARGET_RENDERER") diff --git a/modules/webbrowser/cmake/webbrowser_helpers.cmake b/modules/webbrowser/cmake/webbrowser_helpers.cmake index 67fb45768e..b57f41db26 100644 --- a/modules/webbrowser/cmake/webbrowser_helpers.cmake +++ b/modules/webbrowser/cmake/webbrowser_helpers.cmake @@ -160,7 +160,9 @@ function(run_cef_linux_config CEF_TARGET CEF_ROOT) endfunction () function(set_modules_dependency_on_cef_libraries LIB_DEPENDENT) - target_link_libraries(${LIB_DEPENDENT} INTERFACE libcef_lib) + if (WIN32 OR OS_LINUX) + target_link_libraries(${LIB_DEPENDENT} INTERFACE libcef_lib) + endif () target_link_libraries(${LIB_DEPENDENT} INTERFACE libcef_dll_wrapper) endfunction () diff --git a/modules/webbrowser/src/webbrowserapp.cpp b/modules/webbrowser/src/webbrowserapp.cpp index 902305e61b..4d7f26298b 100644 --- a/modules/webbrowser/src/webbrowserapp.cpp +++ b/modules/webbrowser/src/webbrowserapp.cpp @@ -49,6 +49,10 @@ void WebBrowserApp::OnBeforeCommandLineProcessing(const CefString&, commandLine->AppendSwitch("use-mock-keychain"); commandLine->AppendSwitch("enable-begin-frame-scheduling"); commandLine->AppendSwitchWithValue("autoplay-policy", "no-user-gesture-required"); +#ifdef __APPLE__ + commandLine->AppendSwitch("--disable-gpu-sandbox"); + commandLine->AppendSwitch("--no-sandbox"); +#endif } } // namespace openspace diff --git a/modules/webbrowser/webbrowsermodule.cpp b/modules/webbrowser/webbrowsermodule.cpp index f0fec3e77a..2aeda1bd10 100644 --- a/modules/webbrowser/webbrowsermodule.cpp +++ b/modules/webbrowser/webbrowsermodule.cpp @@ -46,7 +46,7 @@ namespace { constexpr std::string_view SubprocessPath = "OpenSpace_Helper.exe"; #elif defined(__APPLE__) constexpr std::string_view SubprocessPath = - "../Frameworks/OpenSpace Helper.app/Contents/MacOS/OpenSpace_Helper"; + "../Frameworks/OpenSpace Helper.app/Contents/MacOS/OpenSpace Helper"; #else constexpr std::string_view SubprocessPath = "OpenSpace_Helper"; #endif diff --git a/src/scene/scene.cpp b/src/scene/scene.cpp index 6d54e7a18b..1972830b00 100644 --- a/src/scene/scene.cpp +++ b/src/scene/scene.cpp @@ -862,7 +862,12 @@ std::string makeIdentifier(std::string s) { // marks. Hence, we first convert '_' to whitespaces to avoid them being replaced // in the puncutation check std::replace(s.begin(), s.end(), '_', ' '); - std::replace_if(s.begin(), s.end(), std::ptr_fun(&std::ispunct), '-'); + std::replace_if( + s.begin(), + s.end(), + [](char c) { return std::ispunct(c) == 0; }, + '-' + ); std::replace(s.begin(), s.end(), ' ', '_'); return s; }