xunzhang / gflags

Automatically exported from code.google.com/p/gflags
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

FindThreadsCXX error when cross-compiling #90

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. cross-compile gflags for armhf using a CMAKE_TOOLCHAIN_FILE

What is the expected output? What do you see instead?

Expect FindThreadsCXX to work the same as FindThreads, no error when 
cross-compiling.

Instead the following error appears:

-- Check if compiler accepts -pthread
CMake Error: TRY_RUN() invoked in cross-compiling mode, please set the 
following cache variables appropriately:
   THREADS_PTHREAD_ARG (advanced)
For details see 
/home/gpapin/projects/Kalamos/Cross/third_party-build/Build/ep_gflags/TryRunResu
lts.cmake
-- Check if compiler accepts -pthread - no

What version of the product are you using? On what operating system?

I'm using gflags version 2.1.1 from github: 
https://github.com/schuhschuh/gflags/archive/v2.1.1.tar.gz

cmake version is 3.0.2

I'm cross-compile from Ubuntu 14.04 x86_64 toward Ubuntu 14.04 armhf.

Original issue reported on code.google.com by guillaum...@parrot.com on 27 Nov 2014 at 10:58

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
The attached patch fix the problem for me but I believe it is not what you want 
otherwise FindThreadsCXX.cmake wouldn't exist.

IMHO, avoiding C and using CXX only is not such a good idea, I tried it once 
and it bit me with the CMake modules. Same problem here apparently.

Original comment by guillaum...@parrot.com on 27 Nov 2014 at 11:18

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for the report. As you use a recent CMake version, can you try what 
happens when you comment the set(CMAKE_MODULE_PATH ...) in the CMakeLists.txt 
file of gflags ? I copied the CMake files just from the development branch of 
CMake and made minor fixes that were not in their yet. It may well be that 
these issues were fixed in the meantime. If it doesn't help, going back to 
C/CXX languages is a viable option to avoid these problems until the CMake 
modules work fine with CXX only.

Original comment by andreas....@gmail.com on 27 Nov 2014 at 11:42

GoogleCodeExporter commented 9 years ago
In my version of CMake the C language is still required by the CMake modules.

...
-- Looking for stddef.h
CMake Error at 
/home/gpapin/pkg/cmake-3.0.2-Linux-i386/share/cmake-3.0/Modules/CheckIncludeFile
.cmake:58 (try_compile):
  Unknown extension ".c" for file

    /home/gpapin/pkg/gflags-2.1.1/build/CMakeFiles/CMakeTmp/CheckIncludeFile.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):
  /home/gpapin/pkg/cmake-3.0.2-Linux-i386/share/cmake-3.0/Modules/CheckTypeSize.cmake:223 (check_include_file)
  CMakeLists.txt:116 (check_type_size)
...

Did you know if an issue was reported to the CMake guys?

Original comment by guillaum...@parrot.com on 27 Nov 2014 at 12:54

GoogleCodeExporter commented 9 years ago
To bad, I reported the bug and it has been fixed, though, see 
https://www.cmake.org/Bug/view.php?id=14056&history=1.

Original comment by andreas....@gmail.com on 27 Nov 2014 at 1:10

GoogleCodeExporter commented 9 years ago
I.e. CMake 3.1 should be fine. Any chance you can quickly download and install 
the release candidate for this version and try again? Would be interesting to 
see if we then could not make use of the CMake modules included in the gflags 
project and get rid of them eventually (once CMake 3.1 is the minimum default 
on most systems).

Original comment by andreas....@gmail.com on 27 Nov 2014 at 1:13

GoogleCodeExporter commented 9 years ago
Okay, it looks like CheckTypeSize was fixed to support CXX only: 
http://www.cmake.org/Bug/view.php?id=14056

But in practice, it still doesn't work with my CMake version (3.0.2) which 
includes this change. Also IIUC, gflags fixed other modules than CheckTypeSize.

Original comment by guillaum...@parrot.com on 27 Nov 2014 at 1:17

GoogleCodeExporter commented 9 years ago
I saw your messages after I submitted one, looks like that was your bug that I 
found.

Anyway, I downloaded cmake 3.1 rc2 and the example from the bug report works 
now.

On the other hand compiling gflags still fails due to pthread which hasn't been 
fixed.

-- Looking for include file pthread.h
CMake Error at 
/home/gpapin/pkg/cmake-3.1.0-rc2-Linux-i386/share/cmake-3.1/Modules/CheckInclude
Files.cmake:74 (try_compile):
  Unknown extension ".c" for file

    /home/gpapin/pkg/gflags-2.1.1/build/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):
  /home/gpapin/pkg/cmake-3.1.0-rc2-Linux-i386/share/cmake-3.1/Modules/FindThreads.cmake:123 (CHECK_INCLUDE_FILES)
  CMakeLists.txt:157 (find_package)

Original comment by guillaum...@parrot.com on 27 Nov 2014 at 1:25

GoogleCodeExporter commented 9 years ago
I see, thanks for giving it a try. Maybe the safest option is then to just 
apply your patch and revert to C+CXX. Just wanted to avoid all the C compiler 
checks to speed up configuration.

Original comment by andreas....@gmail.com on 27 Nov 2014 at 4:05

GoogleCodeExporter commented 9 years ago
Yeah I understand the concern as I tried this myself once.

I think it's best to just enable C for now and maybe one day, when CMake 
supports CXX-only project more easily you will be able to call 
enable_language(C) only for CMake versions prior to this one.

Best,
Guillaume

Original comment by guillaum...@parrot.com on 27 Nov 2014 at 4:26