~ubuntu-branches/ubuntu/jaunty/cmake/jaunty-security

« back to all changes in this revision

Viewing changes to Modules/CMakeDetermineCXXCompiler.cmake

  • Committer: Bazaar Package Importer
  • Author(s): A. Maitland Bottoms
  • Date: 2005-03-02 09:22:44 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050302092244-y6o9j8wr27vqcqvx
Tags: 2.0.5-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# determine the compiler to use for C++ programs
 
2
# NOTE, a generator may set CMAKE_CXX_COMPILER before
 
3
# loading this file to force a compiler.
 
4
# use environment variable CXX first if defined by user, next use 
 
5
# the cmake variable CMAKE_GENERATOR_CXX which can be defined by a generator
 
6
# as a default compiler
 
7
 
 
8
IF(NOT CMAKE_CXX_COMPILER)
 
9
  SET(CMAKE_CXX_COMPILER_INIT NOTFOUND)
 
10
 
 
11
  # prefer the environment variable CXX
 
12
  IF($ENV{CXX} MATCHES ".+")
 
13
    GET_FILENAME_COMPONENT(CMAKE_CXX_COMPILER_INIT $ENV{CXX} PROGRAM PROGRAM_ARGS CMAKE_CXX_FLAGS_ENV_INIT)
 
14
    IF(EXISTS ${CMAKE_CXX_COMPILER_INIT})
 
15
    ELSE(EXISTS ${CMAKE_CXX_COMPILER_INIT})
 
16
      MESSAGE(FATAL_ERROR "Could not find compiler set in environment variable CXX:\n$ENV{CXX}.\n${CMAKE_CXX_COMPILER_INIT}")
 
17
    ENDIF(EXISTS ${CMAKE_CXX_COMPILER_INIT})
 
18
  ENDIF($ENV{CXX} MATCHES ".+")
 
19
 
 
20
  # next prefer the generator specified compiler
 
21
  IF(CMAKE_GENERATOR_CXX)
 
22
    IF(NOT CMAKE_CXX_COMPILER_INIT)
 
23
      SET(CMAKE_CXX_COMPILER_INIT ${CMAKE_GENERATOR_CXX})
 
24
    ENDIF(NOT CMAKE_CXX_COMPILER_INIT)
 
25
  ENDIF(CMAKE_GENERATOR_CXX)
 
26
 
 
27
  # if no compiler has been found yet, then try to find one
 
28
  IF(NOT CMAKE_CXX_COMPILER_INIT)
 
29
  # if not in the envionment then search for the compiler in the path
 
30
    SET(CMAKE_CXX_COMPILER_LIST c++ g++ CC aCC cl bcc xlC)
 
31
    FIND_PROGRAM(CMAKE_CXX_COMPILER_FULLPATH NAMES ${CMAKE_CXX_COMPILER_LIST})
 
32
    GET_FILENAME_COMPONENT(CMAKE_CXX_COMPILER_INIT
 
33
                           ${CMAKE_CXX_COMPILER_FULLPATH} NAME)
 
34
    SET(CMAKE_CXX_COMPILER_FULLPATH "${CMAKE_CXX_COMPILER_FULLPATH}" CACHE INTERNAL "full path to the compiler cmake found")
 
35
  ENDIF(NOT CMAKE_CXX_COMPILER_INIT)
 
36
  SET(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER_INIT} 
 
37
      CACHE STRING "C++ compiler") 
 
38
ENDIF(NOT CMAKE_CXX_COMPILER)
 
39
MARK_AS_ADVANCED(CMAKE_CXX_COMPILER)
 
40
 
 
41
IF(NOT CMAKE_COMPILER_IS_GNUCXX_RUN)
 
42
  # test to see if the cxx compiler is gnu
 
43
  SET(CMAKE_COMPILER_IS_GNUCXX_RUN 1)
 
44
  EXEC_PROGRAM(${CMAKE_CXX_COMPILER} ARGS -E "\"${CMAKE_ROOT}/Modules/CMakeTestGNU.c\"" OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT RETURN_VALUE CMAKE_COMPILER_RETURN)
 
45
  IF(NOT CMAKE_COMPILER_RETURN)
 
46
    IF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_GNU.*" )
 
47
      SET(CMAKE_COMPILER_IS_GNUCXX 1)
 
48
      FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeOutput.log
 
49
        "Determining if the C++ compiler is GNU succeeded with "
 
50
        "the following output:\n${CMAKE_COMPILER_OUTPUT}\n\n")
 
51
    ELSE("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_GNU.*" )
 
52
      FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeOutput.log
 
53
        "Determining if the C++ compiler is GNU failed with "
 
54
        "the following output:\n${CMAKE_COMPILER_OUTPUT}\n\n")
 
55
    ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_GNU.*" )
 
56
  ENDIF(NOT CMAKE_COMPILER_RETURN)
 
57
ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX_RUN)
 
58
 
 
59
# configure all variables set in this file
 
60
CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeCXXCompiler.cmake.in 
 
61
               ${CMAKE_BINARY_DIR}/CMakeCXXCompiler.cmake IMMEDIATE)
 
62
 
 
63
 
 
64
   
 
65