ROCm / rocm-cmake

CMake modules used within the ROCm libraries
https://rocm.docs.amd.com/projects/ROCmCMakeBuildTools/en/latest/
MIT License
62 stars 43 forks source link

Set project languages to NONE #108

Closed Maetveis closed 2 years ago

Maetveis commented 2 years ago

Set the languages of the projects to NONE explicitly, to avoid CMake defaulting to C and C++.

From CMake command project() documentation:

By default C and CXX are enabled if no language options are given

Maetveis commented 2 years ago

Hmm, there are lot of other project calls in the tests, probably most of them also don't compile any code. Should I change those calls as well?

cgmb commented 2 years ago
  • Finally when the build of rocm-cmake is embedded in an other project (as in the case of rocRAND)

How is rocRAND embedding rocm-cmake? You mean like add_subdirectory?

Maetveis commented 2 years ago
  • Finally when the build of rocm-cmake is embedded in an other project (as in the case of rocRAND)

How is rocRAND embedding rocm-cmake? You mean like add_subdirectory?

It's downloading, configuring and installing it via execute_process, when it's not found normally via find_package as part of Dependencies.cmake. There is some work so that this might change to using FetchContent or similar, but currently this is how its done.

rocRAND code in question

lawruble13 commented 2 years ago

Long term we would actually like to remove that code from rocRAND (and the other libraries), and have it be handled in a similar fashion to any other dependency. However this change is correct regardless, so I'm in favour.

Hmm, there are lot of other project calls in the tests, probably most of them also don't compile any code. Should I change those calls as well?

Changing those calls in the tests which don't compile anything would be appreciated, thanks.

Maetveis commented 2 years ago

I'm fine with this change regardless, but I don't see how rocm-cmake's configuration can affect your project's configuration when you're building it using execute_process like that... unless you mean that the rocm-cmake configuration itself is failing?

Yes that's what's happening, because cmake is passing the compilers via environment variables (CC or CXX) to the commands executed in execute_process (this is not documented, but easy to verify by executing env via execute_process). The catch is that its only setting these environment variables for the languages the project enables. So when rocRAND (which only enables C++) is configured it needs to have CMAKE_CXX_COMPILER=amdclang set, so that gets passed through to rocm-cmake, but cmake will search for and default to MSVC for the C compiler resulting in an error during the configuration of rocm-cmake.