MantisBT - CMake
View Issue Details
0014056CMakeModulespublic2013-04-02 10:472014-10-06 10:32
Daniele E. Domenichelli 
Daniele E. Domenichelli 
normalminoralways
closedfixed 
CMake 2.8.10.2 
CMake 3.1CMake 3.1 
0014056: CheckTypeSize does not work if C language is not enabled
If C language is not enabled, it is impossible to use the CheckTypeSize module.
This is a minimal CMakeLists.txt to show the issue:

---

cmake_minimum_required(VERSION 2.6.4)
project(test_prj CXX)
include(CheckTypeSize)
check_type_size("short" SIZEOF_SHORT)
Output:

---

-- Check size of short
CMake Error at /usr/share/cmake-2.8/Modules/CheckTypeSize.cmake:89 (try_compile):
  Unknown extension ".c" for file

    /opt/iit/build/testxx/CMakeFiles/CheckTypeSize/SIZEOF_SHORT.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):
  /usr/share/cmake-2.8/Modules/CheckTypeSize.cmake:174 (__check_type_size_impl)
  CMakeLists.txt:6 (check_type_size)


-- Configuring incomplete, errors occurred!
No tags attached.
Issue History
2013-04-02 10:47Daniele E. DomenichelliNew Issue
2014-03-15 10:03Andreas SchuhNote Added: 0035413
2014-03-17 09:16Brad KingAssigned To => Daniele E. Domenichelli
2014-03-17 09:16Brad KingStatusnew => assigned
2014-03-17 12:39Daniele E. DomenichelliNote Added: 0035423
2014-03-18 12:00Andreas SchuhNote Added: 0035431
2014-03-20 09:11Brad KingNote Added: 0035451
2014-03-20 09:11Brad KingStatusassigned => resolved
2014-03-20 09:11Brad KingResolutionopen => fixed
2014-03-20 09:11Brad KingFixed in Version => CMake 3.1
2014-03-20 09:11Brad KingTarget Version => CMake 3.1
2014-10-06 10:32Robert MaynardNote Added: 0036946
2014-10-06 10:32Robert MaynardStatusresolved => closed

Notes
(0035413)
Andreas Schuh   
2014-03-15 10:03   
I noticed that the current CMake Git master branch (SHA 34a49dea) contains a modified CheckTypeSize.cmake module which accepts a language argument. However, this module still causes an error when used for CXX only because it tries to check the available system headers using check_include_file instead of check_include_file_cxx.
(0035423)
Daniele E. Domenichelli   
2014-03-17 12:39   
Pushed to next:

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7d6d45f2 [^]

Unit test:

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7f857775 [^]
(0035431)
Andreas Schuh   
2014-03-18 12:00   
I encountered another problem with the latest CheckTypeSize.cmake module (SHA 34a49dea). It states the minimum required CMake version is 2.6. However, it passes the LINK_LIBRARIES on to try_compile. This option is supported by this command only since version 2.8.11 of CMake. Either the module needs to require this later version of CMake explicitly or ignore the LINK_LIBRARIES (possibly with a warning).
(0035451)
Brad King   
2014-03-20 09:11   
Re 0014056:0035431: Since the module comes with CMake we know it is running in a new enough version. That cmake_minimum_required call is there to set policies to match what the module expects. I suspect it can be updated or removed but that is a separate issue.
(0036946)
Robert Maynard   
2014-10-06 10:32   
Closing resolved issues that have not been updated in more than 4 months.