Scripts/Compiler.cmake

Sun, 18 Mar 2018 16:25:06 +0200

author
cemkalyoncu
date
Sun, 18 Mar 2018 16:25:06 +0200
branch
4.x-dev
changeset 1123
7d4ba778fdee
parent 1060
73b643fcb15b
child 1126
e8f77f6340bf
permissions
-rw-r--r--

* 64 bit build is now default
* New FORCE_32_BIT option
* Some 64 bit issues are fixed
* ptrtest.gor is now supplied

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
1005
cfd2060d8e8e * Rectangle now have separate tiling flags
cemkalyoncu
parents: 953
diff changeset
6 set(CMAKE_CXX_STANDARD 14)
cfd2060d8e8e * Rectangle now have separate tiling flags
cemkalyoncu
parents: 953
diff changeset
7
415
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
8 #compiler check
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
9 IF(CMAKE_COMPILER_IS_GNUCXX)
416
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents: 415
diff changeset
10 EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents: 415
diff changeset
11
415
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
12 IF(GCC_VERSION VERSION_LESS 4.8)
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
13 IF(IGNORE_COMPILER_VERSION)
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
14 MESSAGE(STATUS "Gorgon Library requires GCC 4.8+")
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
15 ELSE()
418
dcdaafd460d7 * Testing framework finished
cemkalyoncu
parents: 416
diff changeset
16 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
17 MESSAGE(FATAL_ERROR "Gorgon Library requires GCC 4.8+")
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
18 ENDIF()
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
19 ENDIF()
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
20 ELSEIF(MSVC)
714
fd31361b7814 * Visual Studio 2015 build
cemkalyoncu
parents: 618
diff changeset
21 IF(MSVC_VERSION VERSION_LESS 14)
415
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
22 IF(IGNORE_COMPILER_VERSION)
714
fd31361b7814 * Visual Studio 2015 build
cemkalyoncu
parents: 618
diff changeset
23 MESSAGE(STATUS "Gorgon Library requires Visual Studio 2015+")
415
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
24 ELSE()
418
dcdaafd460d7 * Testing framework finished
cemkalyoncu
parents: 416
diff changeset
25 MESSAGE(STATUS "use cmake -DIGNORE_COMPILER_VERSION=ON to continue anyway")
714
fd31361b7814 * Visual Studio 2015 build
cemkalyoncu
parents: 618
diff changeset
26 MESSAGE(FATAL_ERROR "Gorgon Library requires Visual Studio 2015+")
415
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
27 ENDIF()
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
28 ENDIF()
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
29 ELSE()
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
30 IF(IGNORE_COMPILER_VENDOR)
714
fd31361b7814 * Visual Studio 2015 build
cemkalyoncu
parents: 618
diff changeset
31 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
32 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
33 ELSE()
418
dcdaafd460d7 * Testing framework finished
cemkalyoncu
parents: 416
diff changeset
34 MESSAGE(STATUS "use cmake -DIGNORE_COMPILER_VENDOR=ON to continue anyway")
714
fd31361b7814 * Visual Studio 2015 build
cemkalyoncu
parents: 618
diff changeset
35 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
36 ENDIF()
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
37 ENDIF()
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
38
568
776f8dd57c04 * Partial support for reference counting for reference types
cemkalyoncu
parents: 439
diff changeset
39
953
bb20866ecc63 * Window function for X11 (Resizing has a bug both in DWM and X11)
cemkalyoncu
parents: 870
diff changeset
40 #enable C++14 and 32-bit compilation
415
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
41 INCLUDE(CheckCXXCompilerFlag)
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
42 IF(CMAKE_COMPILER_IS_GNUCXX)
1123
7d4ba778fdee * 64 bit build is now default
cemkalyoncu
parents: 1060
diff changeset
43 IF(${FORCE_32_BIT})
953
bb20866ecc63 * Window function for X11 (Resizing has a bug both in DWM and X11)
cemkalyoncu
parents: 870
diff changeset
44 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
45 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
1123
7d4ba778fdee * 64 bit build is now default
cemkalyoncu
parents: 1060
diff changeset
46 ELSE()
7d4ba778fdee * 64 bit build is now default
cemkalyoncu
parents: 1060
diff changeset
47 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
48 ENDIF()
415
001cd0eb15db * CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
diff changeset
49 ENDIF()
416
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents: 415
diff changeset
50
815
c0466d54ffb6 * Partial WASAPI support
cemkalyoncu
parents: 758
diff changeset
51 IF(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
1123
7d4ba778fdee * 64 bit build is now default
cemkalyoncu
parents: 1060
diff changeset
52 IF(${FORCE_32_BIT})
953
bb20866ecc63 * Window function for X11 (Resizing has a bug both in DWM and X11)
cemkalyoncu
parents: 870
diff changeset
53 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -m32")
584
5bfe659d0b59 * Reference type proper errors
cemkalyoncu
parents: 568
diff changeset
54 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
1123
7d4ba778fdee * 64 bit build is now default
cemkalyoncu
parents: 1060
diff changeset
55 ELSE()
7d4ba778fdee * 64 bit build is now default
cemkalyoncu
parents: 1060
diff changeset
56 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
584
5bfe659d0b59 * Reference type proper errors
cemkalyoncu
parents: 568
diff changeset
57 ENDIF()
5bfe659d0b59 * Reference type proper errors
cemkalyoncu
parents: 568
diff changeset
58 ENDIF()
5bfe659d0b59 * Reference type proper errors
cemkalyoncu
parents: 568
diff changeset
59
618
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
60 #MACRO(FixProject)
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
61 #ENDMACRO()
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
62
416
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents: 415
diff changeset
63 IF(MSVC)
1060
73b643fcb15b * Fixed several configuration problems
cemkalyoncu
parents: 1005
diff changeset
64 ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
73b643fcb15b * Fixed several configuration problems
cemkalyoncu
parents: 1005
diff changeset
65
73b643fcb15b * Fixed several configuration problems
cemkalyoncu
parents: 1005
diff changeset
66 ADD_DEFINITIONS(-DUNICODE)
73b643fcb15b * Fixed several configuration problems
cemkalyoncu
parents: 1005
diff changeset
67 ADD_DEFINITIONS(-D_UNICODE)
618
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
68
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
69 SET(configs
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
70 CMAKE_C_FLAGS_DEBUG
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
71 CMAKE_C_FLAGS_MINSIZEREL
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
72 CMAKE_C_FLAGS_RELEASE
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
73 CMAKE_C_FLAGS_RELWITHDEBINFO
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
74 CMAKE_CXX_FLAGS_DEBUG
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
75 CMAKE_CXX_FLAGS_MINSIZEREL
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
76 CMAKE_CXX_FLAGS_RELEASE
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
77 CMAKE_CXX_FLAGS_RELWITHDEBINFO
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
78 )
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
79
870
427acef8d34a * FLAC encoding and decoding support
cemkalyoncu
parents: 815
diff changeset
80
427acef8d34a * FLAC encoding and decoding support
cemkalyoncu
parents: 815
diff changeset
81 add_definitions( "/D_CRT_SECURE_NO_WARNINGS /wd4068" )
427acef8d34a * FLAC encoding and decoding support
cemkalyoncu
parents: 815
diff changeset
82
618
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
83 FOREACH(config ${configs})
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
84 IF(${config} MATCHES "/MD")
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
85 STRING(REGEX REPLACE "/MD" "/MT" ${config} "${${config}}")
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
86 ENDIF()
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
87 ENDFOREACH()
9fa41184c08a * Start and open for Win32
cemkalyoncu
parents: 584
diff changeset
88
1123
7d4ba778fdee * 64 bit build is now default
cemkalyoncu
parents: 1060
diff changeset
89 IF(${CMAKE_CL_64} AND ${FORCE_32_BIT})
7d4ba778fdee * 64 bit build is now default
cemkalyoncu
parents: 1060
diff changeset
90 MESSAGE(FATAL_ERROR "Gorgon Library is configured for 32 bits.")
416
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents: 415
diff changeset
91 ENDIF()
418
dcdaafd460d7 * Testing framework finished
cemkalyoncu
parents: 416
diff changeset
92 ENDIF()

mercurial