diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index de96fbffe..6a804b036 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,6 +16,8 @@ jobs: strategy: fail-fast: false matrix: + os: [ubuntu-22.04, macos-13, windows-2022] + shared_libs: ['ON', 'OFF'] include: - os: ubuntu-22.04 package_manager: "apt" @@ -59,8 +61,12 @@ jobs: $GITHUB_WORKSPACE/scripts/install_prerequisites.sh -v -u -m ${{matrix.package_manager}} all - name: Configure CMake - run: | - cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN_FILE" -DBUILD_TESTS=${{matrix.test}} + run: > + cmake -G Ninja -B build + -D CMAKE_BUILD_TYPE=$BUILD_TYPE + -D CMAKE_TOOLCHAIN_FILE="$TOOLCHAIN_FILE" + -D BUILD_SHARED_LIBS=${{ matrix.shared_libs }} + -D BUILD_TESTS=${{ matrix.test }} - name: Build run: cmake --build build --config $BUILD_TYPE diff --git a/CMakeLists.txt b/CMakeLists.txt index 0870c0dec..74dec0826 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,9 @@ endif() # Make our own cmake imports accessible list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") +set(CMAKE_POSITION_INDEPENDENT_CODE ON) +SET(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + include(SetPlatformVars) include(PangolinFactory) @@ -33,8 +36,9 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() +option( BUILD_SHARED_LIBS "Build Shared Library" ON) + if(_WIN_) - option( BUILD_SHARED_LIBS "Build Shared Library" OFF) option( MSVC_USE_STATIC_CRT "Use static C Runtime with MSVC, /MT instead of /MD" ON) # Make sure there are no erroneous C Runtime flags @@ -54,14 +58,11 @@ if(_WIN_) endforeach() endif() elseif(_OSX_) - option( BUILD_SHARED_LIBS "Build Shared Library" ON) set(CMAKE_MACOSX_RPATH ON) elseif(EMSCRIPTEN) set(BUILD_SHARED_LIBS OFF) include(EmscriptenUtils) set(CMAKE_EXE_LINKER_FLAGS "-sASYNCIFY=1 -sDISABLE_EXCEPTION_CATCHING=0 -sGL_ASSERTIONS=1 -sFULL_ES3=1 --bind") -else() - option( BUILD_SHARED_LIBS "Build Shared Library" ON) endif() # run with "ASAN_OPTIONS=fast_unwind_on_malloc=0" to print stack with more details diff --git a/components/pango_core/CMakeLists.txt b/components/pango_core/CMakeLists.txt index 9061bd84e..23fedecb4 100644 --- a/components/pango_core/CMakeLists.txt +++ b/components/pango_core/CMakeLists.txt @@ -51,24 +51,6 @@ if(Threads_FOUND) target_link_libraries(${COMPONENT} PUBLIC Threads::Threads) endif() -## Generate symbol export helper header on MSVC -IF(MSVC) - include(GenerateExportHeader) - GENERATE_EXPORT_HEADER( ${COMPONENT} - BASE_NAME PANGOLIN - EXPORT_MACRO_NAME PANGOLIN_EXPORT - EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/include/pangolin/pangolin_export.h" - STATIC_DEFINE PANGOLIN_BUILT_AS_STATIC - ) - target_include_directories(${COMPONENT} PUBLIC - $ - $ - ) - install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include" - DESTINATION ${CMAKE_INSTALL_PREFIX} - ) -ENDIF() - if(BUILD_TESTS) add_executable(test_uris ${CMAKE_CURRENT_LIST_DIR}/tests/tests_uri.cpp) target_link_libraries(test_uris PRIVATE Catch2::Catch2 ${COMPONENT}) diff --git a/components/pango_core/include/pangolin/platform.h b/components/pango_core/include/pangolin/platform.h index c78fd27aa..443cd9579 100644 --- a/components/pango_core/include/pangolin/platform.h +++ b/components/pango_core/include/pangolin/platform.h @@ -42,11 +42,10 @@ #ifdef _MSC_VER # define __thread __declspec(thread) -# include -#else -# define PANGOLIN_EXPORT #endif //_MSVC_ +#define PANGOLIN_EXPORT + // HOST / DEVICE Annotations #ifdef __CUDACC__ # include diff --git a/components/pango_core/src/threadedfilebuf.cpp b/components/pango_core/src/threadedfilebuf.cpp index 4fbe4dfe1..fe1181f74 100644 --- a/components/pango_core/src/threadedfilebuf.cpp +++ b/components/pango_core/src/threadedfilebuf.cpp @@ -35,6 +35,7 @@ #ifdef USE_POSIX_FILE_IO #include #include +#include // Optionally use direct file i/o to avoid the cache. #define USE_DIRECT_FILE_IO diff --git a/components/pango_display/CMakeLists.txt b/components/pango_display/CMakeLists.txt index e927be9d8..3a7c4b87c 100644 --- a/components/pango_display/CMakeLists.txt +++ b/components/pango_display/CMakeLists.txt @@ -13,6 +13,7 @@ PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src/image_view.cpp ${CMAKE_CURRENT_LIST_DIR}/src/ConsoleView.cpp ${CMAKE_CURRENT_LIST_DIR}/src/default_font.cpp + ${CMAKE_CURRENT_BINARY_DIR}/fonts.cpp ) target_link_libraries(${COMPONENT} PUBLIC pango_core pango_opengl pango_windowing pango_vars ) diff --git a/components/pango_geometry/src/geometry_obj.cpp b/components/pango_geometry/src/geometry_obj.cpp index dea245032..37ea47f7c 100644 --- a/components/pango_geometry/src/geometry_obj.cpp +++ b/components/pango_geometry/src/geometry_obj.cpp @@ -114,7 +114,7 @@ pangolin::Geometry LoadGeometryObj(const std::string& filename) std::memcpy(tex_image.RowPtr(y), tex_image.RowPtr(tex_image.h - 1 - y), row_bytes); std::memcpy(tex_image.RowPtr(tex_image.h - 1 - y), tmp_row.data(), row_bytes); } - } catch(const std::exception& e) { + } catch(const std::exception&) { pango_print_warn("Unable to read texture '%s'\n", tex_name.c_str()); geom.textures.erase(tex_name); } diff --git a/components/pango_packetstream/include/pangolin/log/playback_session.h b/components/pango_packetstream/include/pangolin/log/playback_session.h index 3cd2c63dd..d6cc86042 100644 --- a/components/pango_packetstream/include/pangolin/log/playback_session.h +++ b/components/pango_packetstream/include/pangolin/log/playback_session.h @@ -9,7 +9,7 @@ namespace pangolin { -class Params; +struct Params; class PlaybackSession { diff --git a/components/pango_video/src/drivers/uvc_mediafoundation.cpp b/components/pango_video/src/drivers/uvc_mediafoundation.cpp index df6b2d48a..519a4fd56 100644 --- a/components/pango_video/src/drivers/uvc_mediafoundation.cpp +++ b/components/pango_video/src/drivers/uvc_mediafoundation.cpp @@ -60,7 +60,7 @@ class AsyncSourceReader : public IMFSourceReaderCallback // IUnknown methods STDMETHODIMP QueryInterface(REFIID iid, void** ppv) { - if (iid != __uuidof(IMFSourceReaderCallback)) { + if (!IsEqualGUID(iid, __uuidof(IMFSourceReaderCallback))) { return E_NOINTERFACE; } InterlockedIncrement(&ref_); @@ -696,7 +696,7 @@ bool UvcMediaFoundationVideo::FindDevice(int vendorId, int productId, const std: continue; } - if(nodeGuid == KSNODETYPE_DEV_SPECIFIC) + if(IsEqualGUID(nodeGuid, KSNODETYPE_DEV_SPECIFIC)) { // This is the extension node IKsNodeControl* pUnknown = nullptr; @@ -859,12 +859,12 @@ void UvcMediaFoundationVideo::InitDevice(size_t width, size_t height, bool async stride = bestStride; } - if(bestGuid == MFVideoFormat_YUY2) + if(IsEqualGUID(bestGuid, MFVideoFormat_YUY2)) { pixelFormat = PixelFormatFromString("GRAY8"); bit_depth = 8; } - else if(bestGuid == MFVideoFormat_Y10) + else if(IsEqualGUID(bestGuid, MFVideoFormat_Y10)) { pixelFormat = PixelFormatFromString("GRAY10"); bit_depth = 10;