MantisBT - CMake
View Issue Details
0010579CMakeModulespublic2010-04-20 09:192013-01-09 14:05
Rolf Eike Beer 
Rolf Eike Beer 
normalfeaturehave not tried
closedfixed 
CMake-2-8 
CMake 2.8.10CMake 2.8.10 
0010579: CheckStructHasMember should also return the size of the type
For properly detecting e.g. large file support one should check if off_t is 64 bit and struct stat member st_size is 64 bit too. There is currently no easy way to do that so I suggest that CheckStructHasMember will additionally return the size of the member when it checks for it's presence.
No tags attached.
patch 0001-CheckTypeSize-show-in-documentation-how-to-get-struc.patch (1,022) 2012-08-13 13:02
https://public.kitware.com/Bug/file/4422/0001-CheckTypeSize-show-in-documentation-how-to-get-struc.patch
patch 0002-CheckTypeSize-add-a-test-for-size-of-struct-members.patch (4,258) 2012-08-13 13:29
https://public.kitware.com/Bug/file/4423/0002-CheckTypeSize-add-a-test-for-size-of-struct-members.patch
Issue History
2010-04-20 09:19Rolf Eike BeerNew Issue
2010-05-08 03:38Alex NeundorfCategoryCMake => Modules
2010-08-31 15:31David ColeStatusnew => assigned
2010-08-31 15:31David ColeAssigned To => Brad King
2010-08-31 15:33Brad KingNote Added: 0022032
2010-08-31 18:06David ColeTarget Version => CMake 2.8.3
2010-09-06 04:42Rolf Eike BeerNote Added: 0022094
2010-09-09 15:22Brad KingNote Added: 0022164
2010-09-14 09:17David ColeNote Added: 0022217
2010-09-14 09:17David ColeTarget VersionCMake 2.8.3 =>
2012-08-13 10:17Rolf Eike BeerNote Added: 0030472
2012-08-13 10:36Brad KingStatusassigned => backlog
2012-08-13 10:36Brad KingNote Added: 0030474
2012-08-13 13:01Rolf Eike BeerNote Added: 0030571
2012-08-13 13:01Rolf Eike BeerAssigned ToBrad King => Rolf Eike Beer
2012-08-13 13:01Rolf Eike BeerStatusbacklog => assigned
2012-08-13 13:01Rolf Eike BeerTarget Version => CMake 2.8.10
2012-08-13 13:02Rolf Eike BeerFile Added: 0001-CheckTypeSize-show-in-documentation-how-to-get-struc.patch
2012-08-13 13:29Rolf Eike BeerFile Added: 0002-CheckTypeSize-add-a-test-for-size-of-struct-members.patch
2012-08-21 02:34Rolf Eike BeerNote Added: 0030715
2012-08-21 02:34Rolf Eike BeerStatusassigned => resolved
2012-08-21 02:34Rolf Eike BeerResolutionopen => fixed
2012-08-21 02:34Rolf Eike BeerFixed in Version => CMake 2.8.10
2013-01-09 14:05Robert MaynardNote Added: 0032077
2013-01-09 14:05Robert MaynardStatusresolved => closed

Notes
(0022032)
Brad King   
2010-08-31 15:33   
Perhaps a new CheckSizeofStructMember would be better?
(0022094)
Rolf Eike Beer   
2010-09-06 04:42   
Whatever works ;) If it is an optional field of a struct I still would need to check if it exists first. Or this new check would simply return 0 then and not raise an error.

What I wanted to avoid is something like:

CHECK_STRUCT_HAS_MEMBER("struct timeval" tv_sec sys/select.h HAVE_TIMEVAL_TV_SEC)
IF (HAVE_TIMEVAL_TV_SEC)
  CheckSizeofStructMember("struct timeval" tv_sec sys/select.h TIMEVAL_TV_SEC_SIZE)
ELSE ()
  SET(TIMEVAL_TV_SEC_SIZE 0)
ENDIF ()

It would be nice if that would just be one single call at the end. Since CheckStructHasMember must do basically all the magic anyway (set headers, check if it compiles at all, ...) I thought it would be easier to just extend this one. But at the end I would welcome every working solution.
(0022164)
Brad King   
2010-09-09 15:22   
While investigating an implementation I realized that "CheckTypeSize" should actually be called "CheckExprSize". You can do this:

include(CheckTypeSize)
set(CMAKE_EXTRA_INCLUDE_FILES sys/stat.h)
check_type_size("((struct stat*)0)->st_mode" SIZEOF_MEMBER)
message("SIZEOF_MEMBER=[${SIZEOF_MEMBER}]")
message("SIZEOF_MEMBER_CODE=[${SIZEOF_MEMBER_CODE}]")

and it works even back in CMake 2.4. The size is zero or blank if the member does not exist.
(0022217)
David Cole   
2010-09-14 09:17   
We will not be addressing this for the upcoming CMake 2.8.3 release. Changing target release value back to empty for now.

Waiting for reply from reporter to note 22164.
(0030472)
Rolf Eike Beer   
2012-08-13 10:17   
From my POV we don't need a new macro since we can already do what I wanted. But that trick should be added to the documentation.
(0030474)
Brad King   
2012-08-13 10:36   
Sending issues I'm not actively working on to the backlog to await someone with time for them.

If an issue you care about is sent to the backlog when you feel it should have been addressed in a different manner, please bring it up on the CMake mailing list for discussion. Sign up for the mailing list here, if you're not already on it:

 http://www.cmake.org/mailman/listinfo/cmake [^]

It's easy to re-activate a bug here if you can find a CMake developer or contributor who has the bandwidth to take it on.
(0030571)
Rolf Eike Beer   
2012-08-13 13:01   
This patch should do it. Testcase to keep this stuff working will follow shortly.
(0030715)
Rolf Eike Beer   
2012-08-21 02:34   
Patches merged to next:

9926f68 CheckTypeSize: add a test for size of struct members
2d68b03 CheckTypeSize: show in documentation how to get struct member size (0010579)
(0032077)
Robert Maynard   
2013-01-09 14:05   
Closing resolved issues that have not been updated in more than 4 months.