-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tested with Visual Studio 2013 and 2015 on Windows, other platforms may still need work.
- Loading branch information
Christoph Oelckers
committed
Nov 10, 2016
0 parents
commit 2bafaae
Showing
12 changed files
with
4,865 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
cmake_minimum_required( VERSION 2.4 ) | ||
if( COMMAND cmake_policy ) | ||
cmake_policy( SET CMP0003 NEW ) | ||
endif( COMMAND cmake_policy ) | ||
|
||
include( CheckFunctionExists ) | ||
include( CheckCXXCompilerFlag ) | ||
|
||
project( WADEXT ) | ||
|
||
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 ) | ||
|
||
if( CMAKE_COMPILER_IS_GNUCXX ) | ||
set( GPROF 0 CACHE BOOL "Enable profiling with gprof for Debug and RelWithDebInfo build types." ) | ||
set( PROFILE 0 CACHE INT "1=Generate profile coverage info, 2=Use it" ) | ||
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( WIN32 AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) | ||
# set( ALL_C_FLAGS "${ALL_C_FLAGS} -Wno-deprecated-declarations -Wno-format" ) | ||
#endif( WIN32 AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) | ||
|
||
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( WADEXT_LIBS "${ZLIB_LIBRARIES}" ) | ||
|
||
set( HEADERS | ||
fileformat.h | ||
resourcefile.h | ||
tarray.h | ||
wadext.h | ||
wadman.h | ||
) | ||
|
||
set( SOURCES | ||
convert.cpp | ||
fileformat.cpp | ||
main.cpp | ||
wadext.cpp | ||
wadfile.cpp | ||
) | ||
|
||
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( wadext ${SOURCES} ${HEADERS} ) | ||
target_link_libraries( wadext ${WADEXT_LIBS} ${PROF_LIB} ) | ||
include_directories( "${ZLIB_INCLUDE_DIR}" ) |
Oops, something went wrong.