MantisBT - CMake
View Issue Details
0014836CMakeCMakepublic2014-03-25 13:102014-10-06 10:33
Michael Priestman 
 
normalmajoralways
closedfixed 
Apple MacOS X10.4.10
CMake 2.8.12 
CMake 2.8.12.2CMake 2.8.12.2 
0014836: find_package(Threads) fails on Mac OS X with Xcode 5.1.
When CMake tries to find the threading libraries using find_package(Threads), it will fail on Mac OS X and Xcode 5.1.

It works fine with Xcode 5.0.
To reproduce, put the following in a basic CMakeLists.txt file:

--- Begin CMakeLists.txt ---
cmake_minimum_required(VERSION 2.8)
project(Test)
find_package(Threads REQUIRED)
--- End CMakeLists.txt ---

then run:

cmake -G "Xcode"

You get the following output:

-- The C compiler identification is Clang 5.1.0
-- The CXX compiler identification is Clang 5.1.0
-- Looking for include file pthread.h
CMake Error at /Applications/CMake 2.8-12.app/Contents/share/cmake-2.8/Modules/CMakeCInformation.cmake:37 (get_filename_component):
  get_filename_component called with incorrect number of arguments
Call Stack (most recent call first):
  CMakeLists.txt:2 (PROJECT)


CMake Error: Internal CMake error, TryCompile configure of cmake failed
-- Looking for include file pthread.h - not found
CMake Error at /Applications/CMake 2.8-12.app/Contents/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
  Could NOT find Threads (missing: Threads_FOUND)
Call Stack (most recent call first):
  /Applications/CMake 2.8-12.app/Contents/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE)
  /Applications/CMake 2.8-12.app/Contents/share/cmake-2.8/Modules/FindThreads.cmake:166 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:3 (find_package)


-- Configuring incomplete, errors occurred!
This was working fine for us up until we upgraded to Xcode 5.1. Could it be just looking in the wrong place for pthread.h?

The strange thing is that if you just create a basic C file that includes <pthread.h>, it compiles fine in Xcode, so just sure what is going wrong here.
No tags attached.
related to 0014635closed Brad King CMake with Xcode generator breaks with Xcode 5.1 DP due to brittle regex in CMakeDetermineCompilerId.cmake 
zip CMakeTryCompileError.zip (49,291) 2014-03-25 16:31
https://public.kitware.com/Bug/file/5104/CMakeTryCompileError.zip
Issue History
2014-03-25 13:10Michael PriestmanNew Issue
2014-03-25 15:12Rolf Eike BeerNote Added: 0035507
2014-03-25 16:31Michael PriestmanFile Added: CMakeTryCompileError.zip
2014-03-25 16:32Michael PriestmanNote Added: 0035511
2014-03-26 08:49Brad KingNote Added: 0035520
2014-03-26 08:51Brad KingRelationship addedrelated to 0014635
2014-03-26 08:58Michael PriestmanNote Added: 0035521
2014-03-26 09:41Rolf Eike BeerStatusnew => resolved
2014-03-26 09:41Rolf Eike BeerResolutionopen => fixed
2014-03-26 09:41Rolf Eike BeerFixed in Version => CMake 2.8.12.2
2014-03-26 09:41Rolf Eike BeerTarget Version => CMake 2.8.12.2
2014-10-06 10:33Robert MaynardNote Added: 0036955
2014-10-06 10:33Robert MaynardStatusresolved => closed

Notes
(0035507)
Rolf Eike Beer   
2014-03-25 15:12   
I suspect that this is a deeper problem. Please put this in a CMakeLists.txt, run it with cmake --debug-trycompile and attach the whole build folder here:

cmake_minimum_required(VERSION 2.8)
include (CheckIncludeFiles)
CHECK_INCLUDE_FILES("pthread.h" CMAKE_HAVE_PTHREAD_H)
(0035511)
Michael Priestman   
2014-03-25 16:32   
Please find the output from the command attached to the bug. The CMake console output was:

[priestm@shfc02h60mwdhjq build]$ cmake -G "Xcode" --debug-trycompile ..
debug trycompile on
-- The C compiler identification is Clang 5.1.0
-- The CXX compiler identification is Clang 5.1.0
-- Looking for include file pthread.h
CMake Error at /Applications/CMake 2.8-12.app/Contents/share/cmake-2.8/Modules/CMakeCInformation.cmake:37 (get_filename_component):
  get_filename_component called with incorrect number of arguments
Call Stack (most recent call first):
  CMakeLists.txt:2 (PROJECT)


CMake Error: Internal CMake error, TryCompile configure of cmake failed
-- Looking for include file pthread.h - not found
-- Configuring incomplete, errors occurred!
See also "/users/priestm/Git/temp/build/CMakeFiles/CMakeOutput.log".
See also "/users/priestm/Git/temp/build/CMakeFiles/CMakeError.log".
(0035520)
Brad King   
2014-03-26 08:49   
Are you using CMake 2.8.12.2? It had this fix for Xcode 5.1 since 2.8.12.1:

 CMakeDetermineCompilerId: Fix compiler line match for Xcode 5.1
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=65ee85d0 [^]
(0035521)
Michael Priestman   
2014-03-26 08:58   
Ahh, no, I was using 2.8.12. Just upgraded to latest version, and all appears well.

Cheers Brad. You can mark this bug as fixed.
(0036955)
Robert Maynard   
2014-10-06 10:33   
Closing resolved issues that have not been updated in more than 4 months.