View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015723CMakeCMakepublic2015-09-02 06:312016-02-01 09:10
ReporterAdam Strzelecki 
Assigned ToRolf Eike Beer 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product VersionCMake 3.3.1 
Target VersionCMake 3.4Fixed in VersionCMake 3.4 
Summary0015723: Regression: FindCUDA fails for C++ only projects in CMake 3.3.1 due find_package(Threads), while it works well in CMake 3.2.3
DescriptionCUDA language is C++ superset, so developers may prefer using C++ only project together with CUDA. FindCUDA already supports such case (1) when neither CUDA_HOST_COMPILER nor CMAKE_C_COMPILER is defined, just skips adding --ccbin.

Another case (2) is that user defined its own CUDA_HOST_COMPILER that is different than CMAKE_C_COMPILER, then custom host compiler is passed to --ccbin.

The problem is that recently CUDA_USE_STATIC_CUDA_RUNTIME (default ON) started calling find_package(Threads REQUIRED) that tries to lookup pthread using CMAKE_C_COMPILER which is invalid in both cases (1) (2).

However I don't see any clear solution here. I understand that linking CUDA static rt requires pthread linkage, but maybe we should just check if current linker can either link -lpthread or -pthread, rather falling back to C compiler that may be undefined for the project?
Steps To Reproduce# CMakeList.txt
cmake_minimum_required(VERSION 2.6)
project(OnlyCXXCUDA CXX)
find_package(CUDA)


$ cmake .
-- The CXX compiler identification is AppleClang 7.0.0.7000059
-- Check for working CXX compiler: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for include file pthread.h
CMake Error at /Applications/CMake.app/Contents/share/cmake-3.3/Modules/CheckIncludeFiles.cmake:79 (try_compile):
  Unknown extension ".c" for file

    /Users/ono/Documents/Bugs/CMake/FindCUDA/CMakeFiles/CMakeTmp/CheckIncludeFiles.c

  try_compile() works only for enabled languages. Currently these are:

    CXX

  See project() command to enable other languages.
Call Stack (most recent call first):
  /Applications/CMake.app/Contents/share/cmake-3.3/Modules/FindThreads.cmake:123 (CHECK_INCLUDE_FILES)
  /Applications/CMake.app/Contents/share/cmake-3.3/Modules/FindCUDA.cmake:741 (find_package)
  CMakeLists.txt:3 (find_package)


-- Looking for include file pthread.h - not found
CMake Error at /Applications/CMake.app/Contents/share/cmake-3.3/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
  Could NOT find Threads (missing: Threads_FOUND)
Call Stack (most recent call first):
  /Applications/CMake.app/Contents/share/cmake-3.3/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
  /Applications/CMake.app/Contents/share/cmake-3.3/Modules/FindThreads.cmake:204 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  /Applications/CMake.app/Contents/share/cmake-3.3/Modules/FindCUDA.cmake:741 (find_package)
  CMakeLists.txt:3 (find_package)


-- Configuring incomplete, errors occurred!
See also "/Users/ono/Documents/Bugs/CMake/FindCUDA/CMakeFiles/CMakeOutput.log".
See also "/Users/ono/Documents/Bugs/CMake/FindCUDA/CMakeFiles/CMakeError.log".
TagsNo tags attached.
Attached Files

 Relationships
related to 0015482closedJames Bigler CUDA - Support Static Linked Binaries. 
related to 0014905closedRolf Eike Beer FindThreads doesn't clearly express it requires C language enabled. 

  Notes
(0039363)
Brad King (manager)
2015-09-02 09:05

For issue 0015482 this change was made:

 FindCUDA: Use the static CUDA runtime library if available
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7fea2b77 [^]

That also hard-codes use of CMAKE_C_FLAGS.
(0039364)
Brad King (manager)
2015-09-02 09:13

FindThreads should be fixed to work when C is not enabled. It could also be taught to fail with a nicer message when neither C nor CXX is enabled.
(0039399)
Thiago M. (reporter)
2015-09-10 14:12
edited on: 2015-09-10 14:16

The fix to FindThreads to work when C is not enabled is suggested in issue 0014905.

(0039473)
Rolf Eike Beer (developer)
2015-09-23 05:42

The limitation to C should be gone now, there are patches in next that should make FindThreads.cmake work in projects where only C++ is enabled.
(0039479)
Brad King (manager)
2015-09-25 10:14

Eike's topic to fix FindThreads with only CXX enabled has been merged to 'master' here:

 Merge topic 'Threads-CXX'
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=910ea210 [^]
(0040418)
Robert Maynard (manager)
2016-02-01 09:10

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2015-09-02 06:31 Adam Strzelecki New Issue
2015-09-02 09:04 Brad King Relationship added related to 0015482
2015-09-02 09:05 Brad King Note Added: 0039363
2015-09-02 09:06 Brad King Target Version => CMake 3.4
2015-09-02 09:13 Brad King Note Added: 0039364
2015-09-10 14:12 Thiago M. Note Added: 0039399
2015-09-10 14:16 Thiago M. Note Edited: 0039399
2015-09-10 14:18 Brad King Relationship added related to 0014905
2015-09-14 14:07 Brad King Target Version CMake 3.4 =>
2015-09-23 05:42 Rolf Eike Beer Note Added: 0039473
2015-09-25 10:14 Brad King Note Added: 0039479
2015-09-25 10:14 Brad King Assigned To => Rolf Eike Beer
2015-09-25 10:14 Brad King Status new => resolved
2015-09-25 10:14 Brad King Resolution open => fixed
2015-09-25 10:14 Brad King Fixed in Version => CMake 3.4
2015-09-25 10:14 Brad King Target Version => CMake 3.4
2016-02-01 09:10 Robert Maynard Note Added: 0040418
2016-02-01 09:10 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team