[custom] CMakeLists.txt improvement suggestion
The root CMakeLists.txt file collect subprojects using macro collect_subproject_directory_names() and stores the subproject names in PCL_MODULES_NAMES, subproject directories names in PCL_MODULES_DIRS. According to my understanding, the reason for this is to prevent inconsistencies between subproject name and subproject directory name.
However, in macro PCL_SUBSYS_DEPEND(), the project collect include directories of subproject using include_directories(${PROJECT_SOURCE_DIR}/${_include_dir}/include), and the ${_include_dir} is set to subproject name in macro PCL_GET_SUBSYS_INCLUDE_DIR(), rather than subproject directory name. So errors may occur when subproject directory name is different with subproject name. Of course, so far, the structure of each sub module of PCL is consistent, so there will be no such problem. But I still want to submit an issue about it. : )
@pla66 Thanks for reporting. As you mentioned, so far everything is consistent, and I would say it's unlikely that will ever change. Still, do you have a suggestion how to fix this? If it is an easy fix, it would be nice to do it, otherwise I wouldn't worry about it until it actually becomes a problem.
@pla66 Thanks for reporting. As you mentioned, so far everything is consistent, and I would say it's unlikely that will ever change. Still, do you have a suggestion how to fix this? If it is an easy fix, it would be nice to do it, otherwise I wouldn't worry about it until it actually becomes a problem.
I agree with the structure of the current PCL project that codes of a subproject store in a same-name folder. Such code organization principle is simple and elegant. So maybe the code in root CMakeLists.txt file does not need to maintain the variable PCL_MODULES_DIRS and use PCL_MODULES_NAMES instead. And if there is a inconsistence between subproject directory name and subproject name, an error should be raised. Should I pull a new request or just suggest here, since this is a little and unimportant code suggestion? This improvment is for developers not for users, so there is no problem without making changes. I came up with this idea because I use PCL cmake structure for reference to build my own cmake structure. There is much worth learning. Thanks for your reply!
I checked and there is actually one difference: global_tests (module name) vs test (module dir). But this doesn't matter since there are no includes in the test module that are needed in other modules.
So how about for now just a check whether all entries in PCL_MODULES_DIRS and PCL_MODULES_NAMES are the same (except for global_tests - test), and a CMake warning otherwise? Ideally the check would happen inside the collect_subproject_directory_names macro in pcl_targets.cmake. Feel free to create a new pull request.
I checked and there is actually one difference:
global_tests(module name) vstest(module dir). But this doesn't matter since there are no includes in the test module that are needed in other modules. So how about for now just a check whether all entries in PCL_MODULES_DIRS and PCL_MODULES_NAMES are the same (except for global_tests - test), and a CMake warning otherwise? Ideally the check would happen inside thecollect_subproject_directory_namesmacro in pcl_targets.cmake. Feel free to create a new pull request.
I have found some other mistakes in CMake files, and have come up with some other code improvement suggestions. Give me some time to sort them out and pull a request. : )
@pla66 Any news here? Otherwise I will probably close this issue
@pla66 Any news here? Otherwise I will probably close this issue
sorry, some other works interrupted recently. I'll pull a new request as soon as possible.
I am closing this issue because it seems unlikely that this problem will ever arise. Still, feel free to create a pull request with your suggested changes, if you like.