Scripts/Compiler.cmake

Fri, 23 Sep 2016 10:58:29 +0300

author
cemkalyoncu
date
Fri, 23 Sep 2016 10:58:29 +0300
branch
4.x-dev
changeset 953
bb20866ecc63
parent 870
427acef8d34a
child 1005
cfd2060d8e8e
permissions
-rw-r--r--

* Window function for X11 (Resizing has a bug both in DWM and X11)

415
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
1 cmake_minimum_required(VERSION 2.8)
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
2
418
dcdaafd460d7 * Testing framework finished
cemkalyoncu
parents: 416
diff changeset
3 OPTION(IGNORE_COMPILER_VERSION "Ignore compiler version check" OFF)
dcdaafd460d7 * Testing framework finished
cemkalyoncu
parents: 416
diff changeset
4 OPTION(IGNORE_COMPILER_VENDOR "Ignore compiler vendor check" OFF)
dcdaafd460d7 * Testing framework finished
cemkalyoncu
parents: 416
diff changeset
5
415
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
6 #compiler check
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
7 IF(CMAKE_COMPILER_IS_GNUCXX)
416
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents: 415
diff changeset
8 EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents: 415
diff changeset
9
415
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
10 IF(GCC_VERSION VERSION_LESS 4.8)
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
11 IF(IGNORE_COMPILER_VERSION)
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
12 MESSAGE(STATUS "Gorgon Library requires GCC 4.8+")
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
13 ELSE()
418
dcdaafd460d7 * Testing framework finished
cemkalyoncu
parents: 416
diff changeset
14 MESSAGE(STATUS "use cmake -DIGNORE_COMPILER_VERSION=ON to continue anyway")
415
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
15 MESSAGE(FATAL_ERROR "Gorgon Library requires GCC 4.8+")
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
16 ENDIF()
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
17 ENDIF()
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
18 ELSEIF(MSVC)
714
fd31361b7814 * Visual Studio 2015 build
cemkalyoncu
parents: 618
diff changeset
19 IF(MSVC_VERSION VERSION_LESS 14)
415
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
20 IF(IGNORE_COMPILER_VERSION)
714
fd31361b7814 * Visual Studio 2015 build
cemkalyoncu
parents: 618
diff changeset
21 MESSAGE(STATUS "Gorgon Library requires Visual Studio 2015+")
415
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
22 ELSE()
418
dcdaafd460d7 * Testing framework finished
cemkalyoncu
parents: 416
diff changeset
23 MESSAGE(STATUS "use cmake -DIGNORE_COMPILER_VERSION=ON to continue anyway")
714
fd31361b7814 * Visual Studio 2015 build
cemkalyoncu
parents: 618
diff changeset
24 MESSAGE(FATAL_ERROR "Gorgon Library requires Visual Studio 2015+")
415
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
25 ENDIF()
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
26 ENDIF()
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
27 ELSE()
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
28 IF(IGNORE_COMPILER_VENDOR)
714
fd31361b7814 * Visual Studio 2015 build
cemkalyoncu
parents: 618
diff changeset
29 MESSAGE(STATUS "Unsupported compiler! Gorgon Library requires GCC 4.8+ OR Visual Studio 2015+")
953
bb20866ecc63 * Window function for X11 (Resizing has a bug both in DWM and X11)
cemkalyoncu
parents: 870
diff changeset
30 MESSAGE(STATUS "You may need to manually activate C++14 features")
415
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
31 ELSE()
418
dcdaafd460d7 * Testing framework finished
cemkalyoncu
parents: 416
diff changeset
32 MESSAGE(STATUS "use cmake -DIGNORE_COMPILER_VENDOR=ON to continue anyway")
714
fd31361b7814 * Visual Studio 2015 build
cemkalyoncu
parents: 618
diff changeset
33 MESSAGE(FATAL_ERROR "Unsupported compiler! Gorgon Library requires GCC 4.8+ OR Visual Studio 2015+")
415
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
34 ENDIF()
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
35 ENDIF()
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
36
568
776f8dd57c04 * Partial support for reference counting for reference types
cemkalyoncu
parents: 439
diff changeset
37 OPTION(ENABLE_64_BIT "Enable 64 bit compilation" OFF)
776f8dd57c04 * Partial support for reference counting for reference types
cemkalyoncu
parents: 439
diff changeset
38
953
bb20866ecc63 * Window function for X11 (Resizing has a bug both in DWM and X11)
cemkalyoncu
parents: 870
diff changeset
39 #enable C++14 and 32-bit compilation
415
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
40 INCLUDE(CheckCXXCompilerFlag)
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
41 IF(CMAKE_COMPILER_IS_GNUCXX)
568
776f8dd57c04 * Partial support for reference counting for reference types
cemkalyoncu
parents: 439
diff changeset
42 IF(${ENABLE_64_BIT})
953
bb20866ecc63 * Window function for X11 (Resizing has a bug both in DWM and X11)
cemkalyoncu
parents: 870
diff changeset
43 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
568
776f8dd57c04 * Partial support for reference counting for reference types
cemkalyoncu
parents: 439
diff changeset
44 ELSE()
953
bb20866ecc63 * Window function for X11 (Resizing has a bug both in DWM and X11)
cemkalyoncu
parents: 870
diff changeset
45 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -m32")
568
776f8dd57c04 * Partial support for reference counting for reference types
cemkalyoncu
parents: 439
diff changeset
46 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
776f8dd57c04 * Partial support for reference counting for reference types
cemkalyoncu
parents: 439
diff changeset
47 ENDIF()
415
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
48 ENDIF()
416
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents: 415
diff changeset
49
815
c0466d54ffb6 * Partial WASAPI support
cemkalyoncu
parents: 758
diff changeset
50 IF(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
584
5bfe659d0b59 * Reference type proper errors
cemkalyoncu
parents: 568
diff changeset
51 IF(${ENABLE_64_BIT})
953
bb20866ecc63 * Window function for X11 (Resizing has a bug both in DWM and X11)
cemkalyoncu
parents: 870
diff changeset
52 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
584
5bfe659d0b59 * Reference type proper errors
cemkalyoncu
parents: 568
diff changeset
53 ELSE()
953
bb20866ecc63 * Window function for X11 (Resizing has a bug both in DWM and X11)
cemkalyoncu
parents: 870
diff changeset
54 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -m32")
584
5bfe659d0b59 * Reference type proper errors
cemkalyoncu
parents: 568
diff changeset
55 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
5bfe659d0b59 * Reference type proper errors
cemkalyoncu
parents: 568
diff changeset
56 ENDIF()
5bfe659d0b59 * Reference type proper errors
cemkalyoncu
parents: 568
diff changeset
57 ENDIF()
5bfe659d0b59 * Reference type proper errors
cemkalyoncu
parents: 568
diff changeset
58
618
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
59 #MACRO(FixProject)
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
60 #ENDMACRO()
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
61
416
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents: 415
diff changeset
62 #make sure 64bits cannot be activated
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents: 415
diff changeset
63 IF(MSVC)
435
79cb74c6e90a * Size is reorganized
cemkalyoncu
parents: 421
diff changeset
64 ADD_DEFINITIONS(-D_SBCS -D_CRT_SECURE_NO_WARNINGS)
618
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
65
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
66 SET(configs
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
67 CMAKE_C_FLAGS_DEBUG
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
68 CMAKE_C_FLAGS_MINSIZEREL
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
69 CMAKE_C_FLAGS_RELEASE
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
70 CMAKE_C_FLAGS_RELWITHDEBINFO
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
71 CMAKE_CXX_FLAGS_DEBUG
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
72 CMAKE_CXX_FLAGS_MINSIZEREL
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
73 CMAKE_CXX_FLAGS_RELEASE
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
74 CMAKE_CXX_FLAGS_RELWITHDEBINFO
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
75 )
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
76
870
427acef8d34a * FLAC encoding and decoding support
cemkalyoncu
parents: 815
diff changeset
77
427acef8d34a * FLAC encoding and decoding support
cemkalyoncu
parents: 815
diff changeset
78 add_definitions( "/D_CRT_SECURE_NO_WARNINGS /wd4068" )
427acef8d34a * FLAC encoding and decoding support
cemkalyoncu
parents: 815
diff changeset
79
618
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
80 FOREACH(config ${configs})
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
81 IF(${config} MATCHES "/MD")
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
82 STRING(REGEX REPLACE "/MD" "/MT" ${config} "${${config}}")
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
83 ENDIF()
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
84 ENDFOREACH()
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
85
568
776f8dd57c04 * Partial support for reference counting for reference types
cemkalyoncu
parents: 439
diff changeset
86 IF(${CMAKE_CL_64} AND NOT(${ENABLE_64_BIT}))
416
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents: 415
diff changeset
87 MESSAGE(FATAL_ERROR "Gorgon Library works only 32bits")
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents: 415
diff changeset
88 ENDIF()
418
dcdaafd460d7 * Testing framework finished
cemkalyoncu
parents: 416
diff changeset
89 ENDIF()

mercurial