Skip to content
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

prevent GCC flags propagating to NVCC #2430

Merged
merged 2 commits into from
Sep 12, 2018

Conversation

jasjuang
Copy link
Contributor

With the merge of #2100 now all the compile definitions got carried along when target_link_libraries(${PROJECT_NAME} ${PCL_LIBRARIES}) is called, however we don't want these definitions to be propagated to CUDA files because NVCC can't recognize it. This PR prevents this problem.

@taketwo
Copy link
Member

taketwo commented Sep 10, 2018

We are still keeping our CMake minimum requirement pretty low (at least for this release). We should double-check that this does not rely on recent CMake versions.

@taketwo
Copy link
Member

taketwo commented Sep 10, 2018

I'm afraid there are a bunch of problems here:

  • COMPILER_LANGUAGE was introduced in 3.3
  • it is not supported by Visual Studio, so portable buildsystems should not use it
  • CUDA became a first-class language in 3.8, before it probably counts as CXX

@jasjuang
Copy link
Contributor Author

It is actually supported by Visual studio https://gitlab.kitware.com/cmake/cmake/merge_requests/1657 and https://gitlab.kitware.com/cmake/cmake/issues/17435.

If we want to support old cmake versions, maybe we can do a bunch of if else (if(CMAKE_VERSION VERSION_LESS 3.3)) etc to guard it? And for people that's still stuck on old cmakes they will have no way to avoid this error.

@taketwo
Copy link
Member

taketwo commented Sep 10, 2018

Yes, I think we should add a version check, we can not just break the config file for the users of old CMake.

And for people that's still stuck on old cmakes they will have no way to avoid this error.

I hope this is not a wide-spread use case to link CUDA targets against PCL. If there will be people complaining, there is a workaround: link the "old way" against "raw" libraries ${PCL_${COMPONENT}_LIBRARY}.

@SergioRAgostinho what do you think?

@SergioRAgostinho
Copy link
Member

SergioRAgostinho commented Sep 11, 2018

I'm ok with the version check. I'm not sure I fully understand

I hope this is not a wide-spread use case to link CUDA targets against PCL. If there will be people complaining, there is a workaround: link the "old way" against "raw" libraries ${PCL_${COMPONENT}_LIBRARY}.

because of inexperience with compiling CUDA targets. But if there's a workaround I assume I don't need to worry much.

We are still keeping our CMake minimum requirement pretty low (at least for this release)

My next goal is C++14. I was hoping to bump the min CMake version to 3.1 to support CXX_STANDARD.

@taketwo
Copy link
Member

taketwo commented Sep 11, 2018

It just struck me that before 3.8 a special command was used to create CUDA targets, and this command did not respect transitive properties anyway. So everything should be fine with the users of old CMake as long as we add guards.

My next goal is C++14. I was hoping to bump the min CMake version to 3.1 to support CXX_STANDARD.

I think we can lift minimum requirements for our dependencies. The reasoning would be: we are going for C++14 => oldest Ubuntu LTS that supports it is 16.04 => use this as a baseline. This means, among other things, that we can require CMake 3.5. But I think we can have a separate issue for deciding on the baseline and versions after the release.

@taketwo taketwo added the needs: more work Specify why not closed/merged yet label Sep 11, 2018
@taketwo taketwo added this to the pcl-1.9.0 milestone Sep 11, 2018
@jasjuang
Copy link
Contributor Author

@taketwo @SergioRAgostinho What is the decision for this PR? Does something like

if(CMAKE_VERSION VERSION_LESS 3.3)
set_target_properties(${pcl_component}
        PROPERTIES
          INTERFACE_COMPILE_DEFINITIONS "${definitions}"
          INTERFACE_COMPILE_OPTIONS "${PCL_COMPILE_OPTIONS}"
          INTERFACE_INCLUDE_DIRECTORIES "${PCL_${COMPONENT}_INCLUDE_DIRS}"
          INTERFACE_LINK_LIBRARIES "${PCL_${COMPONENT}_LINK_LIBRARIES}"
      )
else()
set_target_properties(${pcl_component}
        PROPERTIES
          INTERFACE_COMPILE_DEFINITIONS "${definitions}"
          INTERFACE_COMPILE_OPTIONS "$<$<COMPILE_LANGUAGE:CXX>:${PCL_COMPILE_OPTIONS}>"
          INTERFACE_INCLUDE_DIRECTORIES "${PCL_${COMPONENT}_INCLUDE_DIRS}"
          INTERFACE_LINK_LIBRARIES "${PCL_${COMPONENT}_LINK_LIBRARIES}"
      )
endif()

work?

@taketwo
Copy link
Member

taketwo commented Sep 12, 2018

LGTM. And after the release we will lift CMake requirement and drop the first branch.

@SergioRAgostinho
Copy link
Member

Now I fully got the "transitive properties" and why setting compiler language to cxx won't create a problem before or after 3.8.

@jasjuang I also believe that should solve it. Go for it.

@jasjuang
Copy link
Contributor Author

@taketwo @SergioRAgostinho Just pushed the approved change. Please merge!

@taketwo taketwo removed the needs: more work Specify why not closed/merged yet label Sep 12, 2018
Copy link
Member

@SergioRAgostinho SergioRAgostinho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this closes it for this release then 👏 Now it's closing up.

@taketwo
Copy link
Member

taketwo commented Sep 12, 2018

#2439 please also

@guteksan
Copy link

Hello,
It looks like you have fixed this problem in 1.9.0 release, however for some reason I need to use PCL in verson 1.8.1, and I have exactly this problem: I am linking my project with CUDA and PCL and flag '-fPIC' is passed to nvcc, which fails at it.

I tried the workaround mentioned above, use

target_link_libraries(xxx PUBLIC
    ${PCL_SEGMENTATION_LIBRARIES})

instead of

target_link_libraries(xxx PUBLIC
    ${PCL_LIBRARIES})

but this does not work (I think fPIC flag comes from segmentation module, other modules seem to be safe). Can you suggest another workaround how to link PCL with CUDA?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants