mirror of
https://github.com/minetest/minetest.git
synced 2024-12-02 04:23:45 +01:00
Update CMakeLists to use add_compile_definitions
(#15483)
This is a newer feature introduced in CMake 3.12, which is now our minimum version. It supercedes `add_definitions`. I've also replaced some calls to set `CMAKE_<LANG>_FLAGS` that were used to set definitions. This is a fairly trivial routine build maintenance that is not intended to have any behavioral effects.
This commit is contained in:
parent
d068f34753
commit
c3db9492a7
@ -9,7 +9,7 @@ option(USE_SDL2 "Use the SDL2 backend" ${DEFAULT_SDL2})
|
|||||||
# Compiler flags
|
# Compiler flags
|
||||||
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
add_definitions(-D_DEBUG)
|
add_compile_definitions(_DEBUG)
|
||||||
endif()
|
endif()
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
||||||
|
|
||||||
@ -43,9 +43,7 @@ elseif(MSVC)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Platform-independent configuration (hard-coded currently)
|
# Platform-independent configuration (hard-coded currently)
|
||||||
add_definitions(
|
add_compile_definitions(IRR_ENABLE_BUILTIN_FONT)
|
||||||
-DIRR_ENABLE_BUILTIN_FONT
|
|
||||||
)
|
|
||||||
|
|
||||||
# Platform-specific configuration
|
# Platform-specific configuration
|
||||||
|
|
||||||
@ -56,35 +54,35 @@ endif()
|
|||||||
# Device
|
# Device
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
add_definitions(-D_IRR_WINDOWS_ -D_IRR_WINDOWS_API_)
|
add_compile_definitions(_IRR_WINDOWS_ _IRR_WINDOWS_API_)
|
||||||
set(DEVICE "WINDOWS")
|
set(DEVICE "WINDOWS")
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
add_definitions(-D_IRR_OSX_PLATFORM_)
|
add_compile_definitions(_IRR_OSX_PLATFORM_)
|
||||||
set(DEVICE "OSX")
|
set(DEVICE "OSX")
|
||||||
elseif(ANDROID)
|
elseif(ANDROID)
|
||||||
add_definitions(-D_IRR_ANDROID_PLATFORM_)
|
add_compile_definitions(_IRR_ANDROID_PLATFORM_)
|
||||||
if(NOT USE_SDL2)
|
if(NOT USE_SDL2)
|
||||||
message(FATAL_ERROR "The Android build requires SDL2")
|
message(FATAL_ERROR "The Android build requires SDL2")
|
||||||
endif()
|
endif()
|
||||||
elseif(EMSCRIPTEN)
|
elseif(EMSCRIPTEN)
|
||||||
add_definitions(-D_IRR_EMSCRIPTEN_PLATFORM_ -D_IRR_COMPILE_WITH_EGL_MANAGER_)
|
add_compile_definitions(_IRR_EMSCRIPTEN_PLATFORM_ _IRR_COMPILE_WITH_EGL_MANAGER_)
|
||||||
set(LINUX_PLATFORM TRUE)
|
set(LINUX_PLATFORM TRUE)
|
||||||
set(DEVICE "SDL")
|
set(DEVICE "SDL")
|
||||||
elseif(SOLARIS)
|
elseif(SOLARIS)
|
||||||
add_definitions(-D_IRR_SOLARIS_PLATFORM_ -D_IRR_POSIX_API_)
|
add_compile_definitions(_IRR_SOLARIS_PLATFORM_ _IRR_POSIX_API_)
|
||||||
set(DEVICE "X11")
|
set(DEVICE "X11")
|
||||||
else()
|
else()
|
||||||
add_definitions(-D_IRR_POSIX_API_)
|
add_compile_definitions(_IRR_POSIX_API_)
|
||||||
set(LINUX_PLATFORM TRUE)
|
set(LINUX_PLATFORM TRUE)
|
||||||
set(DEVICE "X11")
|
set(DEVICE "X11")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(LINUX_PLATFORM)
|
if(LINUX_PLATFORM)
|
||||||
add_definitions(-D_IRR_LINUX_PLATFORM_)
|
add_compile_definitions(_IRR_LINUX_PLATFORM_)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(USE_SDL2)
|
if(USE_SDL2)
|
||||||
@ -93,7 +91,7 @@ elseif(DEVICE STREQUAL "SDL")
|
|||||||
message(FATAL_ERROR "SDL was used but not enabled?!")
|
message(FATAL_ERROR "SDL was used but not enabled?!")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_definitions("-D_IRR_COMPILE_WITH_${DEVICE}_DEVICE_")
|
add_compile_definitions("_IRR_COMPILE_WITH_${DEVICE}_DEVICE_")
|
||||||
|
|
||||||
# X11
|
# X11
|
||||||
|
|
||||||
@ -114,7 +112,7 @@ endif()
|
|||||||
# Joystick
|
# Joystick
|
||||||
|
|
||||||
if(NOT (BSD OR SOLARIS OR EMSCRIPTEN))
|
if(NOT (BSD OR SOLARIS OR EMSCRIPTEN))
|
||||||
add_definitions(-D_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
|
add_compile_definitions(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# OpenGL
|
# OpenGL
|
||||||
@ -154,15 +152,15 @@ endif()
|
|||||||
|
|
||||||
if(ENABLE_OPENGL OR (ENABLE_OPENGL3 AND NOT USE_SDL2))
|
if(ENABLE_OPENGL OR (ENABLE_OPENGL3 AND NOT USE_SDL2))
|
||||||
if(ENABLE_OPENGL)
|
if(ENABLE_OPENGL)
|
||||||
add_definitions(-D_IRR_COMPILE_WITH_OPENGL_)
|
add_compile_definitions(_IRR_COMPILE_WITH_OPENGL_)
|
||||||
set(OPENGL_DIRECT_LINK TRUE) # driver relies on this
|
set(OPENGL_DIRECT_LINK TRUE) # driver relies on this
|
||||||
endif()
|
endif()
|
||||||
if(DEVICE STREQUAL "WINDOWS")
|
if(DEVICE STREQUAL "WINDOWS")
|
||||||
add_definitions(-D_IRR_COMPILE_WITH_WGL_MANAGER_)
|
add_compile_definitions(_IRR_COMPILE_WITH_WGL_MANAGER_)
|
||||||
elseif(DEVICE STREQUAL "X11")
|
elseif(DEVICE STREQUAL "X11")
|
||||||
add_definitions(-D_IRR_COMPILE_WITH_GLX_MANAGER_)
|
add_compile_definitions(_IRR_COMPILE_WITH_GLX_MANAGER_)
|
||||||
elseif(DEVICE STREQUAL "OSX")
|
elseif(DEVICE STREQUAL "OSX")
|
||||||
add_definitions(-D_IRR_COMPILE_WITH_NSOGL_MANAGER_)
|
add_compile_definitions(_IRR_COMPILE_WITH_NSOGL_MANAGER_)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -177,14 +175,14 @@ if(ENABLE_OPENGL3)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_GLES2)
|
if(ENABLE_GLES2)
|
||||||
add_definitions(-D_IRR_COMPILE_WITH_OGLES2_)
|
add_compile_definitions(_IRR_COMPILE_WITH_OGLES2_)
|
||||||
if(DEVICE MATCHES "^(WINDOWS|X11)$" OR EMSCRIPTEN)
|
if(DEVICE MATCHES "^(WINDOWS|X11)$" OR EMSCRIPTEN)
|
||||||
add_definitions(-D_IRR_COMPILE_WITH_EGL_MANAGER_)
|
add_compile_definitions(_IRR_COMPILE_WITH_EGL_MANAGER_)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_WEBGL1)
|
if(ENABLE_WEBGL1)
|
||||||
add_definitions(-D_IRR_COMPILE_WITH_WEBGL1_)
|
add_compile_definitions(_IRR_COMPILE_WITH_WEBGL1_)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Misc
|
# Misc
|
||||||
@ -192,7 +190,7 @@ endif()
|
|||||||
include(TestBigEndian)
|
include(TestBigEndian)
|
||||||
TEST_BIG_ENDIAN(BIG_ENDIAN)
|
TEST_BIG_ENDIAN(BIG_ENDIAN)
|
||||||
if(BIG_ENDIAN)
|
if(BIG_ENDIAN)
|
||||||
add_definitions(-D__BIG_ENDIAN__)
|
add_compile_definitions(__BIG_ENDIAN__)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Configuration report
|
# Configuration report
|
||||||
@ -263,7 +261,7 @@ if(ENABLE_OPENGL AND DEVICE STREQUAL "SDL")
|
|||||||
#endif\n\
|
#endif\n\
|
||||||
int main() {}" CHECK_GL_VERSION_4_5)
|
int main() {}" CHECK_GL_VERSION_4_5)
|
||||||
if(CHECK_GL_VERSION_4_5)
|
if(CHECK_GL_VERSION_4_5)
|
||||||
add_definitions(-DIRR_PREFER_SDL_GL_HEADER)
|
add_compile_definitions(IRR_PREFER_SDL_GL_HEADER)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -275,7 +273,7 @@ elseif(APPLE)
|
|||||||
find_library(COCOA_LIB Cocoa REQUIRED)
|
find_library(COCOA_LIB Cocoa REQUIRED)
|
||||||
find_library(IOKIT_LIB IOKit REQUIRED)
|
find_library(IOKIT_LIB IOKit REQUIRED)
|
||||||
|
|
||||||
add_definitions(-DGL_SILENCE_DEPRECATION)
|
add_compile_definitions(GL_SILENCE_DEPRECATION)
|
||||||
elseif(NOT USE_SDL2)
|
elseif(NOT USE_SDL2)
|
||||||
# Unix probably
|
# Unix probably
|
||||||
find_package(X11 REQUIRED)
|
find_package(X11 REQUIRED)
|
||||||
|
@ -260,12 +260,11 @@ endif()
|
|||||||
|
|
||||||
# Haiku endian support
|
# Haiku endian support
|
||||||
if(HAIKU)
|
if(HAIKU)
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_BSD_SOURCE")
|
add_compile_definitions(_BSD_SOURCE)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_BSD_SOURCE")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Use cmake_config.h
|
# Use cmake_config.h
|
||||||
add_definitions(-DUSE_CMAKE_CONFIG_H)
|
add_compile_definitions(USE_CMAKE_CONFIG_H)
|
||||||
|
|
||||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
@ -276,11 +275,15 @@ if(WIN32)
|
|||||||
if(MSVC) # MSVC Specifics
|
if(MSVC) # MSVC Specifics
|
||||||
set(PLATFORM_LIBS dbghelp.lib ${PLATFORM_LIBS})
|
set(PLATFORM_LIBS dbghelp.lib ${PLATFORM_LIBS})
|
||||||
# Surpress some useless warnings
|
# Surpress some useless warnings
|
||||||
add_definitions ( /D "_CRT_SECURE_NO_DEPRECATE" /W1 )
|
add_compile_options(/W1)
|
||||||
|
add_compile_definitions(
|
||||||
|
# Suppress some useless warnings
|
||||||
|
_CRT_SECURE_NO_DEPRECATE
|
||||||
# Get M_PI to work
|
# Get M_PI to work
|
||||||
add_definitions(/D "_USE_MATH_DEFINES")
|
_USE_MATH_DEFINES
|
||||||
# Don't define min/max macros in minwindef.h
|
# Don't define min/max macros in minwindef.h
|
||||||
add_definitions(/D "NOMINMAX")
|
NOMINMAX
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
set(PLATFORM_LIBS ws2_32.lib version.lib shlwapi.lib winmm.lib ${PLATFORM_LIBS})
|
set(PLATFORM_LIBS ws2_32.lib version.lib shlwapi.lib winmm.lib ${PLATFORM_LIBS})
|
||||||
|
|
||||||
@ -871,7 +874,7 @@ endif()
|
|||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
# Visual Studio
|
# Visual Studio
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D _WIN32_WINNT=0x0601 /D WIN32_LEAN_AND_MEAN /D _CRT_SECURE_NO_WARNINGS")
|
add_compile_definitions(_WIN32_WINNT=0x0601 WIN32_LEAN_AND_MEAN _CRT_SECURE_NO_WARNINGS)
|
||||||
# EHa enables SEH exceptions (used for catching segfaults)
|
# EHa enables SEH exceptions (used for catching segfaults)
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "/EHa /Ox /MD /GS- /Zi /fp:fast /D NDEBUG /D _HAS_ITERATOR_DEBUGGING=0")
|
set(CMAKE_CXX_FLAGS_RELEASE "/EHa /Ox /MD /GS- /Zi /fp:fast /D NDEBUG /D _HAS_ITERATOR_DEBUGGING=0")
|
||||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||||
@ -915,7 +918,7 @@ else()
|
|||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
set(OTHER_FLAGS "${OTHER_FLAGS} -mthreads")
|
set(OTHER_FLAGS "${OTHER_FLAGS} -mthreads")
|
||||||
endif()
|
endif()
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WIN32_WINNT=0x0601 -DWIN32_LEAN_AND_MEAN")
|
add_compile_definitions(_WIN32_WINNT=0x0601 WIN32_LEAN_AND_MEAN)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Use a safe subset of flags to speed up math calculations:
|
# Use a safe subset of flags to speed up math calculations:
|
||||||
|
Loading…
Reference in New Issue
Block a user