@@ -381,10 +381,30 @@ add_library(nanogui-obj OBJECT
381
381
include /nanogui/nanogui.h
382
382
)
383
383
384
- add_library (nanogui ${NANOGUI_LIBRARY_TYPE}
385
- $< TARGET_OBJECTS:nanogui-obj>
386
- $< TARGET_OBJECTS:glfw_objects>
387
- )
384
+ # XCode has a serious bug where the XCode project produces an invalid target
385
+ # that will not get linked if it consists only of objects from object libraries,
386
+ # it will not generate any products (executables, libraries). The only work
387
+ # around is to add a dummy source file to the library definition. This is an
388
+ # XCode, not a CMake bug. See: https://itk.org/Bug/view.php?id=14044
389
+ if (CMAKE_GENERATOR STREQUAL Xcode )
390
+ set (XCODE_DUMMY ${CMAKE_CURRENT_BINARY_DIR} /xcode_dummy.cpp )
391
+ file (WRITE ${XCODE_DUMMY} "" )
392
+ add_library (nanogui ${NANOGUI_LIBRARY_TYPE}
393
+ ${XCODE_DUMMY}
394
+ $< TARGET_OBJECTS:nanogui-obj>
395
+ $< TARGET_OBJECTS:glfw_objects>
396
+ )
397
+
398
+ # XCode also fails at linking GLFW, so we exclude it. Note that the actual
399
+ # component we need to build is 'glfw_objects', which is merged into the
400
+ # NanoGUI library itself.
401
+ set_target_properties (glfw PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1 )
402
+ else ()
403
+ add_library (nanogui ${NANOGUI_LIBRARY_TYPE}
404
+ $< TARGET_OBJECTS:nanogui-obj>
405
+ $< TARGET_OBJECTS:glfw_objects>
406
+ )
407
+ endif ()
388
408
389
409
if (NANOGUI_BUILD_SHARED )
390
410
set_property (TARGET nanogui-obj PROPERTY POSITION_INDEPENDENT_CODE ON )
0 commit comments