Commit Graph

49 Commits

Author SHA1 Message Date
Brad King a4596f2048 CheckTypeSize: Do not use cmake_policy(VERSION)
Do not force a specific policy version in the module because it prevents
projects from setting newer policies to NEW.  In particular, projects
may want to set CMP0056 to NEW to affect any try_compile calls in this
module.

Use of this was added in commit v2.8.2~539 (New CheckTypeSize for OS X
Universal Binaries, 2009-12-17) and updated in commit v3.1.0-rc1~511^2~1
(Do not change minimum required version in modules, 2014-05-07).  The
history does not clearly explain why a specific policy version was
introduced.  If specific policies need to be NEW then we can add
explicit settings for them.
2015-05-19 12:56:07 -04:00
Rolf Eike Beer 6784f0a6eb CheckTypeSize: Avoid if() auto-dereferene in quoted arguments (#15571)
Exposed by a CMP0054 warning.  Set CMP0054 to NEW since no code in this
module depends on the old behavior.
2015-05-19 12:47:24 -04:00
Sebastian Leske 908c74399a Help: Document that the CHECK_* macros create cache variables
Otherwise callers may expect to be able to re-use result variables.
2014-09-11 08:55:26 -04:00
Daniele E. Domenichelli 81a3f22882 Do not change minimum required version in modules
Some modules change CMake minimum required version when they are
included. For example:

  cmake_minimum_required(VERSION 2.8.12)
  message("${CMAKE_MINIMUM_REQUIRED_VERSION}")
  include(CheckTypeSize)
  message("${CMAKE_MINIMUM_REQUIRED_VERSION}")

will produce the following output:

  2.8.12
  2.6

This patch ensures that when you include a CMake module the minimum
required version and the policies set are left unchanged.

Fixes Issue #14864
2014-05-19 16:55:12 +02:00
Rolf Eike Beer 2622bc3f65 Clean up usage of if(... MATCHES regex) followed string(REGEX REPLACE regex)
The matches have already been calculated and can simply be taken from
CMAKE_MATCH_n variables. This avoids multiple compilations of the same or very
similar regular expressions.
2014-04-14 18:16:58 +02:00
Clinton Stimpson 4c0cc9ab91 Check*.cmake : Add CMAKE_REQUIRED_QUIET flag.
Setting this flag can silence messages from the Check*.cmake modules.
This can be used by Find*.cmake modules when they are in silent mode.
2014-03-29 20:14:23 -06:00
Daniele E. Domenichelli 7d6d45f23c CheckTypeSize: Support for CXX when C language is not enabled
This example now works without need to enable C language:

  cmake_minimum_required(VERSION x.x.x)
  project(foo CXX)
  include(CheckTypeSize)
  check_type_size("short" SIZEOF_SHORT LANGUAGE CXX)

Fixes #14056
2014-03-15 23:23:53 +01:00
Daniele E. Domenichelli 8252406cd6 CheckTypeSize: Unset temporary variables when done (#14690)
When the macro is invoked multiple times, the parsing variables were
not unset and therefore used for all the following calls.
2014-01-10 09:16:30 -05:00
Daniele E. Domenichelli 07a2342fbc CheckTypeSize: Add support for C++
Previously if headers required to check the size of a type can be
compiled with C++ compiler only, the check would fail because the C
compiler fails.  As a consequence, HAVE_${VARIABLE} would be set to
false, and ${VARIABLE} will be empty.

Teach CHECK_TYPE_SIZE to accept a new optional argument LANGUAGE
that allows one to explicitly set the compiler to use.  The new
signature is therefore:

   CHECK_TYPE_SIZE(TYPE VARIABLE [BUILTIN_TYPES_ONLY]
                                 [LANGUAGE <language>])
2013-10-21 16:39:04 +02:00
Kitware Robot f051814ed0 Convert builtin help to reStructuredText source files
Run the convert-help.bash script to convert documentation:

 ./convert-help.bash "/path/to/CMake-build/bin"

Then remove it.
2013-10-15 14:12:03 -04:00
Stephen Kelly 236133e79e Handle targets in the LINK_LIBRARIES of try_compile.
Imported targets are re-exported so that they can be used by the
try_compile generated code with target_link_libraries.

This makes the use of the cmake_expand_imported_targets macro
obsolete. The macro is not able to expand the generator expressions
which may appear in the IMPORTED_LINK_INTERFACE_LIBRARIES content.
Instead it just sees them as 'not a target'.
2013-02-22 08:35:39 -05:00
Rolf Eike Beer 48783b71fb CheckTypeSize: show in documentation how to get struct member size (#10579) 2012-08-14 21:14:33 +02:00
Kitware Robot 9db3116226 Remove CMake-language block-end command arguments
Ancient versions of CMake required else(), endif(), and similar block
termination commands to have arguments matching the command starting the
block.  This is no longer the preferred style.

Run the following shell code:

for c in else endif endforeach endfunction endmacro endwhile; do
    echo 's/\b'"$c"'\(\s*\)(.\+)/'"$c"'\1()/'
done >convert.sed &&
git ls-files -z -- bootstrap '*.cmake' '*.cmake.in' '*CMakeLists.txt' |
egrep -z -v '^(Utilities/cm|Source/kwsys/)' |
egrep -z -v 'Tests/CMakeTests/While-Endwhile-' |
xargs -0 sed -i -f convert.sed &&
rm convert.sed
2012-08-13 14:19:16 -04:00
Alex Neundorf 35c48e1270 Check*.cmake: Expand imported targets in CMAKE_REQUIRED_LIBRARIES
Add the function cmake_expand_imported_targets() to expand imported
targets in a list of libraries into their on-disk file names for a
particular configuration.  Adapt the implementation from KDE's
HANDLE_IMPORTED_TARGETS_IN_CMAKE_REQUIRED_LIBRARIES which has been in
use for over 2 years.  Call the function from all the Check*.cmake
macros to handle imported targets named in CMAKE_REQUIRED_LIBRARIES.

Alex
2012-02-21 15:38:15 -05:00
Todd Gamblin 2cde67a781 Modules: Fix spelling 'To distributed' -> 'To distribute' 2010-08-09 08:48:31 -04:00
Brad King c9b726c314 New CheckTypeSize for OS X Universal Binaries
We re-implement this module to support architecture-dependent type
sizes.  In the mixed-size case we generate C preprocessor code to select
the detected type size for each architecture.
2009-12-17 15:14:47 -05:00
Brad King 3a666595c9 Convert CMake non-find modules to BSD License
This adds copyright/license notification blocks CMake's non-find
modules.  Most of the modules had no notices at all.  Some had notices
referring to the BSD license already.  This commit normalizes existing
notices and adds missing notices.
2009-09-28 11:46:51 -04:00
Bill Hoffman 779a2abda3 ENH: allow users to turn off extra checks 2008-04-25 10:47:34 -04:00
Bill Hoffman 5f68965608 ENH: make sure all required headers are checked before checking type size 2008-04-25 09:09:06 -04:00
Alexander Neundorf 578841cce5 STYLE: remove unused CheckTypeSize.c.in
ENH: change test for endianess from TRY_RUN() to TRY_COMPILE() by testing
the binary image of a 16bit integer array, tested on Linux x86, Intel Mac
and Sun (big endian)

Alex
2007-08-10 13:14:00 -04:00
Alexander Neundorf b956fc2406 STYLE: remove out commented code
Alex
2007-06-07 13:51:17 -04:00
Alexander Neundorf 74750610cf ENH: determine typesize by compiling a file and reading strings from the compiled output.
Tested with various gcc, XCode, MSVC7, sdcc
For OSX when doing TRY_COMPILE() CMAKE_OSX_ARCHITECTURES is used, if there are different results an error is generated. CMAKE_OSX_ARCHITECTURES can be overwritten for the TRY_COMPILES with CMAKE_TRY_COMPILE_OSX_ARCHITECTURES.

Alex
2007-06-04 17:08:46 -04:00
Alexander Neundorf c9aecb91cc STYLE: remove debug output, fix indentation
the tests run again successfully, but since CheckTypeSize will switch to a
TRY_COMPILE soon I will look at it again after this change

Alex
2007-05-24 16:03:39 -04:00
Alexander Neundorf 504ea6df4e COMP: try to fix the test failures on dash2
Alex
2007-05-24 14:30:09 -04:00
Brad King 58debfd6bd ENH: Use IF(NOT DEFINED) check to short-circuit size test. 2007-05-17 15:17:45 -04:00
Alexander Neundorf 61d3444f93 ENH: merge CMake-CrossCompileBasic to HEAD
-add a RESULT_VARIABLE to INCLUDE()
-add CMAKE_TOOLCHAIN_FILE for specifiying your (potentially crosscompiling) toolchain
-have TRY_RUN() complain if you try to use it in crosscompiling mode (which were compiled but cannot run on this system)
-use CMAKE_EXECUTABLE_SUFFIX in TRY_RUN(), probably TRY_RUN won't be able to
run the executables if they have a different suffix because they are
probably crosscompiled, but nevertheless it should be able to find them
-make several cmake variables presettable by the user: CMAKE_C/CXX_COMPILER, CMAKE_C/CXX_OUTPUT_EXTENSION, CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_INFO_FILE
-support prefix for GNU toolchains (arm-elf-gcc, arm-elf-ar, arm-elf-strip etc.)
-move ranlib on OSX from the file command to a command in executed in cmake_install.cmake
-add support for stripping during install in cmake_install.cmake
-split out cl.cmake from Windows-cl.cmake, first (very incomplete) step to support MS crosscompiling tools
-remove stdio.h from the simple C program which checks if the compiler works, since this may not exist for some embedded platforms
-create a new CMakeFindBinUtils.cmake which collects the search fro ar, ranlib, strip, ld, link, install_name_tool and other tools like these
-add support for CMAKE_FIND_ROOT_PATH for all FIND_XXX commands, which is a
list of directories which will be prepended to all search directories, right
now as a cmake variable, turning it into a global cmake property may need
some more work
-remove cmTestTestHandler::TryExecutable(), it's unused
-split cmFileCommand::HandleInstall() into slightly smaller functions

Alex
2007-05-17 13:20:44 -04:00
Ken Martin 8e9a6beccc ENH: centralized locaiton of CMakeFiles setting 2006-06-14 12:28:32 -04:00
Brad King eeab2c55ed ENH: Added CMAKE_REQUIRED_DEFINITIONS and CMAKE_REQUIRED_INCLUDES to the interface. 2006-02-14 15:29:13 -05:00
Bill Hoffman 1eb57b6d08 ENH: fix check type size 2006-01-22 21:15:24 -05:00
Bill Hoffman 96f948adf5 ENH: fix checktypesize 2006-01-13 09:57:15 -05:00
Bill Hoffman 1d72bdea9a ENH: move define into configured file and do not use the command line 2006-01-12 23:08:33 -05:00
Ken Martin 4bdca3b404 ENH: put CmakeTmp into CMakeFiles 2006-01-12 13:49:32 -05:00
Ken Martin d2689c95a1 ENH: some style fixes for the book 2005-12-15 10:41:19 -05:00
Bill Hoffman b7fa820118 ENH: add documentation support for modules 2005-12-14 13:51:08 -05:00
Ken Martin c6b011e35e ENH: put cmake files intoa CMakeFiles subdir to clean up bin tree 2005-07-29 09:19:25 -04:00
Andy Cedilnik 518de19f74 ENH: Add option of adding random include files before doing CheckTypeSize 2004-10-05 08:33:08 -04:00
Andy Cedilnik 575afc8b14 ENH: support STDDEF and cleanup 2004-05-03 16:35:37 -04:00
Andy Cedilnik db12c17017 ENH: Documentation fix 2003-10-13 15:27:58 -04:00
Andy Cedilnik 8149dbed29 ENH: Cleanups and add missing CMakeOutput.log and CMakeError.log appending. Close Bug #136 - Verify that all modules that do try compile produce CMakeError.log and CMakeOutput.log 2003-08-08 11:59:07 -04:00
Andy Cedilnik d6ebc123f7 ENH: Extra new line after output 2003-07-17 14:55:45 -04:00
Andy Cedilnik a17587c244 ENH: Replace WRITE_FILE with FILE(WRITE and FILE(APPEND. Replace MAKE_DIRECTORY with FILE(MAKE_DIRECTORY, replace STRING(ASCII things 2003-07-11 14:14:03 -04:00
Brad King 98d10a42d3 BUG: Should test HAVE_<VARIABLE> before repeating test, not just whether <VARIABLE> is set. 2003-03-06 10:32:43 -05:00
Ken Martin dfa4cbd19e minor fix to backw compat 2003-01-09 11:34:45 -05:00
Andy Cedilnik cf81ec9a39 Remove debug 2003-01-03 20:26:20 -05:00
Andy Cedilnik 668b3f3cea Fix problems with required flags 2003-01-03 20:03:35 -05:00
Andy Cedilnik e720b84d6b Add required flags 2003-01-03 19:23:19 -05:00
Andy Cedilnik c8e546a353 To prevent cmake from breaking up arguments, put quotes around them 2003-01-01 16:25:26 -05:00
Andy Cedilnik 6d5c437045 Add a way to add custom libraries to the mix 2003-01-01 15:02:20 -05:00
Brad King ea1467d056 ENH: Renamed Modules/CheckSizeOf to Modules/CheckTypeSize for consistency with the macro name that is defined by the module. 2002-12-30 11:02:31 -05:00