-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMake Modernization and cleanup in lib and plugin/adsk #323
CMake Modernization and cleanup in lib and plugin/adsk #323
Conversation
# | ||
|
||
cmake_minimum_required(VERSION 3.12.0) | ||
cmake_minimum_required(VERSION 3.13...3.17) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting Min and Max versions to be used.
One of the features introduced in version 3.13
is that target_sources doesn't have to be called in the same CMakeLists file that add_library is called.
If you look at lib/CMakeLists.txt
, there is no traces of call to target_sources and rather this is delegated to each sub-directories (e.g ae, base, fileio, listeners, nodes, etc...).
If you are interested, there is a great article on the advantages of target_sources and enhancements in version 3.13
:
https://crascit.com/2016/01/31/enhanced-source-file-handling-with-target_sources/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may be missing something here, but why do we care about a max version if we're currently compatible with the most recent release? Seems like this would be something we'd need to update periodically to support newer releases of CMake as they come out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we necessarily need to update this periodically or at least any times soon to support newer features.
The version range basically specifies that the current CMake code is written and tested for the given range of CMake versions and avoids having to setup the explicit policy settings.
"max" compatibility version affects policy settings. So, if someone is using a version which is newer than let's say 3.19 then they can set policies as far as the "max" version.
Please see this:
https://cmake.org/cmake/help/v3.12/command/cmake_minimum_required.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, sorry. See? I should have rtfm. :)
I foolishly assumed the max was a hard cutoff on which versions of CMake the project could be built with. Makes a lot more sense that it only determines policy settings instead. Duh...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lol, no worries.... I am no CMake expert myself at all and have to read the manuals from time to time to understand things :)
#============================================================================== | ||
#------------------------------------------------------------------------------ | ||
# options | ||
#------------------------------------------------------------------------------ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replacing =
with -
. It is less distracting.
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--enable-new-dtags") | ||
endif() | ||
|
||
#------------------------------------------------------------------------------ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
organizing global options.
#============================================================================== | ||
# Tests | ||
#============================================================================== | ||
#------------------------------------------------------------------------------ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving compiler configuration as is for now!! This will change in the second phase of cmake clean up.
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping the Copyright style consistence.
Also,we don't need to add Copyright headers in every Cmake files ( it is very distracting ). Only add in the top level cmake file.
@@ -33,7 +33,7 @@ | |||
# - OS-specific defines | |||
# - Post-commnad for correcting Qt library linking on osx | |||
# - Windows link flags for exporting initializePlugin/uninitializePlugin | |||
macro(MAYA_SET_PLUGIN_PROPERTIES target) | |||
macro(maya_set_plugin_properties target) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping all function calls lowered cased for consistency.
# | ||
# SUBDIR - optional sub-directory in which to promote files. | ||
# FILES - list of files to promote. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed duplicated mayaUsd_promoteHeaderListWithSubdir
and consolidated some of it's functionalities into mayaUsd_promoteHeaderList
add_subdirectory(usd) | ||
add_subdirectory(utils) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the main problems that this PR addresses is to clean up this CMake file.
-
Every sub-directories under
lib
now gets it's own CMakeLists.txt -
All the
target_xxx
calls explicitly declare properties such asPUBLIC
,PRIVATE
. This reduces the chance to introduce hidden dependencies.
Haven’t done a full review, but was comparing this PR to #321... and to be clear, before either of these PRs, there were 3 functions with similar names: mayaUsd_promoteHeaderList, and TWO identical copies of mayaUsd_promoteHeaderListWithSubdir. PR #321 removed the second copy of mayaUsd_promoteHeaderListWithSubdir, but left the other two unchanged. This PR removes the first copy of mayaUsd_promoteHeaderListWithSubdir, and updates mayaUsd_promoteHeaderList, but leaves the second copy of mayaUsd_promoteHeaderListWithSubdir untouched. Is this intentional? |
… my previous commit.
whoops!! not intentional indeed. Fixed in 056e830. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for tackling this @HamedSabri-adsk! It's looking way better already.
The one important thing I think needs to be looked at is the module.cpp
/moduleDeps.cpp
thing for mayaUsd
, but otherwise this is looking pretty good. I'm no CMake expert, but I like the direction this is heading, and we can do additional cleanup in subsequent passes.
# | ||
|
||
cmake_minimum_required(VERSION 3.12.0) | ||
cmake_minimum_required(VERSION 3.13...3.17) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may be missing something here, but why do we care about a max version if we're currently compatible with the most recent release? Seems like this would be something we'd need to update periodically to support newer releases of CMake as they come out.
cmake/utils.cmake
Outdated
function(mayaUsd_promoteMayaUsdHeader) | ||
set(srcFile ${CMAKE_CURRENT_SOURCE_DIR}/base/mayaUsd.h.src) | ||
set(srcFile ${CMAKE_CURRENT_SOURCE_DIR}/mayaUsd.h.src) | ||
set(dstFile ${CMAKE_BINARY_DIR}/include/mayaUsd/mayaUsd.h) | ||
if (NOT EXISTS ${dstFile}) | ||
message(STATUS "promoting: " ${srcFile}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really sure why there's a utility function for this. Seems like its contents should just go in the lib
(or lib/base
?) CMakeLists.txt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can understand why this could be confusing.
This utility basically calls cmake "configure_file" function to copy an input
file to an output
file and substitutes variable values referenced as @var@ or ${VAR} in the input file content.
input = mayaUsd.h.src
output = include/mayaUsd/mayaUsd.h
The reason base/
is removed is because every sub-directories under "lib" is now getting it's own CMakeLists.txt
and we no longer need to have hard-coded paths in utilities anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry if I was unclear. I think I get what the function does. My gripe was more that I think as a function, this only gets called in one place, doesn't it? I would think we only install the mayaUsd.h
file once. Can/should we just put this code directly in the lib/base/CMakeLists.txt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, this function is only called once for copying mayaUsd.h.src which is in lib/base/CMakeLists.txt
You have a point, this is now directly called in lib/base/CMakeLists.txt.
See 71d2a8b
lib/CMakeLists.txt
Outdated
MAYAUSD_CORE_EXPORT | ||
MFB_PACKAGE_NAME="${PROJECT_NAME}" | ||
MFB_ALT_PACKAGE_NAME="${PROJECT_NAME}" | ||
MFB_PACKAGE_MODULE=mayaUsd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
${PROJECT_NAME}
here too instead of the literal mayaUsd
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Will fix it in the next commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see e25fa48
lib/CMakeLists.txt
Outdated
target_include_directories(${PROJECT_NAME} | ||
PUBLIC | ||
${CMAKE_BINARY_DIR}/include | ||
${MAYA_INCLUDE_DIRS} | ||
${PXR_INCLUDE_DIRS} | ||
$<$<BOOL:${UFE_FOUND}>:${UFE_INCLUDE_DIR}> | ||
PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is slated for a later phase, but it would be great to verify that all of the named targets we're using with target_link_libraries()
properly identify their interface include directories so that we don't need to specify them here. I think the pxr libraries should be doing that already, and maybe we should be setting up Maya::*
and UFE::*
targets in the Find modules.
lib/CMakeLists.txt
Outdated
${Boost_FILESYSTEM_LIBRARY} | ||
${Boost_SYSTEM_LIBRARY} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we start using the named boost targets now, like Boost::filesystem
and Boost::system
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. I like your suggestion. Will fix it in the next commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see e25fa48
lib/base/CMakeLists.txt
Outdated
mayaUsd_promoteMayaUsdHeader() | ||
mayaUsd_promoteHeaderList(HEADERS ${headers} SUBDIR base) | ||
|
||
# ----------------------------------------------------------------------------- | ||
# install | ||
# ----------------------------------------------------------------------------- | ||
install(FILES ${headers} | ||
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/mayaUsd/base | ||
) | ||
|
||
install(FILES ${CMAKE_BINARY_DIR}/include/mayaUsd/mayaUsd.h | ||
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/mayaUsd | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may be missing something here too, but promoting and installing feels somewhat redundant to me, and I'm not crazy about how the promote function injects #pragma
directives on the fly. Is there a way to collapse this? Or maybe that's also planned for a later pass?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Promoting and installing are kind of orthogonal to each other. The problem with collapsing them is that "install stage" doesn't necessarily need to happen all the time but the "build stage" does.
Also relying on install stage to access the header files doesn't really work. What happens with incremental builds? That's why we include headers from the build directory when building the project. Also when the incremental build happens ONLY the headers files that have touched are promoted.
Please let me know if this answers your question or perhaps I got your question confused with something else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I was reading your above comment in lib/CMakeLists.txt
, I realized that having ${CMAKE_BINARY_DIR}/include
in the PUBLIC list makes it a bit vague when other projects link against mayaUsd project.
This is now added in the PRIVATE entry list and projects that links against mayaUsd now need to explicitly add ${CMAKE_BINARY_DIR}/include
in their target_include_directories
.
mayaUsd
target_include_directories(${PROJECT_NAME}
PUBLIC
${MAYA_INCLUDE_DIRS}
${PXR_INCLUDE_DIRS}
$<$<BOOL:${UFE_FOUND}>:${UFE_INCLUDE_DIR}>
PRIVATE
${CMAKE_BINARY_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}
)
_mayaUsd
add_library(${PYTHON_TARGET_NAME} SHARED)
target_include_directories(${PYTHON_TARGET_NAME}
PRIVATE
${CMAKE_BINARY_DIR}/include
)
target_link_libraries(${PYTHON_TARGET_NAME}
PRIVATE
mayaUsd
)
please see 904b394
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may again be exposing my CMake ignorance, but is this not what the INTERFACE keyword is for?
It seems like things that link against mayaUsd shouldn't need to do anything special (like add an include directory) other than just declare their dependence on mayaUsd. The build and install requirements necessary for a dependency of a downstream library should all be determined by the properties of the upstream target.
I think I probably need to do my CMake homework here, and am totally happy to revisit this later when I have a better understanding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not at all.... You have a great point and I am glad we revisit this and change things.
My understating is that PRIVATE
properties are used internally to build the target. Hence, PRIVATE
models the build requirements
of a target.
On the other hand, INTERFACE
properties are used externally by users of the target. Hence, INTERFACE
properties models the usage requirements
of a target.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What initially confused me (and possibly what tripped @mattyjams up as well?), was this bit (emphasis mine):
This is now added in the PRIVATE entry list and projects that links against mayaUsd now need to explicitly add ${CMAKE_BINARY_DIR}/include in their target_include_directories.
On re-reading this thread, I now assume that you were speaking hypothetically. Is this correct? Or are there actually cases where an external project would want / need to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, my comment was mostly hypothetical. I am happy if we want to revisit this but let's do it after this PR merged.
lib/python/CMakeLists.txt
Outdated
module.cpp | ||
moduleDeps.cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a subtle distinction in purpose between these two files that's not represented here.
module.cpp
is definitely intended to get built into the Python module library object (lib/python/mayaUsd/lib/_mayaUsd.so
on Linux), but moduleDeps.cpp
is intended to get built into the main library (lib/libmayaUsd.so
on Linux).
For pxr libraries, module.cpp
is identified as a PYMODULE_CPPFILES
:
https://github.com/PixarAnimationStudios/USD/blob/40c813421425c47aa84f4572b4798fbb3430984e/cmake/macros/Public.cmake#L304
Whereas moduleDeps.cpp
is identified as a PYTHON_CPPFILES
:
https://github.com/PixarAnimationStudios/USD/blob/40c813421425c47aa84f4572b4798fbb3430984e/cmake/macros/Public.cmake#L219
The upshot is that I think moduleDeps.cpp
need to go up a level and be included in the main lib/CMakeLists.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh I didn't know. Will fix it in the next commit. Thank you for the links.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please see 12f14b6
@@ -401,15 +321,17 @@ function(separate_argument_list listName) | |||
endfunction() | |||
|
|||
# python extension module suffix | |||
function(set_python_module_suffix target) | |||
function(set_python_module_property target) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new function name is a little mysterious and looks a bit weird in CMakeLists.txt files below. What property? :P
It's a bit verbose, but maybe set_python_module_suffix_property()
? Or do we expect that other properties might need to be added here? If that's the case maybe set_python_module_properties()
?
And/or possibly prefix this with mayaUsd_
? I'd be mildly concerned that this could be mistaken for a built-in CMake function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set_python_module_property
is simply a tiny wrapper around cmake set_target_properties
function that sets both prefix
and suffix
names for python modules on different platforms.
function(set_python_module_property target)
if(IS_WINDOWS)
set_target_properties(${target}
PROPERTIES
PREFIX ""
SUFFIX ".pyd"
)
elseif(IS_LINUX OR IS_MACOSX)
set_target_properties(${target}
PROPERTIES
PREFIX ""
SUFFIX ".so"
)
endif()
endfunction()
Every cmake target (shared library, execturable,...) has some properties that can be modified through set_target_properties
function.
Here is the list of all the properties on targets:
https://cmake.org/cmake/help/latest/manual/cmake-properties.7.html#properties-on-targets
Besides Targets, (Tests, Directories, Source Files, Cache Entries) can also have their own properties which are all listed here:
https://cmake.org/cmake/help/latest/manual/cmake-properties.7.html#id1
I totally agree with the name I chose being off. :) What do you think about
mayaUsd_set_python_module_properties
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I think it was mostly the name that tripped me up. mayaUsd_set_python_module_properties
sounds great to me.
# ----------------------------------------------------------------------------- | ||
target_include_directories(${TARGET_NAME} | ||
PRIVATE | ||
"${CMAKE_CURRENT_SOURCE_DIR}/.." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This relative pathing is kind of unfortunate. I'd rather see this use headers from the build or install tree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally agree. I am not really a big fan either. This was the way the cmake code came from mayaToHydra project and I wanted to discuss it with Paul as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, fine for now, but worth revisiting later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed as well!
Actually, my hope is that once everything is properly modernized, we'll inherit this directory "for free", from linking against hdMaya, and we can drop this line entirely.
- using Boost::filesystem and Boost::system instead of ${Boost_FILESYSTEM_LIBRARY} and ${Boost_SYSTEM_LIBRARY}
…ct and didn't really belong in the public list. This makes it more explicit and clear as where the include directories are coming from. - Removed unused ${MAYAUSD_INCLUDE_DIR} variable.
… the Python module library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! I'm sure we'll refine this stuff more as we go, but this is a great step forward. Thanks @HamedSabri-adsk!
# | ||
|
||
cmake_minimum_required(VERSION 3.12.0) | ||
cmake_minimum_required(VERSION 3.13...3.17) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, sorry. See? I should have rtfm. :)
I foolishly assumed the max was a hard cutoff on which versions of CMake the project could be built with. Makes a lot more sense that it only determines policy settings instead. Duh...
cmake/utils.cmake
Outdated
function(mayaUsd_promoteMayaUsdHeader) | ||
set(srcFile ${CMAKE_CURRENT_SOURCE_DIR}/base/mayaUsd.h.src) | ||
set(srcFile ${CMAKE_CURRENT_SOURCE_DIR}/mayaUsd.h.src) | ||
set(dstFile ${CMAKE_BINARY_DIR}/include/mayaUsd/mayaUsd.h) | ||
if (NOT EXISTS ${dstFile}) | ||
message(STATUS "promoting: " ${srcFile}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry if I was unclear. I think I get what the function does. My gripe was more that I think as a function, this only gets called in one place, doesn't it? I would think we only install the mayaUsd.h
file once. Can/should we just put this code directly in the lib/base/CMakeLists.txt?
@@ -401,15 +321,17 @@ function(separate_argument_list listName) | |||
endfunction() | |||
|
|||
# python extension module suffix | |||
function(set_python_module_suffix target) | |||
function(set_python_module_property target) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I think it was mostly the name that tripped me up. mayaUsd_set_python_module_properties
sounds great to me.
lib/base/CMakeLists.txt
Outdated
mayaUsd_promoteMayaUsdHeader() | ||
mayaUsd_promoteHeaderList(HEADERS ${headers} SUBDIR base) | ||
|
||
# ----------------------------------------------------------------------------- | ||
# install | ||
# ----------------------------------------------------------------------------- | ||
install(FILES ${headers} | ||
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/mayaUsd/base | ||
) | ||
|
||
install(FILES ${CMAKE_BINARY_DIR}/include/mayaUsd/mayaUsd.h | ||
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/mayaUsd | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may again be exposing my CMake ignorance, but is this not what the INTERFACE keyword is for?
It seems like things that link against mayaUsd shouldn't need to do anything special (like add an include directory) other than just declare their dependence on mayaUsd. The build and install requirements necessary for a dependency of a downstream library should all be determined by the properties of the upstream target.
I think I probably need to do my CMake homework here, and am totally happy to revisit this later when I have a better understanding.
# ----------------------------------------------------------------------------- | ||
target_include_directories(${TARGET_NAME} | ||
PRIVATE | ||
"${CMAKE_CURRENT_SOURCE_DIR}/.." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, fine for now, but worth revisiting later.
lib/usd/hdMaya/CMakeLists.txt
Outdated
mayaUsd | ||
${OPENGL_gl_LIBRARY} | ||
${MAYA_LIBRARIES} | ||
${Boost_LIBRARIES} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Boost::boost here, maybe?
…his is not really a utility function. - replace ${Boost_LIBRARIES} with Boost::boost
@mattyjams Thanks a lot for all the great feedback. You are a CMake Ninja yourself and don't show :) I am sure we can refine things as we go and more than happy to do so. Cheers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MacOS build is failing during linking of lib/libmayaUsd.dylib
…at I missed in the latest merge.
See 9187c51 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me - just a few small questions / comments!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I tried to build with these changes, I got an error when linking DiffCore - it couldn't find pthread.
When I changed this line:
${GTEST_LIBRARIES} |
...to instead use the GTest::GTest
target (and eliminated explicit add of ${GTEST_INCLUDE_DIRS}
as well), then this error went away.
[184/400] Linking CXX executable test/lib/usd/utils/DiffCore
FAILED: test/lib/usd/utils/DiffCore
: && /usr/lib64/ccache/g++ -msse3 -std=c++11 -Wall -Werror -Wno-deprecated -Wno-deprecated-declarations -Wno-unused-local-typedefs -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11 -Wall -Werror -Wno-deprecated -Wno-deprecated-declarations -Wno-unused-local-typedefs -O3 -DNDEBUG -Wl,--enable-new-dtags test/lib/usd/utils/CMakeFiles/DiffCore.dir/main.cpp.o test/lib/usd/utils/CMakeFiles/DiffCore.dir/test_DiffCore.cpp.o -o test/lib/usd/utils/DiffCore -L/luma/soft/rez/packages/tbb/2017.0.6.nolibstdcpp.1/platform-linux/lib -Wl,-rpath,/Volumes/sv-dev01/devRepo/paulm/projects/rez-build/maya_usd/dev/build/platform-linux/gcc-6.3/maya-2019/usd-0.20.02.luma02/tbb-2017.0/lib/usd/utils:/luma/soft/rez/packages/usd/0.20.02.luma02/platform-linux/gcc-6.3/lib:/usr/local/python-2.7.7/lib:/luma/soft/rez/packages/boost/1.61.0/platform-linux/gcc-6.3.1/python-2.7/lib:/luma/soft/rez/packages/tbb/2017.0.6.nolibstdcpp.1/platform-linux/lib:/luma/soft/rez/packages/jemalloc/4.4.0/platform-linux/gcc-6.3.1/lib /luma/soft/rez/packages/googletest/1.8.0.fPIC/platform-linux/lib64/libgtest.a lib/usd/utils/libmayaUsdUtils.so /luma/soft/rez/packages/usd/0.20.02.luma02/platform-linux/gcc-6.3/lib/liblumausd.so /luma/soft/rez/packages/usd/0.20.02.luma02/platform-linux/gcc-6.3/lib/liblumakind.so /luma/soft/rez/packages/usd/0.20.02.luma02/platform-linux/gcc-6.3/lib/liblumapcp.so /luma/soft/rez/packages/usd/0.20.02.luma02/platform-linux/gcc-6.3/lib/liblumasdf.so /luma/soft/rez/packages/usd/0.20.02.luma02/platform-linux/gcc-6.3/lib/liblumaar.so /luma/soft/rez/packages/usd/0.20.02.luma02/platform-linux/gcc-6.3/lib/liblumaplug.so /luma/soft/rez/packages/usd/0.20.02.luma02/platform-linux/gcc-6.3/lib/liblumavt.so /luma/soft/rez/packages/usd/0.20.02.luma02/platform-linux/gcc-6.3/lib/liblumagf.so /luma/soft/rez/packages/usd/0.20.02.luma02/platform-linux/gcc-6.3/lib/liblumawork.so /luma/soft/rez/packages/usd/0.20.02.luma02/platform-linux/gcc-6.3/lib/liblumatrace.so /luma/soft/rez/packages/usd/0.20.02.luma02/platform-linux/gcc-6.3/lib/liblumajs.so /luma/soft/rez/packages/usd/0.20.02.luma02/platform-linux/gcc-6.3/lib/liblumatf.so /luma/soft/rez/packages/usd/0.20.02.luma02/platform-linux/gcc-6.3/lib/liblumaarch.so -ldl /usr/lib64/libm.so /usr/local/python-2.7.7/lib/libpython2.7.so /luma/soft/rez/packages/boost/1.61.0/platform-linux/gcc-6.3.1/python-2.7/lib/libboost_python.so -ltbb /luma/soft/rez/packages/jemalloc/4.4.0/platform-linux/gcc-6.3.1/lib/libjemalloc.so && :
/opt/rh/devtoolset-6/root/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/ld: /luma/soft/rez/packages/googletest/1.8.0.fPIC/platform-linux/lib64/libgtest.a(gtest-all.cc.o): undefined reference to symbol 'pthread_key_delete@@GLIBC_2.2.5'
//lib64/libpthread.so.0: error adding symbols: DSO missing from command line
- Remove unnecessary CopyRight
Hmm, I don't understand the gtest issue. What do you get when you print out GTEST_INCLUDE_DIRS , GTEST_LIBRARIES ? message("GTEST_INCLUDE_DIRS = " ${GTEST_INCLUDE_DIRS}) |
@elrond79 Fyi, I don't see the Gtest issue on Linux either. Are you using maya-usd/build.py script to build things? The reason I am asking is because I see some traces of |
Well, it may well be the case that there’s something different about my setup; but even if we were to assume there are no functional differences, doesn’t changing things to use the target instead of the explicit libs fit exactly within what this PR is designed to do - change cmake to use more modern, target based practices? |
@elrond79 |
I'm saying let's ignore the particular GTest failure I got for a moment, and treat it as a general matter, regarding CMake modernization. Isn't changing
for
(and also removing the now unneeded |
Ugh I see...... Yes, definitely. In fact, I did a similar change for boost (Boost::boost vs ${Boost_LIBRARIES}) that Matt pointed out in this PR. I already have in my Todo list to create a PR to fix things like ${MAYA_LIBRARIES}, ${TBB_LIBRARIES}, etc... |
Cool - now, re: the specific error I got - I've now learned that error is NOT directly related to this PR, since I'm seeing the same thing on current dev. So the problem is some sort of intersection between one of the other recent changes merged into dev, and our particular compilation environment. (If I had to guess, it's something related to the details of how gtest is built...?) However, since the fix makes sense in this PR's context, it would be nice to have it here. If you'd rather I make it into a separate PR, though, I'm ok with that too. |
…NCLUDE_DIRS if using the target directly. This is done automatically.
Consider it done: See 01122bb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
I just noticed switching to GTest::GTest has broken the debug build on Windows!! Something to look at tomorrow.
|
…smission attributes for hydra usd preview surface. (#323)
Description:
This PR aims at making sure the CMake codes under
lib
andplugin/adsk
are up to a good quality standard. As our code base grow, it is imperative to make sure there is consistency among CMake files and build/usage requirements of targets( shared libraries, executable, etc...) are very clear for the clients.