root/OpenSceneGraph/trunk/CMakeModules/OsgDetermineCompiler.cmake @ 9952

Revision 9528, 3.1 kB (checked in by robert, 9 years ago)

From Mattias Helsing, "got some feedback from J-S on the packaging so I have changed the
name of the top folder in each package to OpenSceneGraph-x.y.z

Noone else has had an opinion on whether compiler and it's version
should be part of the package filename on their platform/setup so I'll
leave it as is. That is - No action is taken for compilers other than
msvc but one can easily add this information to the cmake cache
regardless of platform.
"

Line 
1# - Figure out what compiler (and version) cmake is generating for
2# Once done this will define:
3#
4# Variable:
5#   OSG_COMPILER
6#
7
8IF(CMAKE_COMPILER_IS_GNUCXX)
9
10    EXEC_PROGRAM(
11        ${CMAKE_CXX_COMPILER} 
12        ARGS     ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
13        OUTPUT_VARIABLE gcc_compiler_version
14    )
15    #MESSAGE("GCC Version: ${gcc_compiler_version}")
16
17ELSE(CMAKE_COMPILER_IS_GNUCXX)
18    IF(MSVC)
19        IF(MSVC60)
20            SET(OSG_COMPILER "vc60")
21        ENDIF(MSVC60)
22        IF(MSVC70)
23            SET(OSG_COMPILER "vc70")
24        ENDIF(MSVC70)
25        IF(MSVC71)
26            SET(OSG_COMPILER "vc71")
27        ENDIF(MSVC71)
28        IF(MSVC80)
29            SET(OSG_COMPILER "vc80")
30        ENDIF(MSVC80)
31        IF(MSVC90)
32            SET(OSG_COMPILER "vc90")
33        ENDIF(MSVC90)
34
35        IF(MSVC80)
36            MESSAGE(STATUS "Checking if compiler has service pack 1 installed...")
37            FILE(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx" "int main() {return 0;}\n")
38
39            TRY_COMPILE(_TRY_RESULT
40              ${CMAKE_BINARY_DIR}
41              ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx
42              CMAKE_FLAGS -D CMAKE_VERBOSE_MAKEFILE=ON
43              OUTPUT_VARIABLE OUTPUT
44            )
45
46            IF(_TRY_RESULT)
47                # parse for exact compiler version
48                STRING(REGEX MATCH "Compiler Version [0-9]+.[0-9]+.[0-9]+.[0-9]+" vc_compiler_version "${OUTPUT}")
49                IF(vc_compiler_version)
50                    #MESSAGE("${vc_compiler_version}")
51                    STRING(REGEX MATCHALL "[0-9]+" CL_VERSION_LIST "${vc_compiler_version}")
52                    LIST(GET CL_VERSION_LIST 0 CL_MAJOR_VERSION)
53                    LIST(GET CL_VERSION_LIST 1 CL_MINOR_VERSION)
54                    LIST(GET CL_VERSION_LIST 2 CL_PATCH_VERSION)
55                    LIST(GET CL_VERSION_LIST 3 CL_EXTRA_VERSION)
56                ENDIF(vc_compiler_version)
57
58                # Standard vc80 is 14.00.50727.42, sp1 14.00.50727.762, sp2?
59                # Standard vc90 is 9.0.30729.1, sp1 ?
60                IF(CL_EXTRA_VERSION EQUAL 762)
61                    SET(OSG_COMPILER "vc80sp1")
62                ELSE(CL_EXTRA_VERSION EQUAL 762)
63                    SET(OSG_COMPILER "vc80")
64                ENDIF(CL_EXTRA_VERSION EQUAL 762)
65
66                # parse for exact visual studio version
67                #IF(MSVC_IDE)
68                # string(REGEX MATCH "Visual Studio Version [0-9]+.[0-9]+.[0-9]+.[0-9]+" vs_version "${OUTPUT}")
69                # IF(vs_version)
70                    # MESSAGE("${vs_version}")
71                    # string(REGEX MATCHALL "[0-9]+" VS_VERSION_LIST "${vs_version}")
72                    # list(GET VS_VERSION_LIST 0 VS_MAJOR_VERSION)
73                    # list(GET VS_VERSION_LIST 1 VS_MINOR_VERSION)
74                    # list(GET VS_VERSION_LIST 2 VS_PATCH_VERSION)
75                    # list(GET VS_VERSION_LIST 3 VS_EXTRA_VERSION)
76                # ENDIF(vs_version)
77                #ENDIF(MSVC_IDE)
78            ENDIF(_TRY_RESULT)
79        ENDIF(MSVC80)
80    ENDIF(MSVC)
81ENDIF(CMAKE_COMPILER_IS_GNUCXX)
Note: See TracBrowser for help on using the browser.