- Use CMake build system for ZDBSP.

SVN r2393 (trunk)
This commit is contained in:
Randy Heit 2010-06-30 04:40:47 +00:00
parent 6111d84c1b
commit f824fe7a86
8 changed files with 202 additions and 1280 deletions

185
CMakeLists.txt Normal file
View file

@ -0,0 +1,185 @@
cmake_minimum_required( VERSION 2.4 )
if( COMMAND cmake_policy )
cmake_policy( SET CMP0003 NEW )
endif( COMMAND cmake_policy )
include( CheckFunctionExists )
include( CheckCXXCompilerFlag )
IF( NOT CMAKE_BUILD_TYPE )
SET( CMAKE_BUILD_TYPE Debug CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
FORCE )
ENDIF( NOT CMAKE_BUILD_TYPE )
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( CMAKE_COMPILER_IS_GNUCXX AND WIN32 )
set( BACKPATCH 1 CACHE BOOL "Enable backpatching." )
endif( CMAKE_COMPILER_IS_GNUCXX AND WIN32 )
set( FULL_SSE2 0 CACHE BOOL "Use SSE2 math everywhere." )
set( SSE 1 CACHE BOOL "Build SSE and SSE2 versions of key code." )
endif( SSE_MATTERS )
if( CMAKE_COMPILER_IS_GNUCXX )
set( GPROF 0 CACHE BOOL "Enable profiling with gprof for Debug and RelWithDebInfo build types." )
endif( CMAKE_COMPILER_IS_GNUCXX )
find_package( ZLIB )
if( MSVC )
# Eliminate unreferenced functions and data
# Perform identical COMDAT folding
set( REL_LINKER_FLAGS "/opt:ref /opt:icf /nodefaultlib:msvcrt" )
# String pooling
# Function-level linking
# Disable run-time type information
set( ALL_C_FLAGS "/GF /Gy /GR-" )
# Avoid CRT DLL dependancies in release builds
set( REL_C_FLAGS "/MT" )
# Disable warnings for unsecure CRT functions from VC8+
if( MSVC_VERSION GREATER 1399 )
set( ALL_C_FLAGS "${ALL_C_FLAGS} /wd4996" )
endif( MSVC_VERSION GREATER 1399 )
# The CMake configurations set /GR and /MD by default, which conflict with our settings.
string(REPLACE "/MD " " " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} )
string(REPLACE "/MD " " " CMAKE_CXX_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS_MINSIZEREL} )
string(REPLACE "/MD " " " CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO} )
string(REPLACE "/MD " " " CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE} )
string(REPLACE "/MD " " " CMAKE_C_FLAGS_MINSIZEREL ${CMAKE_C_FLAGS_MINSIZEREL} )
string(REPLACE "/MD " " " CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO} )
string(REPLACE " /GR" " " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} )
endif( MSVC )
if( CMAKE_COMPILER_IS_GNUCXX )
set( ALL_C_FLAGS "${ALL_C_FLAGS} -ffast-math -pipe" )
if( GPROF )
set( ALL_C_FLAGS "${ALL_C_FLAGS} -pg -g" )
else( GPROF )
set( REL_C_FLAGS "${REL_C_FLAGS} -fomit-frame-pointer" )
endif( GPROF )
if( PROFILE EQUAL 1 )
message( STATUS "Generating profile coverage information" )
set( ALL_C_FLAGS "${ALL_C_FLAGS} -fprofile-generate" )
set( PROF_LIB "gcov" )
elseif( PROFILE EQUAL 2 )
message( STATUS "Using profile coverage information" )
set( ALL_C_FLAGS "${ALL_C_FLAGS} -fprofile-use" )
endif( PROFILE EQUAL 1 )
endif( CMAKE_COMPILER_IS_GNUCXX )
if( ZLIB_FOUND )
message( STATUS "Using system zlib" )
else( ZLIB_FOUND )
message( STATUS "Using internal zlib" )
add_subdirectory( zlib )
set( ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/zlib )
set( ZLIB_LIBRARIES z )
set( ZLIB_LIBRARY z )
endif( ZLIB_FOUND )
CHECK_FUNCTION_EXISTS( stricmp STRICMP_EXISTS )
if( NOT STRICMP_EXISTS )
add_definitions( -Dstricmp=strcasecmp )
endif( NOT STRICMP_EXISTS )
CHECK_FUNCTION_EXISTS( strnicmp STRNICMP_EXISTS )
if( NOT STRNICMP_EXISTS )
add_definitions( -Dstrnicmp=strncasecmp )
endif( NOT STRNICMP_EXISTS )
set( ZDBSP_LIBS "${ZLIB_LIBRARIES}" )
set( SOURCES
main.cpp
getopt.c
getopt1.c
blockmapbuilder.cpp
processor.cpp
processor_udmf.cpp
sc_man.cpp
view.cpp
wad.cpp
nodebuild.cpp
nodebuild_events.cpp
nodebuild_extract.cpp
nodebuild_gl.cpp
nodebuild_utility.cpp
nodebuild_classify_nosse2.cpp
)
if( SSE_MATTERS )
if( FULL_SSE2 )
message( STATUS "Using SSE2 math everywhere." )
# Building everything with SSE2 is much like disabling it, in that we
# need not check for its existance while running.
set( ALL_C_FLAGS "${ALL_C_FLAGS} -DDISABLE_SSE ${SSE2_ENABLE}" )
else( FULL_SSE2 )
if( SSE )
message( STATUS "Using SSE math for ClassifyLine only." )
set( SOURCES ${SOURCES} nodebuild_classify_sse1.cpp nodebuild_classify_sse2.cpp )
set_source_files_properties( nodebuild_classify_sse1.cpp PROPERTIES COMPILE_FLAGS "${SSE1_ENABLE}" )
set_source_files_properties( nodebuild_classify_sse2.cpp PROPERTIES COMPILE_FLAGS "${SSE2_ENABLE}" )
else( SSE )
message( STATUS "SSE math is completely disabled." )
set( ALL_C_FLAGS "${ALL_C_FLAGS} -DDISABLE_SSE" )
endif( SSE )
endif( FULL_SSE2 )
else( SSE_MATTERS )
set( ALL_C_FLAGS "${ALL_C_FLAGS} -DDISABLE_SSE" )
endif( SSE_MATTERS )
if( WIN32 )
set( ZDBSP_LIBS ${ZDBSP_LIBS} user32 gdi32 )
if( CMAKE_COMPILER_IS_GNUCXX )
# CMake is not set up to compile and link rc files with GCC. :(
add_custom_command( OUTPUT zdbsp-rc.o
COMMAND windres -o zdbsp-rc.o -i ${CMAKE_CURRENT_SOURCE_DIR}/resource.rc
DEPENDS resource.rc )
set( SOURCES ${SOURCES} zdbsp-rc.o )
else( CMAKE_COMPILER_IS_GNUCXX )
set( SOURCES ${SOURCES} resource.rc )
endif( CMAKE_COMPILER_IS_GNUCXX )
endif( WIN32 )
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${REL_LINKER_FLAGS}" )
set( CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} ${REL_LINKER_FLAGS}" )
set( CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} ${REL_LINKER_FLAGS}" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ALL_C_FLAGS}" )
set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${REL_C_FLAGS}" )
set( CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} ${REL_C_FLAGS}" )
set( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${REL_C_FLAGS}" )
set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${DEB_C_FLAGS} -D_DEBUG" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ALL_C_FLAGS}" )
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${REL_C_FLAGS}" )
set( CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} ${REL_C_FLAGS}" )
set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${REL_C_FLAGS}" )
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DEB_C_FLAGS} -D_DEBUG" )
add_executable( zdbsp ${SOURCES} )
target_link_libraries( zdbsp ${ZDBSP_LIBS} ${PROF_LIB} )
include_directories( "${ZLIB_INCLUDE_DIR}" )

