source: git/modules/CheckCompiler.cmake @ fec53d

fieker-DuValspielwiese
Last change on this file since fec53d was 8cc501, checked in by Kai Krüger <krueger@…>, 14 years ago
Added files to compile with cmake. Still experimental. Might not work git-svn-id: file:///usr/local/Singular/svn/trunk@13240 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 3.1 KB
Line 
1# -*- mode: cmake; -*-
2#
3#  Figure out the version of the used compiler
4#  Variables set by this module
5#  CMAKE_CXX_COMPILER_MAJOR  major version of compiler
6#  CMAKE_CXX_COMPILER_MINR   minor version of compiler
7#  CMAKE_CXX_COMPILER_PATCH  patch level (e.g. gcc 4.1.0)
8#
9
10#execute_process(COMMAND <cmd1> [args1...]]
11#                  [COMMAND <cmd2> [args2...] [...]]
12#                  [WORKING_DIRECTORY <directory>]
13#                  [TIMEOUT <seconds>]
14#                  [RESULT_VARIABLE <variable>]
15#                  [OUTPUT_VARIABLE <variable>]
16#                  [ERROR_VARIABLE <variable>]
17#                  [INPUT_FILE <file>]
18#                  [OUTPUT_FILE <file>]
19#                  [ERROR_FILE <file>]
20#                  [OUTPUT_QUIET]
21#                  [ERROR_QUIET]
22#                  [OUTPUT_STRIP_TRAILING_WHITESPACE]
23#                  [ERROR_STRIP_TRAILING_WHITESPACE])
24
25# check the version of the compiler
26set(CMAKE_CXX_COMPILER_MAJOR "CMAKE_CXX_COMPILER_MAJOR-NOTFOUND")
27set(CMAKE_CXX_COMPILER_MINOR "CMAKE_CXX_COMPILER_MINOR-NOTFOUND")
28set(CMAKE_CXX_COMPILER_PATCH "CMAKE_CXX_COMPILER_PATCH-NOTFOUND")
29
30# extract the version of the compiler
31if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
32  execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
33      OUTPUT_VARIABLE CMAKE_CXX_COMPILER_VERSION)
34
35  string(REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1"
36         CMAKE_CXX_COMPILER_MAJOR ${CMAKE_CXX_COMPILER_VERSION})
37  string(REGEX REPLACE "^([0-9]+)\\.([0-9]+).*" "\\2"
38         CMAKE_CXX_COMPILER_MINOR ${CMAKE_CXX_COMPILER_VERSION})
39  set(CMAKE_CXX_COMPILER_PATCH "")
40endif( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
41
42if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
43  execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
44      OUTPUT_VARIABLE CMAKE_CXX_COMPILER_VERSION)
45
46  string(STRIP ${CMAKE_CXX_COMPILER_VERSION} CMAKE_CXX_COMPILER_VERSION)
47  string(REGEX REPLACE "^([0-9]+).*$" "\\1"
48         CMAKE_CXX_COMPILER_MAJOR ${CMAKE_CXX_COMPILER_VERSION})
49  string(REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\2"
50         CMAKE_CXX_COMPILER_MINOR ${CMAKE_CXX_COMPILER_VERSION})
51  string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+)$" "\\3"
52         CMAKE_CXX_COMPILER_PATCH ${CMAKE_CXX_COMPILER_VERSION})
53endif( ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
54
55
56# just print the results if requested
57function(info_compiler)
58  message(STATUS "CMAKE_FORCE_CXX_COMPILER  = '${CMAKE_FORCE_CXX_COMPILER}'")
59  message(STATUS "CMAKE_CXX_COMPILER        = '${CMAKE_CXX_COMPILER}'")
60  message(STATUS "CMAKE_CXX_COMPILER_ID     = '${CMAKE_CXX_COMPILER_ID}'")
61  message(STATUS "CMAKE_CXX_COMPILER_INIT   = '${CMAKE_CXX_COMPILER_INIT}'")
62  message(STATUS "CMAKE_GENERATOR_CXX       = '${CMAKE_GENERATOR_CXX}'")
63  message(STATUS "CMAKE_GNULD_IMAGE_VERSION = '${CMAKE_GNULD_IMAGE_VERSION}'")
64  message(STATUS "CMAKE_CXX_COMPILER_VERSION= '${CMAKE_CXX_COMPILER_VERSION}'")
65  message(STATUS "CMAKE_CXX_COMPILER_MAJOR  = '${CMAKE_CXX_COMPILER_MAJOR}'")
66  message(STATUS "CMAKE_CXX_COMPILER_MINOR  = '${CMAKE_CXX_COMPILER_MINOR}'")
67  message(STATUS "CMAKE_CXX_COMPILER_PATCH  = '${CMAKE_CXX_COMPILER_PATCH}'")
68endfunction(info_compiler)
Note: See TracBrowser for help on using the repository browser.