diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 45b65da1e..35e093e73 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -327,6 +327,41 @@ if( NOT NO_ASM ) ENDMACRO( ADD_ASM_FILE ) endif( NOT NO_ASM ) +# Decide on SSE setup + +set( SSE_MATTERS NO ) + +# SSE only matters on 32-bit targets. We check compiler flags to know if we can do it. +if( CMAKE_SIZEOF_VOID_P MATCHES "4" ) + CHECK_CXX_COMPILER_FLAG( "-msse2 -mfpmath=sse" CAN_DO_MFPMATH ) + CHECK_CXX_COMPILER_FLAG( -arch:SSE2 CAN_DO_ARCHSSE2 ) + if( CAN_DO_MFPMATH ) + set( SSE1_ENABLE "-msse -mfpmath=sse" ) + set( SSE2_ENABLE "-msse2 -mfpmath=sse" ) + set( SSE_MATTERS YES ) + elseif( CAN_DO_ARCHSSE2 ) + set( SSE1_ENABLE -arch:SSE ) + set( SSE2_ENABLE -arch:SSE2 ) + set( SSE_MATTERS YES ) + endif( CAN_DO_MFPMATH ) +endif( CMAKE_SIZEOF_VOID_P MATCHES "4" ) + +if( SSE_MATTERS ) + if( WIN32 ) + set( BACKPATCH 1 CACHE BOOL "Enable backpatching." ) + else( WIN32 ) + CHECK_FUNCTION_EXISTS(mprotect HAVE_MPROTECT) + if( HAVE_MPROTECT ) + set( BACKPATCH 1 CACHE BOOL "Enable backpatching." ) + else( HAVE_MPROTECT ) + set( BACKPATCH 0 ) + endif( HAVE_MPROTECT ) + endif( WIN32 ) + set( SSE 1 CACHE BOOL "Build SSE and SSE2 versions of key code." ) +else( SSE_MATTERS ) + set( BACKPATCH 0 ) +endif( SSE_MATTERS ) + # Set up flags for GCC if( CMAKE_COMPILER_IS_GNUCXX ) @@ -422,6 +457,12 @@ if( NOT HAS_VA_COPY ) endif( HAS___VA_COPY ) endif( NOT HAS_VA_COPY ) +# Flags + +if( BACKPATCH ) + add_definitions( -DBACKPATCH ) +endif( BACKPATCH ) + # Update svnrevision.h add_custom_target( revision_check ALL @@ -515,12 +556,18 @@ add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) -if( CMAKE_SYSTEM_PROCESSOR MATCHES powerpc OR CMAKE_OSX_ARCHITECTURES MATCHES ppc ) +if( SSE_MATTERS ) + if( SSE ) + set( X86_SOURCES nodebuild_classify_sse2.cpp ) + set_source_files_properties( nodebuild_classify_sse2.cpp PROPERTIES COMPILE_FLAGS "${SSE2_ENABLE}" ) + else( SSE ) + add_definitions( -DDISABLE_SSE ) + endif( SSE ) +else( SSE_MATTERS ) + add_definitions( -DDISABLE_SSE ) set( X86_SOURCES ) - set( NOT_X86 ON ) -else( CMAKE_SYSTEM_PROCESSOR MATCHES powerpc OR CMAKE_OSX_ARCHITECTURES MATCHES ppc ) - set( X86_SOURCES nodebuild_classify_sse2.cpp ) -endif( CMAKE_SYSTEM_PROCESSOR MATCHES powerpc OR CMAKE_OSX_ARCHITECTURES MATCHES ppc ) +endif( SSE_MATTERS ) + add_executable( zdoom WIN32 autostart.cpp @@ -824,21 +871,12 @@ if( NOT WIN32 ) COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/link-make COMMAND /bin/sh -c ${CMAKE_CURRENT_BINARY_DIR}/link-make ) endif( NOT WIN32 ) - if( CMAKE_COMPILER_IS_GNUCXX ) # GCC misoptimizes this file set_source_files_properties( oplsynth/fmopl.cpp PROPERTIES COMPILE_FLAGS "-fno-tree-dominator-opts -fno-tree-fre" ) - - # Compile this one file with SSE2 support. - set_source_files_properties( nodebuild_classify_sse2.cpp PROPERTIES COMPILE_FLAGS "-msse2 -mfpmath=sse" ) # Need to enable intrinsics for this file. - if( NOT NOT_X86 ) + if( SSE_MATTERS ) set_source_files_properties( x86.cpp PROPERTIES COMPILE_FLAGS "-msse2 -mmmx" ) - endif( NOT NOT_X86 ) + endif( SSE_MATTERS ) endif( CMAKE_COMPILER_IS_GNUCXX ) - -if( MSVC ) - # Compile this one file with SSE2 support. - set_source_files_properties( nodebuild_classify_sse2.cpp PROPERTIES COMPILE_FLAGS "/arch:SSE2" ) -endif( MSVC ) diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 50af213b5..636d4d69f 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -1325,8 +1325,8 @@ void P_LoadSubsectors (MapData * map) if ((size_t)subsectors[i].firstline >= maxseg) { Printf ("Subsector %d contains invalid segs %u-%u\n" - "The BSP will be rebuilt.\n", i, subsectors[i].firstline, - subsectors[i].firstline + subsectors[i].numlines - 1); + "The BSP will be rebuilt.\n", i, (unsigned)subsectors[i].firstline, + (unsigned)subsectors[i].firstline + subsectors[i].numlines - 1); ForceNodeBuild = true; delete[] nodes; delete[] subsectors; @@ -1336,7 +1336,7 @@ void P_LoadSubsectors (MapData * map) { Printf ("Subsector %d contains invalid segs %u-%u\n" "The BSP will be rebuilt.\n", i, maxseg, - subsectors[i].firstline + subsectors[i].numlines - 1); + (unsigned)subsectors[i].firstline + subsectors[i].numlines - 1); ForceNodeBuild = true; delete[] nodes; delete[] subsectors;