-
Notifications
You must be signed in to change notification settings - Fork 7k
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
CMakeLists and C++ files refactoring. #2446
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2446 +/- ##
==========================================
- Coverage 70.65% 68.77% -1.89%
==========================================
Files 94 94
Lines 7897 7897
Branches 1241 1241
==========================================
- Hits 5580 5431 -149
- Misses 1934 2076 +142
- Partials 383 390 +7
Continue to review full report at Codecov.
|
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.
CMakeLists.txt
Outdated
@@ -1,7 +1,7 @@ | |||
cmake_minimum_required(VERSION 3.0) | |||
project(torchvision) | |||
set(CMAKE_CXX_STANDARD 14) | |||
set(TORCHVISION_VERSION 0.6.0) | |||
set(TORCHVISION_VERSION 0.5.0) |
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 seems like an unwanted change?
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.
Yes, sorry for the typo
Hi, thanks for the quick feedback! This PR targets all the C++ code, a part from |
Any news on this? |
Hi @vcarpani, can you edit the PR message to list all the changes you made? Thanks! |
CMakeLists.txt
Outdated
|
||
# Gather source files. |
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 a fan of these kinds of comments, they don't add anything valuable.
CMakeLists.txt
Outdated
"${CMAKE_CURRENT_BINARY_DIR}/TorchVisionConfig.cmake" | ||
INSTALL_DESTINATION ${TORCHVISION_CMAKECONFIG_INSTALL_DIR} | ||
) | ||
|
||
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/TorchVisionConfigVersion.cmake | ||
VERSION ${TORCHVISION_VERSION} | ||
COMPATIBILITY AnyNewerVersion) | ||
VERSION ${TORCHVISION_VERSION} | ||
COMPATIBILITY AnyNewerVersion | ||
) | ||
|
||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/TorchVisionConfig.cmake | ||
${CMAKE_CURRENT_BINARY_DIR}/TorchVisionConfigVersion.cmake | ||
DESTINATION ${TORCHVISION_CMAKECONFIG_INSTALL_DIR}) | ||
${CMAKE_CURRENT_BINARY_DIR}/TorchVisionConfigVersion.cmake | ||
DESTINATION ${TORCHVISION_CMAKECONFIG_INSTALL_DIR} | ||
) | ||
|
||
# Install library. | ||
install(TARGETS ${PROJECT_NAME} | ||
EXPORT TorchVisionTargets | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
) | ||
EXPORT TorchVisionTargets | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
) | ||
|
||
install(EXPORT TorchVisionTargets | ||
NAMESPACE TorchVision:: | ||
DESTINATION ${TORCHVISION_CMAKECONFIG_INSTALL_DIR}) | ||
NAMESPACE TorchVision:: | ||
DESTINATION ${TORCHVISION_CMAKECONFIG_INSTALL_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.
These all look like unrelated formatting changes. I'd say stick to the current style, and if you want to propose a different one do so in a different PR.
Hi @bmanga, last commit should solve your comments, plus I added the list of changes to the description of the PR |
Naive question: would it be possible to avoid moving the header files into a new directory and concentrate the changes only into CMakeLists? |
From my knowledge of CMake not, but I could look into that somewhere this week. From my point of view about C++, it is always nice to have a clear split between headers and sources and CMake makes it really easy to do that |
The reason why I'm asking is because this change will require some internal changes as well to torchvision, and in PyTorch they do mix headers and implementation in the same folder, so I would say I would prefer if we could keep it that way, specially given that in the current state of the code the implementation lives in header files. |
@vcarpani have you tried to |
@bmanga that would probably work (it is also the same approach the pytorch uses), but it is also quite horrible, since you would also get the cpp files in the include directories |
@vcarpani if you mean during installation, you can specify a PATTERN for cmake's |
@bmanga, yes I was referring to that, since it forces you to specify the installation pattern, while it is much simpler if you have only |
@vcarpani I understand your point and I agree in principle, however I don't think it's a worthwhile change as of now. I'd suggest to go for the |
This PR refactors the CMakeLists file and the C++ files, to make it easier to package the C++ version of this library.
The main problem is due to the usage of
INTERFACE_INCLUDE_DIRECTORIES
in the CMakeLists file, since it is not advisable to populate theINSTALL_INTERFACE
of theINTERFACE_INCLUDE_DIRECTORIES
of a target with paths for dependencies. That would hard-code into installed packages the include directory paths for dependencies as found on the machine the package was made on [source].Changes:
cinclude
folder.include_directories
instead ofINTERFACE_INCLUDE_DIRECTORIES
There is still some work to be done on the ROCM version of the python library.