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

Reduce unnecessary nesting in "CMakeLists.txt" #2718

Merged

Conversation

SunBlack
Copy link
Contributor

Reduce unnecessary nesting in CMakeLists.txt in case global deactivation parameter exists.

Example:
Old:

if(build)
  // Whole remaining CMake code
endif() //endif at end of file

new:

if(NOT build)
  return()
endif()
// Whole remaining CMake code

PS @whoever is reviewing this: I hope you are not using GitHub diff view to check this PR. A diff view where you can ignore whitespace changes is much better here ;)

@SunBlack SunBlack force-pushed the reduce_nesting_in_CMakeLists branch 3 times, most recently from f76ca8a to 1531b2d Compare December 16, 2018 17:36
apps/CMakeLists.txt Outdated Show resolved Hide resolved
features/CMakeLists.txt Outdated Show resolved Hide resolved
filters/CMakeLists.txt Outdated Show resolved Hide resolved
tools/CMakeLists.txt Show resolved Hide resolved
@taketwo
Copy link
Member

taketwo commented Dec 19, 2018

I've restarted the Ubuntu job two times, but it always failed. This does not look like a compilation problem, rather like the agent is running out of memory and loses communication. Question is, what is it in this pull request that affected the build?

@SunBlack
Copy link
Contributor Author

Mhm, there are only two changed which could have an effect:

  • Rename from BUILD_tools to build, but this does not changed anything as explained in conversation above.

  • I change this on time from

if(UNIX OR APPLE)
  set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}  "-Xcompiler;-fPIC;")
endif()
if(NOT UNIX OR APPLE)
  add_definitions(-DPCLAPI_EXPORTS)
endif()

to

if(UNIX OR APPLE)
  set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}  "-Xcompiler;-fPIC;")
else
  add_definitions(-DPCLAPI_EXPORTS)
endif()

But I now believe this adjustment was not correct, even it should not affect Ubuntu build. I believed if(NOT UNIX OR APPLE) is equal to if(NOT (UNIX OR APPLE)) bot now I think it is equal to if((NOT UNIX) OR APPLE) (not tested yet if OR or NOT are stronger in CMake), so I believe correct would be:

if(UNIX OR APPLE)
  set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}  "-Xcompiler;-fPIC;")
endif()
if(NOT UNIX) # Removed APPLE, because if NOT UNIX is already true, value of APPLE, WIN32, ... doesn't matter
  add_definitions(-DPCLAPI_EXPORTS)
endif()

@taketwo
Copy link
Member

taketwo commented Dec 19, 2018

So I believe correct would be:

if(UNIX OR APPLE)
  set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}  "-Xcompiler;-fPIC;")
endif()
if(NOT UNIX) # Removed APPLE, because if NOT UNIX is already true, value of APPLE, WIN32, ... doesn't matter
  add_definitions(-DPCLAPI_EXPORTS)
endif()

Are you sure that APPLE is not counted as UNIX? I can imagine that both variables are true on MacOS, though I'm not a MacOS user, so can not confirm.

@taketwo
Copy link
Member

taketwo commented Dec 19, 2018

Generally, I don't have a good feeling about this PR in it's current state. We need to have absolutely clear separation between commits that only change indentation, commits that change variable names, and commits that (potentially) alter the logic. Otherwise, if a problem is discovered later on, we will need to skim through 5K lines trying to identify if we have some "innocent fix" that was smuggled together with indentation change.

@SunBlack
Copy link
Contributor Author

I have reverted logic change to this (see last commit), so this PR should just adjust nesting and indentation (except the one thing with BUILD_tools).

@SunBlack
Copy link
Contributor Author

Last entries on log before crash:

[ 85%] Building CXX object test/registration/CMakeFiles/test_registration_api.dir/test_registration_api.cpp.o
Scanning dependencies of target test_registration_api
[ 85%] Built target test_keypoints
[ 85%] Linking CXX executable test_keypoints
[ 85%] Building CXX object test/registration/CMakeFiles/test_registration.dir/test_registration.cpp.o

But I don't see any big CMake adjustments in test/registration/CMakeFiles.

Can you rerun build of last successful build (ba0a6a6), so we can see, if it is not any other issue?

@taketwo
Copy link
Member

taketwo commented Dec 19, 2018

Let's see: https://dev.azure.com/PointCloudLibrary/pcl/_build/results?buildId=499

Edit: maybe we should consider splitting test_registration into several parts.

@SunBlack
Copy link
Contributor Author

Found an issue by comparing resulting Makefile before and after my change. Now they are equal :)

@taketwo
Copy link
Member

taketwo commented Dec 19, 2018

Old code:

if(build)
if(BUILD_io AND BUILD_features)

New code:

if(NOT (build OR (BUILD_io AND BUILD_features)))
   return()
endif()

This is not equivalent. Where does OR come from?

@SunBlack
Copy link
Contributor Author

You are right. Fixed.

@SunBlack
Copy link
Contributor Author

Let's see: https://dev.azure.com/PointCloudLibrary/pcl/_build/results?buildId=499

Failed too, so it seems a issue not related to this PR.

@taketwo
Copy link
Member

taketwo commented Dec 20, 2018

We need to resolve a conflict and to rebase here as well, then can merge if the pipelines succeed.

Copy link
Member

@taketwo taketwo left a comment

Choose a reason for hiding this comment

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

I was going through the PR one last time and noticed this change in NSIS. Please revert it and then I'll merge.

cmake/Modules/NSIS.template.in Show resolved Hide resolved
@taketwo taketwo merged commit 214bb39 into PointCloudLibrary:master Dec 20, 2018
@SunBlack SunBlack deleted the reduce_nesting_in_CMakeLists branch December 22, 2018 10:17
SunBlack pushed a commit to SunBlack/pcl that referenced this pull request Feb 1, 2019
@taketwo taketwo changed the title Reduce unnecessary nesting in CMakeLists.txt Reduce unnecessary nesting in "CMakeLists.txt" Jan 18, 2020
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.

2 participants