@@ -14,133 +14,133 @@ set(GLES_SUPPORTED FALSE CACHE INTERNAL "GLES is not spported")
1414set (CMAKE_OBJECT_PATH_MAX 4096)
1515
1616if (WIN32 )
17- if (${CMAKE_SYSTEM_NAME} STREQUAL "WindowsStore" )
18- set (PLATFORM_UNIVERSAL_WINDOWS TRUE CACHE INTERNAL "Target platform: Windows Store" )
19- message ("Target platform: Universal Windows" )
20- else ()
21- set (PLATFORM_WIN32 TRUE CACHE INTERNAL "Target platform: Win32" ) #WIN32 is a variable, so we cannot use string "WIN32"
22- message ("Target platform: Win32" )
23- endif ()
17+ if (${CMAKE_SYSTEM_NAME} STREQUAL "WindowsStore" )
18+ set (PLATFORM_UNIVERSAL_WINDOWS TRUE CACHE INTERNAL "Target platform: Windows Store" )
19+ message ("Target platform: Universal Windows" )
20+ else ()
21+ set (PLATFORM_WIN32 TRUE CACHE INTERNAL "Target platform: Win32" ) #WIN32 is a variable, so we cannot use string "WIN32"
22+ message ("Target platform: Win32" )
23+ endif ()
2424else ()
25- if (${CMAKE_SYSTEM_NAME} STREQUAL "Android" )
26- set (PLATFORM_ANDROID TRUE CACHE INTERNAL "Target platform: Android" )
27- message ("Target platform: Android" )
28- elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" )
29- set (PLATFORM_LINUX TRUE CACHE INTERNAL "Target platform: Linux" )
30- message ("Target Platform: Linux" )
31- elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" )
32- if (IOS)
33- set (PLATFORM_IOS TRUE CACHE INTERNAL "Target platform: iOS" )
34- message ("Target Platform: iOS" )
35- else ()
36- set (PLATFORM_MACOS TRUE CACHE INTERNAL "Target platform: MacOS" )
37- message ("Target Platform: MacOS" )
38- endif ()
39- else ()
40- message (FATAL_ERROR "Unsupported platform" )
41- endif ()
25+ if (${CMAKE_SYSTEM_NAME} STREQUAL "Android" )
26+ set (PLATFORM_ANDROID TRUE CACHE INTERNAL "Target platform: Android" )
27+ message ("Target platform: Android" )
28+ elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" )
29+ set (PLATFORM_LINUX TRUE CACHE INTERNAL "Target platform: Linux" )
30+ message ("Target Platform: Linux" )
31+ elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" )
32+ if (IOS)
33+ set (PLATFORM_IOS TRUE CACHE INTERNAL "Target platform: iOS" )
34+ message ("Target Platform: iOS" )
35+ else ()
36+ set (PLATFORM_MACOS TRUE CACHE INTERNAL "Target platform: MacOS" )
37+ message ("Target Platform: MacOS" )
38+ endif ()
39+ else ()
40+ message (FATAL_ERROR "Unsupported platform" )
41+ endif ()
4242endif (WIN32 )
4343
4444add_library (BuildSettings INTERFACE )
4545
4646if (PLATFORM_WIN32)
47- set (D3D11_SUPPORTED TRUE CACHE INTERNAL "D3D11 supported on Win32 platform" )
48- set (D3D12_SUPPORTED TRUE CACHE INTERNAL "D3D12 supported on Win32 platform" )
49- set (GL_SUPPORTED TRUE CACHE INTERNAL "OpenGL supported on Win32 platform" )
50- target_compile_definitions (BuildSettings INTERFACE PLATFORM_WIN32=1)
47+ set (D3D11_SUPPORTED TRUE CACHE INTERNAL "D3D11 supported on Win32 platform" )
48+ set (D3D12_SUPPORTED TRUE CACHE INTERNAL "D3D12 supported on Win32 platform" )
49+ set (GL_SUPPORTED TRUE CACHE INTERNAL "OpenGL supported on Win32 platform" )
50+ target_compile_definitions (BuildSettings INTERFACE PLATFORM_WIN32=1)
5151elseif (PLATFORM_UNIVERSAL_WINDOWS)
52- set (D3D11_SUPPORTED TRUE CACHE INTERNAL "D3D11 supported on Univeral Windows platform" )
53- set (D3D12_SUPPORTED TRUE CACHE INTERNAL "D3D12 supported on Univeral Windows platform" )
54- target_compile_definitions (BuildSettings INTERFACE PLATFORM_UNIVERSAL_WINDOWS=1)
52+ set (D3D11_SUPPORTED TRUE CACHE INTERNAL "D3D11 supported on Univeral Windows platform" )
53+ set (D3D12_SUPPORTED TRUE CACHE INTERNAL "D3D12 supported on Univeral Windows platform" )
54+ target_compile_definitions (BuildSettings INTERFACE PLATFORM_UNIVERSAL_WINDOWS=1)
5555elseif (PLATFORM_ANDROID)
56- set (GLES_SUPPORTED TRUE CACHE INTERNAL "OpenGLES supported on Android platform" )
57- target_compile_definitions (BuildSettings INTERFACE PLATFORM_ANDROID=1)
56+ set (GLES_SUPPORTED TRUE CACHE INTERNAL "OpenGLES supported on Android platform" )
57+ target_compile_definitions (BuildSettings INTERFACE PLATFORM_ANDROID=1)
5858elseif (PLATFORM_LINUX)
59- set (GL_SUPPORTED TRUE CACHE INTERNAL "OpenGL supported on Linux platform" )
60- target_compile_definitions (BuildSettings INTERFACE PLATFORM_LINUX=1)
59+ set (GL_SUPPORTED TRUE CACHE INTERNAL "OpenGL supported on Linux platform" )
60+ target_compile_definitions (BuildSettings INTERFACE PLATFORM_LINUX=1)
6161elseif (PLATFORM_MACOS)
62- set (GL_SUPPORTED TRUE CACHE INTERNAL "OpenGL supported on MacOS platform" )
63- target_compile_definitions (BuildSettings INTERFACE PLATFORM_MACOS=1)
62+ set (GL_SUPPORTED TRUE CACHE INTERNAL "OpenGL supported on MacOS platform" )
63+ target_compile_definitions (BuildSettings INTERFACE PLATFORM_MACOS=1)
6464elseif (PLATFORM_IOS)
65- set (GLES_SUPPORTED TRUE CACHE INTERNAL "OpenGLES supported on iOS platform" )
66- target_compile_definitions (BuildSettings INTERFACE PLATFORM_IOS=1)
65+ set (GLES_SUPPORTED TRUE CACHE INTERNAL "OpenGLES supported on iOS platform" )
66+ target_compile_definitions (BuildSettings INTERFACE PLATFORM_IOS=1)
6767else ()
68- message (FATAL_ERROR "No PLATFORM_XXX variable defined. Make sure that 'DiligentCore' folder is processed first" )
68+ message (FATAL_ERROR "No PLATFORM_XXX variable defined. Make sure that 'DiligentCore' folder is processed first" )
6969endif ()
7070
7171if (MSVC )
72- # For msvc, enable level 4 warnings except for
73- # - w4100 - unreferenced formal parameter
74- # - w4505 - unreferenced local function has been removed
75- target_compile_options (BuildSettings INTERFACE /W4 /wd4100 /wd4505)
76- # In all releases mode also:
77- # - disable w4189 - local variable is initialized but not referenced
78- # - Enable AVX2 instruction set (/arch:AVX2)
79- # - Disable RTTI (/GR-)
80- # - Enable whole program optimizaion (/GL)
81- # - Enable string pooling (/GF)
82- set (MSVC_ALL_RELEASE_COMPILE_OPTIONS /arch:AVX2 /wd4189 /GR- /GL /GF)
83- #target_compile_options(BuildSettings INTERFACE "$<$<CONFIG:RELEASE>:/arch:AVX2 /wd4189 /Ot")
84- # In RELEASE mode:
85- # - Set favor fast code option (/Ot)
86- # - Enable intrinsic functions (/Oi)
87- set (MSVC_RELEASE_COMPILE_OPTIONS ${MSVC_ALL_RELEASE_COMPILE_OPTIONS} /Ot /Oi)
88- # In MINSIZEREL mode set favor small code option (/Os)
89- set (MSVC_MINSIZEREL_COMPILE_OPTIONS ${MSVC_ALL_RELEASE_COMPILE_OPTIONS} /Os)
90- set (MSVC_RELWITHDEBINFO_COMPILE_OPTIONS ${MSVC_ALL_RELEASE_COMPILE_OPTIONS} )
91- target_compile_options (BuildSettings INTERFACE "$<$<CONFIG:RELEASE>:${MSVC_RELEASE_COMPILE_OPTIONS} >" )
92- target_compile_options (BuildSettings INTERFACE "$<$<CONFIG:MINSIZEREL>:${MSVC_MINSIZEREL_COMPILE_OPTIONS} >" )
93- target_compile_options (BuildSettings INTERFACE "$<$<CONFIG:RELWITHDEBINFO>:${MSVC_RELWITHDEBINFO_COMPILE_OPTIONS} >" )
94- # !!!NOTE!!! For some reason above is the only form of generator expression that works
95- # For instance, this way
96- # target_compile_options(BuildSettings INTERFACE "$<$<CONFIG:RELEASE>:/Ot>")
97- # does not work as expected
72+ # For msvc, enable level 4 warnings except for
73+ # - w4100 - unreferenced formal parameter
74+ # - w4505 - unreferenced local function has been removed
75+ target_compile_options (BuildSettings INTERFACE /W4 /wd4100 /wd4505)
76+ # In all releases mode also:
77+ # - disable w4189 - local variable is initialized but not referenced
78+ # - Enable AVX2 instruction set (/arch:AVX2)
79+ # - Disable RTTI (/GR-)
80+ # - Enable whole program optimizaion (/GL)
81+ # - Enable string pooling (/GF)
82+ set (MSVC_ALL_RELEASE_COMPILE_OPTIONS /arch:AVX2 /wd4189 /GR- /GL /GF)
83+ #target_compile_options(BuildSettings INTERFACE "$<$<CONFIG:RELEASE>:/arch:AVX2 /wd4189 /Ot")
84+ # In RELEASE mode:
85+ # - Set favor fast code option (/Ot)
86+ # - Enable intrinsic functions (/Oi)
87+ set (MSVC_RELEASE_COMPILE_OPTIONS ${MSVC_ALL_RELEASE_COMPILE_OPTIONS} /Ot /Oi)
88+ # In MINSIZEREL mode set favor small code option (/Os)
89+ set (MSVC_MINSIZEREL_COMPILE_OPTIONS ${MSVC_ALL_RELEASE_COMPILE_OPTIONS} /Os)
90+ set (MSVC_RELWITHDEBINFO_COMPILE_OPTIONS ${MSVC_ALL_RELEASE_COMPILE_OPTIONS} )
91+ target_compile_options (BuildSettings INTERFACE "$<$<CONFIG:RELEASE>:${MSVC_RELEASE_COMPILE_OPTIONS} >" )
92+ target_compile_options (BuildSettings INTERFACE "$<$<CONFIG:MINSIZEREL>:${MSVC_MINSIZEREL_COMPILE_OPTIONS} >" )
93+ target_compile_options (BuildSettings INTERFACE "$<$<CONFIG:RELWITHDEBINFO>:${MSVC_RELWITHDEBINFO_COMPILE_OPTIONS} >" )
94+ # !!!NOTE!!! For some reason above is the only form of generator expression that works
95+ # For instance, this way
96+ # target_compile_options(BuildSettings INTERFACE "$<$<CONFIG:RELEASE>:/Ot>")
97+ # does not work as expected
9898else ()
9999
100- set (DEBUG_MACROS _DEBUG DEBUG)
101- set (RELEASE_MACROS NDEBUG)
102- target_compile_definitions (BuildSettings INTERFACE "$<$<CONFIG:DEBUG>:${DEBUG_MACROS} >" )
103- target_compile_definitions (BuildSettings INTERFACE "$<$<CONFIG:RELEASE>:${RELEASE_MACROS} >" )
104- target_compile_definitions (BuildSettings INTERFACE "$<$<CONFIG:MINSIZEREL>:${RELEASE_MACROS} >" )
105- target_compile_definitions (BuildSettings INTERFACE "$<$<CONFIG:RELWITHDEBINFO>:${RELEASE_MACROS} >" )
100+ set (DEBUG_MACROS _DEBUG DEBUG)
101+ set (RELEASE_MACROS NDEBUG)
102+ target_compile_definitions (BuildSettings INTERFACE "$<$<CONFIG:DEBUG>:${DEBUG_MACROS} >" )
103+ target_compile_definitions (BuildSettings INTERFACE "$<$<CONFIG:RELEASE>:${RELEASE_MACROS} >" )
104+ target_compile_definitions (BuildSettings INTERFACE "$<$<CONFIG:MINSIZEREL>:${RELEASE_MACROS} >" )
105+ target_compile_definitions (BuildSettings INTERFACE "$<$<CONFIG:RELWITHDEBINFO>:${RELEASE_MACROS} >" )
106106
107107endif (MSVC )
108108
109109if (PLATFORM_LINUX)
110- if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" )
111- # Without -fPIC option GCC fails to link static libraries into dynamic library:
112- # -fPIC
113- # If supported for the target machine, emit position-independent code, suitable for
114- # dynamic linking and avoiding any limit on the size of the global offset table.
115- target_compile_options (BuildSettings INTERFACE -fPIC)
116- endif ()
110+ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" )
111+ # Without -fPIC option GCC fails to link static libraries into dynamic library:
112+ # -fPIC
113+ # If supported for the target machine, emit position-independent code, suitable for
114+ # dynamic linking and avoiding any limit on the size of the global offset table.
115+ target_compile_options (BuildSettings INTERFACE -fPIC)
116+ endif ()
117117endif ()
118118
119119if ("${CMAKE_SIZEOF_VOID_P} " EQUAL "8" )
120- set (ARCH 64 CACHE INTERNAL "64-bit architecture" )
120+ set (ARCH 64 CACHE INTERNAL "64-bit architecture" )
121121else ()
122- set (ARCH 32 CACHE INTERNAL "32-bit architecture" )
122+ set (ARCH 32 CACHE INTERNAL "32-bit architecture" )
123123endif ()
124124
125125if (PLATFORM_WIN32 OR PLATFORM_UNIVERSAL_WINDOWS OR PLATFORM_MACOS)
126126
127- # https://cmake.org/cmake/help/v3.8/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html#prop_gbl:CMAKE_CXX_KNOWN_FEATURES
128- target_compile_features (BuildSettings INTERFACE cxx_std_11) # Generates an error in gradle build on Android
127+ # https://cmake.org/cmake/help/v3.8/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html#prop_gbl:CMAKE_CXX_KNOWN_FEATURES
128+ target_compile_features (BuildSettings INTERFACE cxx_std_11) # Generates an error in gradle build on Android
129129
130130elseif (PLATFORM_ANDROID)
131131
132- # LOCAL_CPP_FEATURES := exceptions rtti
132+ # LOCAL_CPP_FEATURES := exceptions rtti
133133
134134elseif (PLATFORM_IOS)
135135
136-
136+
137137endif ()
138138
139139if (PLATFORM_MACOS)
140- find_library (APP_KIT AppKit)
141- if (NOT APP_KIT)
142- message (FATAL_ERROR "AppKit not found" )
143- endif ()
140+ find_library (APP_KIT AppKit)
141+ if (NOT APP_KIT)
142+ message (FATAL_ERROR "AppKit not found" )
143+ endif ()
144144elseif (PLATFORM_IOS)
145145 find_library (CORE_FOUNDATION CoreFoundation)
146146 if (NOT CORE_FOUNDATION)
0 commit comments