112
Makefile
View file

@ -1,112 +0,0 @@
CC = gcc
CXX = g++
CFLAGS = -Wall -Izlib -pipe -ffast-math -MMD
# Optimization flags
CFLAGS += -O3 -fomit-frame-pointer -DNDEBUG
# Unoptimization flags
#CFLAGS += -g -D_DEBUG
# Processor features flags
CFLAGS += -mtune=i686
#CFLAGS += -march=k8
LDFLAGS =
RM = rm -f FILE
ZLIBDIR = zlib/
ifeq (Windows_NT,$(OS))
EXE = zdbsp.exe
LDFLAGS += -luser32 -lgdi32 -static-libstdc++ -static-libgcc
ifneq (msys,$(OSTYPE))
RM = del /q /f FILE 2>nul
ZLIBDIR = "zlib\"
endif
else
EXE = zdbsp
CFLAGS += -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -DNO_MAP_VIEWER=1
endif
# To generate profiling information for gprof, pass gprof=1 to make.
ifeq ($(gprof),1)
CFLAGS += -g -fno-omit-frame-pointer -pg
LDFLAGS += -g -pg
endif
# To strip debugging symbols, pass strip=1 to make.
ifeq ($(strip),1)
LDFLAGS += -s
endif
# To compile without support for backpatching ClassifyLine calls, pass nobackpatch=1 to make.
ifeq ($(nobackpatch),1)
CFLAGS += -DDISABLE_BACKPATCH
endif
# To use SSE2 math for everything, pass sse=1 to make.
ifeq ($(sse),1)
CFLAGS += -msse2 -mfpmath=sse
endif
OBJS = main.o getopt.o getopt1.o blockmapbuilder.o processor.o processor_udmf.o sc_man.o view.o wad.o \
nodebuild.o nodebuild_events.o nodebuild_extract.o nodebuild_gl.o \
nodebuild_utility.o nodebuild_classify_nosse2.o \
zlib/adler32.o zlib/compress.o zlib/crc32.o zlib/deflate.o zlib/trees.o \
zlib/zutil.o
# To compile without any SSE support, pass nosse=1 to make.
ifeq ($(nosse),1)
CFLAGS += -DDISABLE_SSE
else
OBJS += nodebuild_classify_sse1.o nodebuild_classify_sse2.o
endif
CXXFLAGS = $(CFLAGS)
ifeq (Windows_NT,$(OS))
OBJS += resource.o
endif
all: $(EXE)
profile:
$(MAKE) cleanall
$(MAKE) all CFLAGS="$(CFLAGS) -fprofile-generate" LDFLAGS="$(LDFLAGS) -lgcov"
@echo "Process a few maps, then rebuild with make profile-use"
profile-use:
$(MAKE) clean
$(MAKE) all CXXFLAGS="$(CXXFLAGS) -fprofile-use"
$(EXE): $(OBJS)
$(CXX) -o $(EXE) $(OBJS) $(LDFLAGS)
nodebuild_classify_sse2.o: nodebuild_classify_sse2.cpp nodebuild.h
$(CXX) $(CXXFLAGS) -msse -msse2 -march=i686 -mfpmath=sse -c -o $@ $<
nodebuild_classify_sse1.o: nodebuild_classify_sse1.cpp nodebuild.h
$(CXX) $(CXXFLAGS) -msse -march=i686 -mfpmath=sse -c -o $@ $<
resource.o: resource.rc
windres -o $@ -i $<
.PHONY: clean
clean:
$(subst FILE,$(EXE),$(RM))
$(subst FILE,*.o,$(RM))
$(subst FILE,*.d,$(RM))
$(subst FILE,$(ZLIBDIR)*.o,$(RM))
$(subst FILE,$(ZLIBDIR)*.d,$(RM))
cleanprof:
$(subst FILE,*.gc*,$(RM))
$(subst FILE,$(ZLIBDIR)*.gc*,$(RM))
cleanall: clean cleanprof
ifneq ($(MAKECMDGOALS),clean)
-include $(OBJS:%.o=%.d)
endif

