Skip to content
Permalink
Browse files

- applied fast math flags to C and C++ files

Avoid copy-paste using CMake macro
  • Loading branch information...
alexey-lysiuk committed Oct 5, 2019
1 parent ace677b commit c09f196141b5bc6bc804b3537589b8844326da2d
@@ -143,6 +143,19 @@ if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
set( PROFILE 0 CACHE BOOL "Enable profiling with gprof for Debug and RelWithDebInfo build types." )
endif()

# Fast math flags, required by some subprojects
set( ZD_FASTMATH_FLAG "" )
if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
set( ZD_FASTMATH_FLAG "-ffast-math -ffp-contract=fast" )
elseif( MSVC )
set( ZD_FASTMATH_FLAG "/fp:fast" )
endif()

macro( use_fast_math )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ZD_FASTMATH_FLAG}" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ZD_FASTMATH_FLAG}" )
endmacro()

option( NO_OPENAL "Disable OpenAL sound support" OFF )

find_package( BZip2 )
@@ -305,14 +318,6 @@ if (HAVE_VULKAN)
add_subdirectory( libraries/glslang/OGLCompilersDLL )
endif()

# Fast math flags, required by some subprojects
set( ZD_FASTMATH_FLAG "" )
if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
set( ZD_FASTMATH_FLAG "-ffast-math -ffp-contract=fast" )
elseif( MSVC )
set( ZD_FASTMATH_FLAG "/fp:fast" )
endif()

if( ZLIB_FOUND AND NOT FORCE_INTERNAL_ZLIB )
message( STATUS "Using system zlib, includes found at ${ZLIB_INCLUDE_DIR}" )
else()
@@ -1,15 +1,14 @@
cmake_minimum_required( VERSION 2.8.7 )

make_release_only()
use_fast_math()

add_definitions(-DADLMIDI_DISABLE_MIDI_SEQUENCER)

if( ZD_CMAKE_COMPILER_IS_GNUC_COMPATIBLE )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -fomit-frame-pointer" )
endif()

set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ZD_FASTMATH_FLAG}")

add_library( adl STATIC
adldata.cpp
adlmidi.cpp
@@ -1,6 +1,7 @@
cmake_minimum_required( VERSION 2.8.7 )

make_release_only()
use_fast_math()

include( CheckFunctionExists )
include( CheckCXXCompilerFlag )
@@ -14,9 +15,6 @@ if( ZD_CMAKE_COMPILER_IS_GNUC_COMPATIBLE )
endif()
endif()

# Enable fast flag for dumb
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ZD_FASTMATH_FLAG}" )

CHECK_FUNCTION_EXISTS( itoa ITOA_EXISTS )
if( NOT ITOA_EXISTS )
add_definitions( -DNEED_ITOA=1 )
@@ -32,8 +32,7 @@ if( MSVC )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4101 /wd4800 /wd4702 /wd4706 /wd4805 /wd4310 /wd4244 /wd4456 /wd4459 /wd4146 /wd4127 /wd4458 /wd4267 /wd4804")
endif()

# Enable fast flag for GME
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ZD_FASTMATH_FLAG}" )
use_fast_math()

# Default emulators to build (all of them! ;)
# [ZDoom] No options, enable all of them by default.
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 2.8.12)

make_release_only()
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ZD_FASTMATH_FLAG}" )
use_fast_math()

# Request C++11
if(${CMAKE_VERSION} VERSION_LESS 3.1)
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 2.8.12)

make_release_only()
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ZD_FASTMATH_FLAG}" )
use_fast_math()

if(WIN32)
add_subdirectory(OSDependent/Windows)
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 2.8.12)

make_release_only()
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ZD_FASTMATH_FLAG}" )
use_fast_math()

# Request C++11
if(${CMAKE_VERSION} VERSION_LESS 3.1)
@@ -1,12 +1,12 @@
cmake_minimum_required( VERSION 2.8.7 )

use_fast_math()

if( ZD_CMAKE_COMPILER_IS_GNUC_COMPATIBLE )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -fomit-frame-pointer" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )
endif()

set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ZD_FASTMATH_FLAG}")

include( CheckFunctionExists )

CHECK_FUNCTION_EXISTS( stricmp STRICMP_EXISTS )
@@ -1,6 +1,7 @@
cmake_minimum_required( VERSION 2.8.7 )

make_release_only()
use_fast_math()

# we play with out own sequencer
add_definitions(-DOPNMIDI_DISABLE_MIDI_SEQUENCER)
@@ -12,8 +13,6 @@ if( ZD_CMAKE_COMPILER_IS_GNUC_COMPATIBLE )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -fomit-frame-pointer" )
endif()

set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ZD_FASTMATH_FLAG}")

add_library( opn STATIC
chips/gens_opn2.cpp
chips/gens/Ym2612_Emu.cpp
@@ -1,12 +1,12 @@
cmake_minimum_required( VERSION 2.8.7 )

use_fast_math()

if( ZD_CMAKE_COMPILER_IS_GNUC_COMPATIBLE )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -fomit-frame-pointer" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )
endif()

set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ZD_FASTMATH_FLAG}")

include( CheckFunctionExists )

CHECK_FUNCTION_EXISTS( stricmp STRICMP_EXISTS )
@@ -1,12 +1,12 @@
cmake_minimum_required( VERSION 2.8.7 )

use_fast_math()

if( ZD_CMAKE_COMPILER_IS_GNUC_COMPATIBLE )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -fomit-frame-pointer" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )
endif()

set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ZD_FASTMATH_FLAG}")

include_directories( timiditypp )

file( GLOB HEADER_FILES
@@ -1,12 +1,12 @@
cmake_minimum_required( VERSION 2.8.7 )

use_fast_math()

if( ZD_CMAKE_COMPILER_IS_GNUC_COMPATIBLE )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -fomit-frame-pointer" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )
endif()

set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ZD_FASTMATH_FLAG}")

include( CheckFunctionExists )

CHECK_FUNCTION_EXISTS( stricmp STRICMP_EXISTS )
@@ -1,12 +1,12 @@
cmake_minimum_required( VERSION 2.8.7 )

use_fast_math()

if( ZD_CMAKE_COMPILER_IS_GNUC_COMPATIBLE )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -fomit-frame-pointer" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )
endif()

set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ZD_FASTMATH_FLAG}")

include( CheckFunctionExists )

CHECK_FUNCTION_EXISTS( stricmp STRICMP_EXISTS )
@@ -136,7 +136,7 @@ bool FCDThread::Init ()
CD_WindowClass.style = CS_NOCLOSE;
CD_WindowClass.lpfnWndProc = CD_WndProc;
CD_WindowClass.hInstance = g_hInst;
CD_WindowClass.lpszClassName = L"ZNusic CD Player";
CD_WindowClass.lpszClassName = L"ZMusic CD Player";
CD_WindowAtom = RegisterClass (&CD_WindowClass);

if (CD_WindowAtom == 0)

0 comments on commit c09f196

Please sign in to comment.
You can’t perform that action at this time.