Skip to content

Commit

Permalink
build system simplifications & a few fixes for msvc
Browse files Browse the repository at this point in the history
  • Loading branch information
wjakob committed Sep 6, 2020
1 parent 3e36c87 commit 34e97f1
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 327 deletions.
439 changes: 117 additions & 322 deletions CMakeLists.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ext/glfw
Submodule glfw updated 1 files
+1 −3 CMakeLists.txt
2 changes: 1 addition & 1 deletion ext/pybind11
Submodule pybind11 updated 154 files
4 changes: 2 additions & 2 deletions include/nanogui/traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ template <typename T> constexpr VariableType get_type() {
return VariableType::Float32;
else if constexpr (sizeof(T) == 8)
return VariableType::Float64;
} else {
return VariableType::Invalid;
}

return VariableType::Invalid;
}

/// Return the size in bytes associated with a specific variable type
Expand Down
2 changes: 1 addition & 1 deletion include/nanogui/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class Color : public Vector4f {
* \param alpha
* The alpha component of the color, will be divided by ``255.0``.
*/
Color(size_t intensity, int alpha)
Color(int intensity, int alpha)
: Color(Vector3i(intensity), alpha) { }

/**
Expand Down
54 changes: 54 additions & 0 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
if (NOT NANOGUI_BUILD_SHARED)
# Need PIC code in libnanogui & GLFW even when compiled as a static library
set_target_properties(nanogui PROPERTIES POSITION_INDEPENDENT_CODE ON)

if (NANOGUI_BUILD_GLFW)
set_target_properties(glfw_objects PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()
endif()

if (NANOGUI_BUILD_PYTHON AND (APPLE OR CMAKE_SYSTEM MATCHES "Linux"))
# Include coroutine support for running the mainloop in detached mode
add_definitions(-DCORO_SJLJ)
include_directories(../ext/coro)
set(NANOGUI_PYTHON_EXTRA ../ext/coro/coro.c)
endif()

add_definitions(-DNANOGUI_PYTHON)

pybind11_add_module(nanogui-python MODULE THIN_LTO OPT_SIZE
main.cpp
glfw.cpp
icons.cpp
color.cpp
widget.cpp
layout.cpp
basics.cpp
button.cpp
tabs.cpp
textbox.cpp
textarea.cpp
theme.cpp
formhelper.cpp
misc.cpp
canvas.cpp
nanovg.cpp
render.cpp
vector.cpp
python.h
py_doc.h
${NANOGUI_PYTHON_EXTRA})

set_target_properties(nanogui-python PROPERTIES OUTPUT_NAME nanogui)
target_link_libraries(nanogui-python PRIVATE nanogui)

if (CMAKE_COMPILER_IS_GNUCC)
# Quench warnings on GCC
target_compile_options(nanogui-python PRIVATE -Wno-unused-variable)
endif()

if (NANOGUI_INSTALL)
install(TARGETS nanogui-python
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
endif()
2 changes: 2 additions & 0 deletions python/render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ static py::array texture_download(Texture &texture) {
case Texture::ComponentFormat::Int32: dtype_name = "i4"; break;
case Texture::ComponentFormat::Float16: dtype_name = "f2"; break;
case Texture::ComponentFormat::Float32: dtype_name = "f4"; break;
default:
throw std::runtime_error("Invalid component format");
}

py::array result(
Expand Down
3 changes: 3 additions & 0 deletions src/example1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@

#define STB_IMAGE_STATIC
#define STB_IMAGE_IMPLEMENTATION
#if defined(_MSC_VER)
# pragma warning (disable: 4505) // don't warn about dead code in stb_image.h
#endif
#include <stb_image.h>

using namespace nanogui;
Expand Down

0 comments on commit 34e97f1

Please sign in to comment.