Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable shared/static builds #906

Merged
10 changes: 8 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand All @@ -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
Expand Down
18 changes: 0 additions & 18 deletions components/pango_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>
)
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})
Expand Down
5 changes: 2 additions & 3 deletions components/pango_core/include/pangolin/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@

#ifdef _MSC_VER
# define __thread __declspec(thread)
# include <pangolin/pangolin_export.h>
#else
# define PANGOLIN_EXPORT
#endif //_MSVC_

#define PANGOLIN_EXPORT

// HOST / DEVICE Annotations
#ifdef __CUDACC__
# include <cuda_runtime.h>
Expand Down
1 change: 1 addition & 0 deletions components/pango_core/src/threadedfilebuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#ifdef USE_POSIX_FILE_IO
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>

// Optionally use direct file i/o to avoid the cache.
#define USE_DIRECT_FILE_IO
Expand Down
1 change: 1 addition & 0 deletions components/pango_display/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion components/pango_geometry/src/geometry_obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@
try {
TypedImage& tex_image = geom.textures[tex_name];
tex_image = LoadImage(PathParent(filename) + "/" + materials[i].diffuse_texname);
const int row_bytes = tex_image.w * tex_image.fmt.bpp / 8;

Check warning on line 110 in components/pango_geometry/src/geometry_obj.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, ON)

'initializing': conversion from 'size_t' to 'int', possible loss of data

Check warning on line 110 in components/pango_geometry/src/geometry_obj.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, ON)

'initializing': conversion from 'size_t' to 'const int', possible loss of data

Check warning on line 110 in components/pango_geometry/src/geometry_obj.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, OFF)

'initializing': conversion from 'size_t' to 'int', possible loss of data

Check warning on line 110 in components/pango_geometry/src/geometry_obj.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, OFF)

'initializing': conversion from 'size_t' to 'const int', possible loss of data
std::vector<unsigned char> tmp_row(row_bytes);
for (std::size_t y=0; y < (tex_image.h >> 1); ++y) {
std::memcpy(tmp_row.data(), tex_image.RowPtr(y), row_bytes);
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);
}
Expand Down Expand Up @@ -164,7 +164,7 @@

}

const int num_unique_verts = reindex_map.size();

Check warning on line 167 in components/pango_geometry/src/geometry_obj.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, ON)

'initializing': conversion from 'size_t' to 'int', possible loss of data

Check warning on line 167 in components/pango_geometry/src/geometry_obj.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, ON)

'initializing': conversion from 'size_t' to 'const int', possible loss of data

Check warning on line 167 in components/pango_geometry/src/geometry_obj.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, OFF)

'initializing': conversion from 'size_t' to 'int', possible loss of data

Check warning on line 167 in components/pango_geometry/src/geometry_obj.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, OFF)

'initializing': conversion from 'size_t' to 'const int', possible loss of data

// Create unified verts attribute
auto& verts = geom.buffers["geometry"];
Expand All @@ -177,7 +177,7 @@
verts.attributes["vertex"] = new_vs;
float_offset += 3;
for (auto& el : reindex_map) {
new_vs.Row(el.second).CopyFrom(tiny_vs.Row(el.first.vertex_index));

Check warning on line 180 in components/pango_geometry/src/geometry_obj.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, ON)

'argument': conversion from 'size_t' to 'int', possible loss of data

Check warning on line 180 in components/pango_geometry/src/geometry_obj.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, OFF)

'argument': conversion from 'size_t' to 'int', possible loss of data
}
}
if(tiny_ns.IsValid()) {
Expand All @@ -185,7 +185,7 @@
verts.attributes["normal"] = new_ns;
float_offset += 3;
for (auto& el : reindex_map) {
new_ns.Row(el.second).CopyFrom(tiny_ns.Row(el.first.normal_index));

Check warning on line 188 in components/pango_geometry/src/geometry_obj.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, ON)

'argument': conversion from 'size_t' to 'int', possible loss of data

Check warning on line 188 in components/pango_geometry/src/geometry_obj.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, OFF)

'argument': conversion from 'size_t' to 'int', possible loss of data
}
}
if(tiny_cs.IsValid()) {
Expand All @@ -193,7 +193,7 @@
verts.attributes["color"] = new_cs;
float_offset += 3;
for (auto& el : reindex_map) {
new_cs.Row(el.second).CopyFrom(tiny_cs.Row(el.first.vertex_index));

Check warning on line 196 in components/pango_geometry/src/geometry_obj.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, ON)

'argument': conversion from 'size_t' to 'int', possible loss of data

Check warning on line 196 in components/pango_geometry/src/geometry_obj.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, OFF)

'argument': conversion from 'size_t' to 'int', possible loss of data
}
}
if(tiny_ts.IsValid()) {
Expand All @@ -201,7 +201,7 @@
verts.attributes["uv"] = new_ts;
float_offset += 2;
for (auto& el : reindex_map) {
new_ts.Row(el.second).CopyFrom(tiny_ts.Row(el.first.texcoord_index));

Check warning on line 204 in components/pango_geometry/src/geometry_obj.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, ON)

'argument': conversion from 'size_t' to 'int', possible loss of data

Check warning on line 204 in components/pango_geometry/src/geometry_obj.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, OFF)

'argument': conversion from 'size_t' to 'int', possible loss of data
}
}
PANGO_ASSERT(float_offset * sizeof(float) == verts.w);
Expand All @@ -227,7 +227,7 @@
Image<uint32_t> new_ibo = faces->second.UnsafeReinterpret<uint32_t>().SubImage(0,0,3,num_faces);
for(size_t f=0; f < num_faces; ++f) {
for(size_t v=0; v < 3; ++v) {
new_ibo(v,f) = reindex_map[shape.mesh.indices[3 * f + v]];

Check warning on line 230 in components/pango_geometry/src/geometry_obj.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, ON)

'=': conversion from 'size_t' to 'T', possible loss of data

Check warning on line 230 in components/pango_geometry/src/geometry_obj.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, OFF)

'=': conversion from 'size_t' to 'T', possible loss of data
}
}
faces->second.attributes["vertex_indices"] = new_ibo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace pangolin {

class Params;
struct Params;

class PlaybackSession
{
Expand Down
8 changes: 4 additions & 4 deletions components/pango_video/src/drivers/uvc_mediafoundation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Loading