View file

@ -1,5 +1,4 @@
#include <math.h>
#include <xmmintrin.h>
#include "doomdata.h"
#include "workdata.h"
#include "tarray.h"
@ -70,14 +69,11 @@ class FNodeBuilder
};
struct FPrivVert
{
union
{
struct { fixed_t x, y; };
__m64 p64;
};
fixed_t x, y;
DWORD segs; // segs that use this vertex as v1
DWORD segs2; // segs that use this vertex as v2
int index;
int pad; // This structure must be 8-byte aligned.
bool operator== (const FPrivVert &other)
{

View file

@ -6,7 +6,6 @@
#endif
#include "zdbsp.h"
#include <xmmintrin.h>
struct vertex_t
{
@ -15,16 +14,7 @@ struct vertex_t
struct node_t
{
union
{
struct { fixed_t x, y; };
__m64 p64;
};
union
{
struct { fixed_t dx, dy; };
__m64 d64;
};
fixed_t x, y, dx, dy;
fixed_t bbox[2][4];
unsigned int intchildren[2];
};

View file

@ -1,24 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zdbsp", "zdbsp.vcproj", "{3C32111E-76E8-47C9-95A6-A103C861F45F}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
Release (SSE2) = Release (SSE2)
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{3C32111E-76E8-47C9-95A6-A103C861F45F}.Debug.ActiveCfg = Debug|Win32
{3C32111E-76E8-47C9-95A6-A103C861F45F}.Debug.Build.0 = Debug|Win32
{3C32111E-76E8-47C9-95A6-A103C861F45F}.Release.ActiveCfg = Release|Win32
{3C32111E-76E8-47C9-95A6-A103C861F45F}.Release.Build.0 = Release|Win32
{3C32111E-76E8-47C9-95A6-A103C861F45F}.Release (SSE2).ActiveCfg = Release (SSE2)|Win32
{3C32111E-76E8-47C9-95A6-A103C861F45F}.Release (SSE2).Build.0 = Release (SSE2)|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View file

@ -1,32 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual C++ Express 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zdbsp_vs2005", "zdbsp_vs2005.vcproj", "{E628034A-AE64-43B5-8CF4-668D07041C35}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release (SSE2)|Win32 = Release (SSE2)|Win32
Release (SSE2)|x64 = Release (SSE2)|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E628034A-AE64-43B5-8CF4-668D07041C35}.Debug|Win32.ActiveCfg = Debug|Win32
{E628034A-AE64-43B5-8CF4-668D07041C35}.Debug|Win32.Build.0 = Debug|Win32
{E628034A-AE64-43B5-8CF4-668D07041C35}.Debug|x64.ActiveCfg = Debug|x64
{E628034A-AE64-43B5-8CF4-668D07041C35}.Debug|x64.Build.0 = Debug|x64
{E628034A-AE64-43B5-8CF4-668D07041C35}.Release (SSE2)|Win32.ActiveCfg = Release, SSE2|Win32
{E628034A-AE64-43B5-8CF4-668D07041C35}.Release (SSE2)|Win32.Build.0 = Release, SSE2|Win32
{E628034A-AE64-43B5-8CF4-668D07041C35}.Release (SSE2)|x64.ActiveCfg = Release, SSE2|x64
{E628034A-AE64-43B5-8CF4-668D07041C35}.Release (SSE2)|x64.Build.0 = Release, SSE2|x64
{E628034A-AE64-43B5-8CF4-668D07041C35}.Release|Win32.ActiveCfg = Release|Win32
{E628034A-AE64-43B5-8CF4-668D07041C35}.Release|Win32.Build.0 = Release|Win32
{E628034A-AE64-43B5-8CF4-668D07041C35}.Release|x64.ActiveCfg = Release|x64
{E628034A-AE64-43B5-8CF4-668D07041C35}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

File diff suppressed because it is too large Load diff

14
zlib/CMakeLists.txt Normal file
View file

@ -0,0 +1,14 @@
cmake_minimum_required( VERSION 2.4 )
if( CMAKE_COMPILER_IS_GNUC )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fomit-frame-pointer" )
endif( CMAKE_COMPILER_IS_GNUC )
add_library( z
adler32.c
compress.c
crc32.c
deflate.c
trees.c
zutil.c )
target_link_libraries( z )