Skip to content

Commit b94e8a7

Browse files
committed
build system simplifications & a few fixes for msvc
1 parent 3e36c87 commit b94e8a7

File tree

9 files changed

+184
-327
lines changed

9 files changed

+184
-327
lines changed

CMakeLists.txt

Lines changed: 117 additions & 322 deletions
Large diffs are not rendered by default.

ext/glfw

Submodule glfw updated 1 file

ext/pybind11

Submodule pybind11 updated 154 files

include/nanogui/traits.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ template <typename T> constexpr VariableType get_type() {
5151
return VariableType::Float32;
5252
else if constexpr (sizeof(T) == 8)
5353
return VariableType::Float64;
54+
} else {
55+
return VariableType::Invalid;
5456
}
55-
56-
return VariableType::Invalid;
5757
}
5858

5959
/// Return the size in bytes associated with a specific variable type

include/nanogui/vector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ class Color : public Vector4f {
339339
* \param alpha
340340
* The alpha component of the color, will be divided by ``255.0``.
341341
*/
342-
Color(size_t intensity, int alpha)
342+
Color(int intensity, int alpha)
343343
: Color(Vector3i(intensity), alpha) { }
344344

345345
/**

python/CMakeLists.txt

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
if (NOT NANOGUI_BUILD_SHARED)
2+
# Need PIC code in libnanogui & GLFW even when compiled as a static library
3+
set_target_properties(nanogui PROPERTIES POSITION_INDEPENDENT_CODE ON)
4+
5+
if (NANOGUI_BUILD_GLFW)
6+
set_target_properties(glfw_objects PROPERTIES POSITION_INDEPENDENT_CODE ON)
7+
endif()
8+
endif()
9+
10+
if (NANOGUI_BUILD_PYTHON AND (APPLE OR CMAKE_SYSTEM MATCHES "Linux"))
11+
# Include coroutine support for running the mainloop in detached mode
12+
add_definitions(-DCORO_SJLJ)
13+
include_directories(../ext/coro)
14+
set(NANOGUI_PYTHON_EXTRA ../ext/coro/coro.c)
15+
endif()
16+
17+
add_definitions(-DNANOGUI_PYTHON)
18+
19+
pybind11_add_module(nanogui-python MODULE THIN_LTO OPT_SIZE
20+
main.cpp
21+
glfw.cpp
22+
icons.cpp
23+
color.cpp
24+
widget.cpp
25+
layout.cpp
26+
basics.cpp
27+
button.cpp
28+
tabs.cpp
29+
textbox.cpp
30+
textarea.cpp
31+
theme.cpp
32+
formhelper.cpp
33+
misc.cpp
34+
canvas.cpp
35+
nanovg.cpp
36+
render.cpp
37+
vector.cpp
38+
python.h
39+
py_doc.h
40+
${NANOGUI_PYTHON_EXTRA})
41+
42+
set_target_properties(nanogui-python PROPERTIES OUTPUT_NAME nanogui)
43+
target_link_libraries(nanogui-python PRIVATE nanogui)
44+
45+
if (CMAKE_COMPILER_IS_GNUCC)
46+
# Quench warnings on GCC
47+
target_compile_options(nanogui-python PRIVATE -Wno-unused-variable)
48+
endif()
49+
50+
if (NANOGUI_INSTALL)
51+
install(TARGETS nanogui-python
52+
LIBRARY DESTINATION lib
53+
ARCHIVE DESTINATION lib)
54+
endif()

python/render.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ static py::array texture_download(Texture &texture) {
7171
case Texture::ComponentFormat::Int32: dtype_name = "i4"; break;
7272
case Texture::ComponentFormat::Float16: dtype_name = "f2"; break;
7373
case Texture::ComponentFormat::Float32: dtype_name = "f4"; break;
74+
default:
75+
throw std::runtime_error("Invalid component format");
7476
}
7577

7678
py::array result(

python/vector.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#if defined(__clang__)
77
# pragma clang diagnostic push
88
# pragma clang diagnostic ignored "-Wself-assign-overloaded"
9+
# pragma clang diagnostic ignored "-Wunused-lambda-capture"
910
#endif
1011

1112
template <typename Array>

src/example1.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
4141

4242
#define STB_IMAGE_STATIC
4343
#define STB_IMAGE_IMPLEMENTATION
44+
#if defined(_MSC_VER)
45+
# pragma warning (disable: 4505) // don't warn about dead code in stb_image.h
46+
#elif defined(__GNUC__)
47+
# pragma GCC diagnostic ignored "-Wunused-function"
48+
#endif
4449
#include <stb_image.h>
4550

4651
using namespace nanogui;

0 commit comments

Comments
 (0)