how do you allow CMAKE_CUDA_COMPILER to be optional via project LANGUAGE?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

how do you allow CMAKE_CUDA_COMPILER to be optional via project LANGUAGE?

Quang Ha
Hi all,

So this question is again about project(foo LANGUAGES CXX CUDA). Is it possible to switch off CUDA if Cmake couldn't find CUDA compiler? I.e. something along the line:

if (CUDA_FOUND)
  set_language_to_CUDA_and_CXX
else(CUDA_FOUND)
  set_language_to_CXX_only
endif(CUDA_FOUND)

The main reason is I don't want CMake to fail when CUDA compiler isn't available. Rather, it should continue to compile the source files using CPP compilers instead.

Thanks,
Quang

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: how do you allow CMAKE_CUDA_COMPILER to be optional via project LANGUAGE?

Eric Noulard


Le mar. 28 août 2018 à 19:07, Quang Ha <[hidden email]> a écrit :
Hi all,

So this question is again about project(foo LANGUAGES CXX CUDA). Is it possible to switch off CUDA if Cmake couldn't find CUDA compiler? I.e. something along the line:

May be you can only:

  project(foo LANGUAGES CXX)

then

include(CheckLanguage)
check_language(CUDA)
if(CMAKE_CUDA_COMPILER)
  enable_language(CUDA)
else()
  message(STATUS "No CUDA compiler found")
endif()

see doc:


Eric


if (CUDA_FOUND)
  set_language_to_CUDA_and_CXX
else(CUDA_FOUND)
  set_language_to_CXX_only
endif(CUDA_FOUND)

The main reason is I don't want CMake to fail when CUDA compiler isn't available. Rather, it should continue to compile the source files using CPP compilers instead.

Thanks,
Quang
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake


--
Eric

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: how do you allow CMAKE_CUDA_COMPILER to be optional via project LANGUAGE?

Robert Maynard
The way Eric suggest with check_language is what I use when I want to conditionally support CUDA.

On Tue, Aug 28, 2018 at 10:28 AM Eric Noulard <[hidden email]> wrote:


Le mar. 28 août 2018 à 19:07, Quang Ha <[hidden email]> a écrit :
Hi all,

So this question is again about project(foo LANGUAGES CXX CUDA). Is it possible to switch off CUDA if Cmake couldn't find CUDA compiler? I.e. something along the line:

May be you can only:

  project(foo LANGUAGES CXX)

then

include(CheckLanguage)
check_language(CUDA)
if(CMAKE_CUDA_COMPILER)
  enable_language(CUDA)
else()
  message(STATUS "No CUDA compiler found")
endif()

see doc:


Eric


if (CUDA_FOUND)
  set_language_to_CUDA_and_CXX
else(CUDA_FOUND)
  set_language_to_CXX_only
endif(CUDA_FOUND)

The main reason is I don't want CMake to fail when CUDA compiler isn't available. Rather, it should continue to compile the source files using CPP compilers instead.

Thanks,
Quang
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake


--
Eric
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: how do you allow CMAKE_CUDA_COMPILER to be optional via project LANGUAGE?

Quang Ha
It works perfectly - thanks!

QT

On Tue, 28 Aug 2018 at 12:37, Robert Maynard <[hidden email]> wrote:
The way Eric suggest with check_language is what I use when I want to conditionally support CUDA.

On Tue, Aug 28, 2018 at 10:28 AM Eric Noulard <[hidden email]> wrote:


Le mar. 28 août 2018 à 19:07, Quang Ha <[hidden email]> a écrit :
Hi all,

So this question is again about project(foo LANGUAGES CXX CUDA). Is it possible to switch off CUDA if Cmake couldn't find CUDA compiler? I.e. something along the line:

May be you can only:

  project(foo LANGUAGES CXX)

then

include(CheckLanguage)
check_language(CUDA)
if(CMAKE_CUDA_COMPILER)
  enable_language(CUDA)
else()
  message(STATUS "No CUDA compiler found")
endif()

see doc:


Eric


if (CUDA_FOUND)
  set_language_to_CUDA_and_CXX
else(CUDA_FOUND)
  set_language_to_CXX_only
endif(CUDA_FOUND)

The main reason is I don't want CMake to fail when CUDA compiler isn't available. Rather, it should continue to compile the source files using CPP compilers instead.

Thanks,
Quang
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake


--
Eric
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake