-
Notifications
You must be signed in to change notification settings - Fork 194
Detect availability of OpenMP in CMake and Make files #1001
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
base: main
Are you sure you want to change the base?
Conversation
All of the secondary cmakelists.txt files contained code equivalent to: ```cmake target_link_libraries(qsim_decide OpenMP::OpenMP_CXX) ``` Although the use of `link_libraries()` tends to be discouraged in modern CMake usage, this is a case where IMHO it's worth using. I think its use will prevent mistakes and inconsistencies by centralizing the OpenMP setting.
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.
Code Review
This pull request centralizes the OpenMP linking logic by removing individual target_link_libraries calls from subprojects and adding a single link_libraries call in the top-level CMakeLists.txt. While centralizing the logic is a good goal, the use of the obsolete link_libraries command introduces maintainability risks. My review includes a suggestion for a more modern and robust approach using an INTERFACE library to manage this shared dependency.
Gemini Code Assist in code review advocated against using `link_libraries()`. Although I dislike the need to have to put the same command in every cmakelists.txt file, the fact that `link_libraries()` is recommended against is a concern for long-term maintenance and therefore this alternative approach may be be tter in the long run.
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.
Code Review
This pull request correctly refactors the OpenMP dependency handling by centralizing the configuration in the top-level CMakeLists.txt and using an INTERFACE library. The changes in the sub-project CMakeLists.txt files are consistent and improve maintainability. However, there is a critical issue in the top-level CMakeLists.txt where a redundant and conflicting find_package(OpenMP REQUIRED) call remains, which will prevent the new conditional OpenMP logic from working correctly.
The CMake files now check if OpenMP can be used. The Makefiles should too.
All of the secondary cmakelists.txt files contained code equivalent to:
target_link_libraries(qsim_decide OpenMP::OpenMP_CXX)This PR updates the form to use the recommended approach of configuring the use in the top-level
CMakeLists.txtand then usingINTERFACEin the calls totarget_link_libraries. The code there and also in the updatedMakefilechecks that OpenMP is supported on the host before adding the link flag.