[Bf-blender-cvs] [ae28daf7047] temp-sybren-usd-patch-01: USD: Fixed static library linking on Linux
Sybren A. Stüvel
noreply at git.blender.org
Thu Nov 28 15:07:27 CET 2019
Commit: ae28daf704727b4d7577c82972e604e82b66659d
Author: Sybren A. Stüvel
Date: Wed Nov 27 17:25:37 2019 +0100
Branches: temp-sybren-usd-patch-01
https://developer.blender.org/rBae28daf704727b4d7577c82972e604e82b66659d
USD: Fixed static library linking on Linux
This may have inadvertently broken things on Windows, I'll work on a better
way soon.
===================================================================
M build_files/cmake/Modules/FindUSD.cmake
M source/blender/usd/CMakeLists.txt
===================================================================
diff --git a/build_files/cmake/Modules/FindUSD.cmake b/build_files/cmake/Modules/FindUSD.cmake
index 88fb982eb00..ec1a9e4a551 100644
--- a/build_files/cmake/Modules/FindUSD.cmake
+++ b/build_files/cmake/Modules/FindUSD.cmake
@@ -48,7 +48,7 @@ FIND_PATH(USD_INCLUDE_DIR
include
)
-FIND_LIBRARY(USD_LIBRARY
+FIND_LIBRARY(_usd_LIBRARY
NAMES
usd
HINTS
@@ -60,18 +60,26 @@ FIND_LIBRARY(USD_LIBRARY
# handle the QUIETLY and REQUIRED arguments and set USD_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(USD DEFAULT_MSG USD_ROOT_DIR USD_LIBRARY USD_INCLUDE_DIR)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(USD DEFAULT_MSG USD_ROOT_DIR _usd_LIBRARY USD_INCLUDE_DIR)
IF(USD_FOUND)
- SET(USD_LIBRARIES ${USD_LIBRARY})
+ get_filename_component(USD_LIBRARY_DIR ${_usd_LIBRARY} DIRECTORY)
+
+ SET(USD_LIBRARIES)
+ # List copied from pxrTargets.cmake, which is created when building USD.
+ foreach(_usd_lib arch tf gf js trace work plug vt ar kind sdf ndr sdr pcp usd usdGeom usdVol usdLux usdShade usdRender usdHydra usdRi usdSkel usdUI usdUtils)
+ list(APPEND USD_LIBRARIES "${USD_LIBRARY_DIR}/lib${_usd_lib}.a")
+ endforeach()
+ list(REVERSE USD_LIBRARIES)
+
SET(USD_INCLUDE_DIRS ${USD_INCLUDE_DIR})
- SET(USD_ROOT_DIR ${USD_ROOT_DIR})
ENDIF(USD_FOUND)
MARK_AS_ADVANCED(
USD_INCLUDE_DIR
- USD_LIBRARY
+ USD_LIBRARY_DIR
USD_ROOT_DIR
)
+UNSET(_usd_LIBRARY)
UNSET(_usd_SEARCH_DIRS)
diff --git a/source/blender/usd/CMakeLists.txt b/source/blender/usd/CMakeLists.txt
index ce8bc36cfd0..f63b71fa340 100644
--- a/source/blender/usd/CMakeLists.txt
+++ b/source/blender/usd/CMakeLists.txt
@@ -18,8 +18,6 @@
# All rights reserved.
# ***** END GPL LICENSE BLOCK *****
-include(${USD_ROOT_DIR}/pxrConfig.cmake)
-
# This suppresses the warning "This file includes at least one deprecated or antiquated header which
# may be removed without further notice at a future date", which is caused by the USD library
# including <ext/hash_set>. Nothing we can do about that until they change what
@@ -42,7 +40,7 @@ set(INC
)
set(INC_SYS
- ${PXR_INCLUDE_DIRS}
+ ${USD_INCLUDE_DIRS}
${BOOST_INCLUDE_DIR}
${TBB_INCLUDE_DIR}
)
@@ -50,6 +48,7 @@ set(INC_SYS
if(WIN32)
add_definitions(-DNOMINMAX)
endif()
+add_definitions(-DPXR_STATIC)
set(SRC
intern/abstract_hierarchy_iterator.cc
@@ -76,7 +75,9 @@ set(SRC
set(LIB
bf_blenkernel
bf_blenlib
- ${PXR_LIBRARIES}
+ -Wl,--whole-archive
+ ${USD_LIBRARIES}
+ -Wl,--no-whole-archive
)
blender_add_lib(bf_usd "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
More information about the Bf-blender-cvs
mailing list