Skip to content

Commit db2ce58

Browse files
committed
run nanogui mainloop in detached mode (fixes #35)
1 parent ed7f95b commit db2ce58

File tree

10 files changed

+1525
-19
lines changed

10 files changed

+1525
-19
lines changed

CMakeLists.txt

+12-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ set(NANOGUI_EXTRA_LIBS "")
1818

1919
# Platform-dependent files for libnanogui
2020
set(LIBNANOGUI_EXTRA_SOURCE "")
21+
set(LIBNANOGUI_PYTHON_EXTRA_SOURCE "")
2122

2223
if(APPLE AND NANOGUI_BUILD_SHARED)
2324
set(CMAKE_MACOSX_RPATH ON)
@@ -99,7 +100,7 @@ endif()
99100

100101
if (WIN32)
101102
# Build and include GLAD on Windows
102-
list(APPEND LIBNANOGUI_EXTRA_SOURCE
103+
list(APPEND LIBNANOGUI_PYTHON_EXTRA_SOURCE
103104
"${CMAKE_CURRENT_SOURCE_DIR}/ext/glad/src/glad.c"
104105
"${CMAKE_CURRENT_SOURCE_DIR}/ext/glad/include/glad/glad.h"
105106
"${CMAKE_CURRENT_SOURCE_DIR}/ext/glad/include/KHR/khrplatform.h")
@@ -146,12 +147,19 @@ add_custom_command(
146147
include_directories(${CMAKE_CURRENT_BINARY_DIR})
147148

148149
# Set library type
149-
if(NANOGUI_BUILD_SHARED)
150+
if (NANOGUI_BUILD_SHARED)
150151
set(NANOGUI_LIBRARY_TYPE "SHARED")
151152
else()
152153
set(NANOGUI_LIBRARY_TYPE "STATIC")
153154
endif()
154155

156+
if (APPLE)
157+
# Include coroutine support for running the mainloop in detached mode
158+
add_definitions(-DCORO_SJLJ)
159+
include_directories(ext/coro)
160+
list(APPEND LIBNANOGUI_PYTHON_EXTRA_SOURCE ext/coro/coro.c)
161+
endif()
162+
155163
# Compile main NanoGUI library
156164
add_library(nanogui ${NANOGUI_LIBRARY_TYPE}
157165
# Merge GLFW into the NanoGUI library
@@ -274,7 +282,8 @@ if (NANOGUI_BUILD_PYTHON)
274282
set_target_properties(glfw_objects PROPERTIES POSITION_INDEPENDENT_CODE ON)
275283

276284
include_directories("ext/pybind11/include" ${PYTHON_INCLUDE_DIR})
277-
add_library(nanogui_python SHARED python/python.cpp python/python.h python/py_doc.h)
285+
add_library(nanogui_python SHARED python/python.cpp python/python.h python/py_doc.h
286+
${LIBNANOGUI_PYTHON_EXTRA_SOURCE})
278287
set_target_properties(nanogui_python PROPERTIES OUTPUT_NAME "nanogui")
279288
target_link_libraries(nanogui_python nanogui ${NANOGUI_EXTRA_LIBS})
280289

ext/coro/LICENSE

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Copyright (c) 2000-2009 Marc Alexander Lehmann <[email protected]>
2+
3+
Redistribution and use in source and binary forms, with or without modifica-
4+
tion, are permitted provided that the following conditions are met:
5+
6+
1. Redistributions of source code must retain the above copyright notice,
7+
this list of conditions and the following disclaimer.
8+
9+
2. Redistributions in binary form must reproduce the above copyright
10+
notice, this list of conditions and the following disclaimer in the
11+
documentation and/or other materials provided with the distribution.
12+
13+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
14+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
15+
CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
16+
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
17+
CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
18+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
19+
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
20+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
21+
ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
22+
OF THE POSSIBILITY OF SUCH DAMAGE.
23+
24+
Alternatively, the following files carry an additional notice that
25+
explicitly allows relicensing under the GPLv2: coro.c, coro.h.
26+

ext/coro/README

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Configuration, documentation etc. is provided in the coro.h file. Please
2+
note that the file conftest.c in this distribution is under the GPL. It is
3+
not needed for proper operation of this library though, for that, coro.h
4+
and coro.c suffice.
5+
6+
Marc Lehmann <[email protected]>

0 commit comments

Comments
 (0)