Scripts/GorgonConfig.cmake.in

Sat, 27 Nov 2021 15:02:03 +0100

author
cengizkandemir
date
Sat, 27 Nov 2021 15:02:03 +0100
branch
4.x-dev
changeset 1764
e47116c2f9a3
parent 1625
f1512f7188c2
permissions
-rw-r--r--

Include gorgon dirs to the target as system to avoid compilation issues

1149
ac1be49ebc11 * Hello World example project
cemkalyoncu
parents: 1124
diff changeset
1 # - Config file for the Gorgon package
814
8d275aa2f4cb * CMake packaging
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff changeset
2 # It defines the following variables
1149
ac1be49ebc11 * Hello World example project
cemkalyoncu
parents: 1124
diff changeset
3 # GORGON_INCLUDE_DIRS - include directories for Gorgon Library
814
8d275aa2f4cb * CMake packaging
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff changeset
4 # GORGON_LIBRARIES - libraries to link against
8d275aa2f4cb * CMake packaging
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff changeset
5
8d275aa2f4cb * CMake packaging
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff changeset
6 include("${CMAKE_CURRENT_LIST_DIR}/GorgonTargets.cmake")
8d275aa2f4cb * CMake packaging
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff changeset
7
8d275aa2f4cb * CMake packaging
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff changeset
8 # Compute paths
8d275aa2f4cb * CMake packaging
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff changeset
9 get_filename_component(GORGON_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
8d275aa2f4cb * CMake packaging
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff changeset
10 set(GORGON_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@")
1149
ac1be49ebc11 * Hello World example project
cemkalyoncu
parents: 1124
diff changeset
11
814
8d275aa2f4cb * CMake packaging
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff changeset
12 # These are IMPORTED targets created by GorgonTargets.cmake
8d275aa2f4cb * CMake packaging
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff changeset
13 set(GORGON_LIBRARIES Gorgon)
8d275aa2f4cb * CMake packaging
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff changeset
14 set(GORGON_EXECUTABLE )
830
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
15
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
16 MACRO(compilersetup)
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
17
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
18 if(UNIX)
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
19 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLINUX -Werror=return-type")
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
20 else()
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
21 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4800")
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
22 endif()
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
23
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
24 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGLM_SWIZZLE -DGLM_FORCE_RADIANS")
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
25
1149
ac1be49ebc11 * Hello World example project
cemkalyoncu
parents: 1124
diff changeset
26 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOPENGL @ADDITIONAL_CLIENT_FLAGS@")
830
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
27
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
28 #compiler check
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
29 IF(CMAKE_COMPILER_IS_GNUCXX)
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
30 EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
31
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
32 IF(GCC_VERSION VERSION_LESS 4.8)
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
33 IF(IGNORE_COMPILER_VERSION)
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
34 MESSAGE(STATUS "Gorgon Library requires GCC 4.8+")
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
35 ELSE()
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
36 MESSAGE(STATUS "use cmake -DIGNORE_COMPILER_VERSION=ON to continue anyway")
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
37 MESSAGE(FATAL_ERROR "Gorgon Library requires GCC 4.8+")
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
38 ENDIF()
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
39 ENDIF()
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
40 ELSEIF(MSVC)
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
41 IF(MSVC_VERSION VERSION_LESS 14)
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
42 IF(IGNORE_COMPILER_VERSION)
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
43 MESSAGE(STATUS "Gorgon Library requires Visual Studio 2015+")
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
44 ELSE()
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
45 MESSAGE(STATUS "use cmake -DIGNORE_COMPILER_VERSION=ON to continue anyway")
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
46 MESSAGE(FATAL_ERROR "Gorgon Library requires Visual Studio 2015+")
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
47 ENDIF()
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
48 ENDIF()
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
49 ELSE()
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
50 IF(IGNORE_COMPILER_VENDOR)
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
51 MESSAGE(STATUS "Unsupported compiler! Gorgon Library requires GCC 4.8+ OR Visual Studio 2015+")
1123
7d4ba778fdee * 64 bit build is now default
cemkalyoncu
parents: 1061
diff changeset
52 MESSAGE(STATUS "You may need to manually activate C++14 features")
830
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
53 ELSE()
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
54 MESSAGE(STATUS "use cmake -DIGNORE_COMPILER_VENDOR=ON to continue anyway")
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
55 MESSAGE(FATAL_ERROR "Unsupported compiler! Gorgon Library requires GCC 4.8+ OR Visual Studio 2015+")
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
56 ENDIF()
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
57 ENDIF()
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
58
1123
7d4ba778fdee * 64 bit build is now default
cemkalyoncu
parents: 1061
diff changeset
59 OPTION(FORCE_32_BIT "Force 32 bit compilation" OFF)
830
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
60
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
61 #enable C++11 and 32-bit compilation
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
62 INCLUDE(CheckCXXCompilerFlag)
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
63 IF(CMAKE_COMPILER_IS_GNUCXX)
1123
7d4ba778fdee * 64 bit build is now default
cemkalyoncu
parents: 1061
diff changeset
64 IF(${FORCE_32_BIT})
1124
71ddc507e93f * Ability to load paletted png images
cemkalyoncu
parents: 1123
diff changeset
65 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -m32")
830
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
66 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
1123
7d4ba778fdee * 64 bit build is now default
cemkalyoncu
parents: 1061
diff changeset
67 ELSE()
1124
71ddc507e93f * Ability to load paletted png images
cemkalyoncu
parents: 1123
diff changeset
68 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
830
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
69 ENDIF()
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
70 ENDIF()
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
71
1061
1e0c869ed4bd * A CMake configuration warning is silenced
cemkalyoncu
parents: 1060
diff changeset
72 IF(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
1123
7d4ba778fdee * 64 bit build is now default
cemkalyoncu
parents: 1061
diff changeset
73 IF(${FORCE_32_BIT})
1124
71ddc507e93f * Ability to load paletted png images
cemkalyoncu
parents: 1123
diff changeset
74 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -m32")
830
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
75 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
1123
7d4ba778fdee * 64 bit build is now default
cemkalyoncu
parents: 1061
diff changeset
76 ELSE()
1124
71ddc507e93f * Ability to load paletted png images
cemkalyoncu
parents: 1123
diff changeset
77 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
830
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
78 ENDIF()
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
79 ENDIF()
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
80
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
81 #MACRO(FixProject)
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
82 #ENDMACRO()
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
83
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
84 IF(MSVC)
1060
73b643fcb15b * Fixed several configuration problems
cemkalyoncu
parents: 830
diff changeset
85 ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
73b643fcb15b * Fixed several configuration problems
cemkalyoncu
parents: 830
diff changeset
86
73b643fcb15b * Fixed several configuration problems
cemkalyoncu
parents: 830
diff changeset
87 ADD_DEFINITIONS(-DUNICODE)
73b643fcb15b * Fixed several configuration problems
cemkalyoncu
parents: 830
diff changeset
88 ADD_DEFINITIONS(-D_UNICODE)
830
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
89
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
90 SET(configs
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
91 CMAKE_C_FLAGS_DEBUG
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
92 CMAKE_C_FLAGS_MINSIZEREL
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
93 CMAKE_C_FLAGS_RELEASE
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
94 CMAKE_C_FLAGS_RELWITHDEBINFO
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
95 CMAKE_CXX_FLAGS_DEBUG
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
96 CMAKE_CXX_FLAGS_MINSIZEREL
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
97 CMAKE_CXX_FLAGS_RELEASE
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
98 CMAKE_CXX_FLAGS_RELWITHDEBINFO
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
99 )
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
100
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
101 FOREACH(config ${configs})
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
102 IF(${config} MATCHES "/MD")
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
103 STRING(REGEX REPLACE "/MD" "/MT" ${config} "${${config}}")
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
104 ENDIF()
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
105 ENDFOREACH()
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
106
1123
7d4ba778fdee * 64 bit build is now default
cemkalyoncu
parents: 1061
diff changeset
107 IF(${CMAKE_CL_64} AND ${FORCE_32_BIT})
7d4ba778fdee * 64 bit build is now default
cemkalyoncu
parents: 1061
diff changeset
108 MESSAGE(FATAL_ERROR "Gorgon Library forced to work with 32 bit compilation")
830
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
109 ENDIF()
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
110 ENDIF()
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
111 ENDMACRO()
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
112
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
113 MACRO(linkgorgon target)
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
114 compilersetup()
1205
f9a44f70dcf5 * Little config fix
cemkalyoncu
parents: 1165
diff changeset
115 target_link_libraries(${target} Gorgon)
f9a44f70dcf5 * Little config fix
cemkalyoncu
parents: 1165
diff changeset
116
1764
e47116c2f9a3 Include gorgon dirs to the target as system to avoid compilation issues
cengizkandemir
parents: 1625
diff changeset
117 target_include_directories(${target} SYSTEM PRIVATE ${GORGON_INCLUDE_DIRS})
1625
f1512f7188c2 * Freetype directories are relayed to client code
cemkalyoncu
parents: 1205
diff changeset
118
f1512f7188c2 * Freetype directories are relayed to client code
cemkalyoncu
parents: 1205
diff changeset
119 if("@FREETYPE@" STREQUAL "SYSTEM" OR "@FREETYPE@" STREQUAL "BUILTIN")
f1512f7188c2 * Freetype directories are relayed to client code
cemkalyoncu
parents: 1205
diff changeset
120 set(FREETYPE_INCLUDE_DIRS "@FREETYPE_INCLUDE_DIRS@")
f1512f7188c2 * Freetype directories are relayed to client code
cemkalyoncu
parents: 1205
diff changeset
121 endif()
830
dc937409ad24 * Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 814
diff changeset
122 ENDMACRO()

mercurial