Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
9d9912de49 | ||
|
5ff2493004 | ||
|
690794537a | ||
|
e1f864cf54 | ||
|
cc17d0dbca | ||
|
fa8b908458 |
259
CMakeLists.txt
Normal file
259
CMakeLists.txt
Normal file
@ -0,0 +1,259 @@
|
||||
project(powder)
|
||||
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
# TODO: mingw windres?
|
||||
# Force 32/64
|
||||
# Stable, release flags
|
||||
# OpenGL
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
|
||||
|
||||
file(GLOB powder_SRC
|
||||
"src/elements/*.cpp"
|
||||
"src/*.cpp"
|
||||
"src/*/*.cpp"
|
||||
"src/*/*/*.cpp"
|
||||
"generated/*.cpp"
|
||||
)
|
||||
|
||||
# TODO: remove this once everything is C++, this is needed because the C++ stuff interacts with stuff in .c files and not all the headers for .c files have extern "C"
|
||||
set_source_files_properties(${powder_SRC} PROPERTIES LANGUAGE CXX )
|
||||
|
||||
include_directories(includes)
|
||||
include_directories(data)
|
||||
include_directories(generated)
|
||||
include_directories(resources)
|
||||
include_directories(src)
|
||||
add_executable(powder ${powder_SRC})
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
add_definitions(-D_64BIT)
|
||||
endif()
|
||||
|
||||
option(Renderer "Compiles TPT for site previews rendering" OFF)
|
||||
if(Renderer)
|
||||
add_definitions(-DRENDERER)
|
||||
else()
|
||||
add_definitions(-DUSE_SDL)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
add_definitions(-DLIN)
|
||||
add_definitions(-DLINUX)
|
||||
endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
add_definitions(-DWIN32)
|
||||
add_definitions(-DWINDOWS)
|
||||
endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
add_definitions(-DMACOSX)
|
||||
#TODO: Include SDLMain.h and SDLMain.m
|
||||
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
|
||||
|
||||
option(PreferStatic "Prefer linking to static libraries in most cases" ON)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES_ORIG ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES_ONLY_STATIC .a;)
|
||||
|
||||
|
||||
if(PreferStatic AND (${CMAKE_SYSTEM_NAME} MATCHES "Windows"))
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -static-libstdc++ -static-libgcc")
|
||||
endif(CMAKE_COMPILER_IS_GNUCC)
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -static-libstdc++ -static-libgcc")
|
||||
endif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
endif(PreferStatic AND (${CMAKE_SYSTEM_NAME} MATCHES "Windows"))
|
||||
|
||||
|
||||
if(PreferStatic)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_ONLY_STATIC})
|
||||
find_package(GnuRegex)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_ORIG})
|
||||
endif(PreferStatic)
|
||||
if(NOT GNUREGEX_FOUND)
|
||||
find_package(GnuRegex REQUIRED)
|
||||
endif(NOT GNUREGEX_FOUND)
|
||||
include_directories(${GNUREGEX_INCLUDE_DIR})
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
target_link_libraries(powder ${GNUREGEX_LIBRARIES})
|
||||
endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(powder ${CMAKE_THREAD_LIBS_INIT})
|
||||
|
||||
|
||||
option(GravityFFT "Enable FFTs for Newtonian gravity (makes it faster)" ON)
|
||||
if (GravityFFT)
|
||||
if(PreferStatic)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_ONLY_STATIC})
|
||||
find_package(FFTW3F)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_ORIG})
|
||||
endif(PreferStatic)
|
||||
if(NOT FFTW3F_FOUND)
|
||||
find_package(FFTW3F)
|
||||
endif(NOT FFTW3F_FOUND)
|
||||
if (FFTW3F_FOUND)
|
||||
include_directories(${FFTW3F_INCLUDE_DIR})
|
||||
target_link_libraries(powder ${FFTW3F_LIBRARIES})
|
||||
add_definitions(-DGRAVFFT)
|
||||
else (FFTW3F_FOUND)
|
||||
message(STATUS "Package FFTW3F not found, compiling without FFTs for Newtonian gravity")
|
||||
endif (FFTW3F_FOUND)
|
||||
endif (GravityFFT)
|
||||
|
||||
|
||||
# lm
|
||||
|
||||
if(PreferStatic)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_ONLY_STATIC})
|
||||
find_package(BZip2)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_ORIG})
|
||||
endif(PreferStatic)
|
||||
if(NOT BZIP2_FOUND)
|
||||
find_package(BZip2 REQUIRED)
|
||||
endif(NOT BZIP2_FOUND)
|
||||
include_directories(${BZIP2_INCLUDE_DIR})
|
||||
target_link_libraries(powder ${BZIP2_LIBRARIES})
|
||||
|
||||
# zlib
|
||||
|
||||
if(PreferStatic)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_ONLY_STATIC})
|
||||
find_package(ZLIB)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_ORIG})
|
||||
endif(PreferStatic)
|
||||
if(NOT ZLIB_FOUND)
|
||||
find_package(ZLIB REQUIRED)
|
||||
endif(NOT ZLIB_FOUND)
|
||||
include_directories(${ZLIB_INCLUDE_DIR})
|
||||
target_link_libraries(powder ${ZLIB_LIBRARIES})
|
||||
|
||||
|
||||
option(LuaConsole "Enable Lua console" ON)
|
||||
if (LuaConsole)
|
||||
if(PreferStatic)
|
||||
IF(UNIX AND NOT APPLE)
|
||||
# For Linux, find maths library first, because otherwise find_package(Lua51) will fail to find the static Lua library if there isn't a static libm
|
||||
find_library(LUA_MATH_LIBRARY m)
|
||||
ENDIF(UNIX AND NOT APPLE)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_ONLY_STATIC})
|
||||
find_package(Lua51)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_ORIG})
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
if(LUA51_FOUND)
|
||||
FIND_LIBRARY(LUA_EXTRA_LIBS dl)
|
||||
if(LUA_EXTRA_LIBS STREQUAL "LUA_EXTRA_LIBS-NOTFOUND")
|
||||
message(STATUS "Could not find libdl, trying dynamic lua51")
|
||||
unset(LUA51_FOUND)
|
||||
unset(LUA_LIBRARY CACHE)
|
||||
unset(LUA_LIBRARIES CACHE)
|
||||
endif()
|
||||
endif(LUA51_FOUND)
|
||||
else(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
set(LUA_EXTRA_LIBS "")
|
||||
endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
endif(PreferStatic)
|
||||
if(NOT LUA51_FOUND)
|
||||
find_package(Lua51)
|
||||
set(LUA_EXTRA_LIBS "")
|
||||
endif(NOT LUA51_FOUND)
|
||||
if (LUA51_FOUND)
|
||||
include_directories(${LUA_INCLUDE_DIR})
|
||||
target_link_libraries(powder ${LUA_LIBRARIES};${LUA_EXTRA_LIBS})
|
||||
add_definitions(-DLUACONSOLE)
|
||||
else (LUA51_FOUND)
|
||||
message(STATUS "Package lua51 not found, compiling without Lua console")
|
||||
endif (LUA51_FOUND)
|
||||
endif (LuaConsole)
|
||||
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
find_package(ClockGettime REQUIRED)
|
||||
include_directories(${CLOCK_GETTIME_INCLUDE_DIR})
|
||||
target_link_libraries(powder ${CLOCK_GETTIME_LIBRARIES})
|
||||
endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
find_package(X11 REQUIRED)
|
||||
include_directories(${X11_X11_INCLUDE_PATH})
|
||||
target_link_libraries(powder ${X11_X11_LIB})
|
||||
endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
find_package(Winsock REQUIRED)
|
||||
include_directories(${WINSOCK_INCLUDE_DIR})
|
||||
target_link_libraries(powder ${WINSOCK_LIBRARIES})
|
||||
endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
|
||||
# SDL
|
||||
|
||||
if(PreferStatic)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_ONLY_STATIC})
|
||||
find_package(SDL)
|
||||
if(SDL_FOUND)
|
||||
find_package(SDL_static_extra)
|
||||
if(NOT SDL_STATIC_EXTRA_LIBRARIES)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_ORIG})
|
||||
find_package(SDL_static_extra REQUIRED)
|
||||
endif(NOT SDL_STATIC_EXTRA_LIBRARIES)
|
||||
if(SDL_STATIC_EXTRA_LIBRARIES)
|
||||
include_directories(${SDL_INCLUDE_DIR})
|
||||
target_link_libraries(powder ${SDL_LIBRARY})
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
target_link_libraries(powder ${SDL_STATIC_EXTRA_LIBRARIES})
|
||||
endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
else()
|
||||
set(SDL_FOUND false)
|
||||
endif()
|
||||
endif(SDL_FOUND)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_ORIG})
|
||||
endif(PreferStatic)
|
||||
if(NOT SDL_FOUND)
|
||||
find_package(SDL REQUIRED)
|
||||
include_directories(${SDL_INCLUDE_DIR})
|
||||
target_link_libraries(powder ${SDL_LIBRARY})
|
||||
endif(NOT SDL_FOUND)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98 -fkeep-inline-functions")
|
||||
|
||||
option(Optimisations "Enable optimisations" ON)
|
||||
if (Optimisations)
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -ffast-math -ftree-vectorize -funsafe-math-optimizations")
|
||||
endif(CMAKE_COMPILER_IS_GNUCC)
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -ffast-math -ftree-vectorize -funsafe-math-optimizations")
|
||||
endif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
endif(Optimisations)
|
||||
|
||||
option(Debug "Enable debug symbols" ON)
|
||||
if (Debug)
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
|
||||
endif(CMAKE_COMPILER_IS_GNUCC)
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
|
||||
endif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
endif(Debug)
|
||||
|
||||
option(NoWarnings "Disable compiler warnings" ON)
|
||||
if (NoWarnings)
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
|
||||
endif(CMAKE_COMPILER_IS_GNUCC)
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
|
||||
endif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
else(NoWarnings)
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
|
||||
endif(CMAKE_COMPILER_IS_GNUCC)
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||
endif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
endif(NoWarnings)
|
324
SConscript
324
SConscript
@ -1,324 +0,0 @@
|
||||
import os, sys, subprocess, time
|
||||
|
||||
|
||||
##Fix for long command line - http://scons.org/wiki/LongCmdLinesOnWin32
|
||||
class ourSpawn:
|
||||
def ourspawn(self, sh, escape, cmd, args, env):
|
||||
newargs = ' '.join(args[1:])
|
||||
cmdline = cmd + " " + newargs
|
||||
startupinfo = subprocess.STARTUPINFO()
|
||||
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||
proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, startupinfo=startupinfo, shell = False, env = env)
|
||||
data, err = proc.communicate()
|
||||
rv = proc.wait()
|
||||
if rv:
|
||||
print "====="
|
||||
print err
|
||||
print "====="
|
||||
return rv
|
||||
|
||||
def SetupSpawn( env ):
|
||||
if sys.platform == 'win32':
|
||||
buf = ourSpawn()
|
||||
buf.ourenv = env
|
||||
env['SPAWN'] = buf.ourspawn
|
||||
|
||||
AddOption('--opengl',dest="opengl",action='store_true',default=False,help="Build with OpenGL interface support.")
|
||||
AddOption('--opengl-renderer',dest="opengl-renderer",action='store_true',default=False,help="Build with OpenGL renderer support. (requires --opengl)")
|
||||
AddOption('--renderer',dest="renderer",action='store_true',default=False,help="Save renderer")
|
||||
AddOption('--win',dest="win",action='store_true',default=False,help="Windows platform target.")
|
||||
AddOption('--lin',dest="lin",action='store_true',default=False,help="Linux platform target")
|
||||
AddOption('--macosx',dest="macosx",action='store_true',default=False,help="Mac OS X platform target")
|
||||
AddOption('--rpi',dest="rpi",action='store_true',default=False,help="Raspbain platform target")
|
||||
AddOption('--64bit',dest="_64bit",action='store_true',default=False,help="64-bit platform target")
|
||||
AddOption('--static',dest="static",action="store_true",default=False,help="Static linking, reduces external library dependancies but increased file size")
|
||||
AddOption('--pthreadw32-static',dest="ptw32-static",action="store_true",default=False,help="Use PTW32_STATIC_LIB for pthreadw32 headers")
|
||||
AddOption('--python-ver',dest="pythonver",default=False,help="Python version to use for generator.py")
|
||||
AddOption('--release',dest="release",action='store_true',default=False,help="Enable optimisations (Will slow down compiling)")
|
||||
AddOption('--lua-dir',dest="lua-dir",default=False,help="Directory for lua includes")
|
||||
AddOption('--sdl-dir',dest="sdl-dir",default=False,help="Directory for SDL includes")
|
||||
AddOption('--tool',dest="toolprefix",default=False,help="Prefix")
|
||||
AddOption('--sse',dest="sse",action='store_true',default=False,help="Enable SSE optimisations")
|
||||
AddOption('--sse2',dest="sse2",action='store_true',default=False,help="Enable SSE2 optimisations")
|
||||
AddOption('--sse3',dest="sse3",action='store_true',default=False,help="Enable SSE3 optimisations")
|
||||
AddOption('--x86',dest="x86",action='store_true',default=True,help="Target Intel x86 platform")
|
||||
|
||||
AddOption('--debugging', dest="debug", action="store_true", default=False, help="Enable debug options")
|
||||
AddOption('--beta',dest="beta",action='store_true',default=False,help="Beta build.")
|
||||
AddOption('--save-version',dest="save-version",default=False,help="Save version.")
|
||||
AddOption('--minor-version',dest="minor-version",default=False,help="Minor version.")
|
||||
AddOption('--build-number',dest="build-number",default=False,help="Build number.")
|
||||
AddOption('--snapshot',dest="snapshot",action='store_true',default=False,help="Snapshot build.")
|
||||
AddOption('--snapshot-id',dest="snapshot-id",default=False,help="Snapshot build ID.")
|
||||
AddOption('--stable',dest="stable",default=True,help="Non snapshot build")
|
||||
|
||||
AddOption('--aao', dest="everythingAtOnce", action='store_true', default=False, help="Compile the whole game without generating intermediate objects (very slow), enable this when using compilers like clang or mscc that don't support -fkeep-inline-functions")
|
||||
|
||||
if((not GetOption('lin')) and (not GetOption('win')) and (not GetOption('rpi')) and (not GetOption('macosx'))):
|
||||
print "You must specify a platform to target"
|
||||
raise SystemExit(1)
|
||||
|
||||
if(GetOption('win')):
|
||||
env = Environment(tools = ['mingw'], ENV = os.environ)
|
||||
else:
|
||||
env = Environment(tools = ['default'], ENV = os.environ)
|
||||
|
||||
if GetOption("toolprefix"):
|
||||
env['CC'] = GetOption("toolprefix")+env['CC']
|
||||
env['CXX'] = GetOption("toolprefix")+env['CXX']
|
||||
if GetOption('win'):
|
||||
env['RC'] = GetOption("toolprefix")+env['RC']
|
||||
|
||||
#Check for headers and libraries
|
||||
if not GetOption("macosx"):
|
||||
conf = Configure(env)
|
||||
|
||||
try:
|
||||
env.ParseConfig('sdl-config --cflags')
|
||||
env.ParseConfig('sdl-config --libs')
|
||||
except:
|
||||
if not conf.CheckLib("SDL"):
|
||||
print "libSDL not found or not installed"
|
||||
raise SystemExit(1)
|
||||
|
||||
if(GetOption("sdl-dir")):
|
||||
if not conf.CheckCHeader(GetOption("sdl-dir") + '/SDL.h'):
|
||||
print "sdl headers not found or not installed"
|
||||
raise SystemExit(1)
|
||||
else:
|
||||
env.Append(CPPPATH=[GetOption("sdl-dir")])
|
||||
|
||||
#Find correct lua include dir
|
||||
try:
|
||||
env.ParseConfig('pkg-config --cflags lua5.1')
|
||||
except:
|
||||
if(GetOption("lua-dir")):
|
||||
if not conf.CheckCHeader(GetOption("lua-dir") + '/lua.h'):
|
||||
print "lua5.1 headers not found or not installed"
|
||||
raise SystemExit(1)
|
||||
else:
|
||||
env.Append(CPPPATH=[GetOption("lua-dir")])
|
||||
|
||||
#Check for FFT lib
|
||||
if not conf.CheckLib('fftw3f') and not conf.CheckLib('fftw3f-3'):
|
||||
print "libfftw3f not found or not installed"
|
||||
raise SystemExit(1)
|
||||
|
||||
#Check for Bzip lib
|
||||
if not conf.CheckLib('bz2'):
|
||||
print "libbz2 not found or not installed"
|
||||
raise SystemExit(1)
|
||||
|
||||
#Check for zlib
|
||||
if not conf.CheckLib('z'):
|
||||
print "libz not found or not installed"
|
||||
raise SystemExit(1)
|
||||
|
||||
if not conf.CheckCHeader("bzlib.h"):
|
||||
print "bzip2 headers not found"
|
||||
raise SystemExit(1)
|
||||
|
||||
#Check for Lua lib
|
||||
if not GetOption("macosx"):
|
||||
if not conf.CheckLib('lua5.1') and not conf.CheckLib('lua-5.1') and not conf.CheckLib('lua51') and not conf.CheckLib('lua'):
|
||||
print "liblua not found or not installed"
|
||||
raise SystemExit(1)
|
||||
|
||||
env = conf.Finish();
|
||||
else:
|
||||
env.Append(LIBS=['z', 'bz2', 'fftw3f'])
|
||||
|
||||
env.Append(CPPPATH=['src/', 'data/', 'generated/'])
|
||||
env.Append(CCFLAGS=['-w', '-std=c++98', '-fkeep-inline-functions'])
|
||||
env.Append(LIBS=['pthread', 'm'])
|
||||
env.Append(CPPDEFINES=["LUACONSOLE", "GRAVFFT", "_GNU_SOURCE", "USE_STDINT", "_POSIX_C_SOURCE=200112L"])
|
||||
|
||||
if GetOption("ptw32-static"):
|
||||
env.Append(CPPDEFINES=['PTW32_STATIC_LIB']);
|
||||
|
||||
if(GetOption('static')):
|
||||
env.Append(LINKFLAGS=['-static-libgcc'])
|
||||
|
||||
if(GetOption('renderer')):
|
||||
env.Append(CPPDEFINES=['RENDERER'])
|
||||
else:
|
||||
env.Append(CPPDEFINES=["USE_SDL"])
|
||||
|
||||
if(GetOption('rpi')):
|
||||
if(GetOption('opengl')):
|
||||
env.ParseConfig('pkg-config --libs glew gl glu')
|
||||
openGLLibs = ['GL']
|
||||
env.Append(LIBS=['X11', 'rt'])
|
||||
env.Append(CPPDEFINES=["LIN"])
|
||||
|
||||
if(GetOption('win')):
|
||||
openGLLibs = ['opengl32', 'glew32']
|
||||
env.Prepend(LIBS=['mingw32', 'ws2_32', 'SDLmain', 'regex'])
|
||||
env.Append(CCFLAGS=['-std=gnu++98'])
|
||||
env.Append(LIBS=['winmm', 'gdi32'])
|
||||
env.Append(CPPDEFINES=["WIN"])
|
||||
env.Append(LINKFLAGS=['-mwindows'])
|
||||
if(GetOption('_64bit')):
|
||||
env.Append(CPPDEFINES=['__CRT__NO_INLINE'])
|
||||
env.Append(LINKFLAGS=['-Wl,--stack=16777216'])
|
||||
if(GetOption('lin')):
|
||||
if(GetOption('opengl')):
|
||||
env.ParseConfig('pkg-config --libs glew gl glu')
|
||||
openGLLibs = ['GL']
|
||||
env.Append(LIBS=['X11', 'rt'])
|
||||
env.Append(CPPDEFINES=["LIN"])
|
||||
if GetOption('_64bit'):
|
||||
env.Append(LINKFLAGS=['-m64'])
|
||||
env.Append(CCFLAGS=['-m64'])
|
||||
else:
|
||||
env.Append(LINKFLAGS=['-m32'])
|
||||
env.Append(CCFLAGS=['-m32'])
|
||||
if(GetOption('macosx')):
|
||||
env.Append(CPPDEFINES=["MACOSX"])
|
||||
env.Append(CCFLAGS=['-I/Library/Frameworks/SDL.framework/Headers'])
|
||||
env.Append(CCFLAGS=['-I/Library/Frameworks/Lua.framework/Headers'])
|
||||
env.Append(LINKFLAGS=['-lfftw3f'])
|
||||
env.Append(LINKFLAGS=['-framework'])
|
||||
env.Append(LINKFLAGS=['SDL'])
|
||||
env.Append(LINKFLAGS=['-framework'])
|
||||
env.Append(LINKFLAGS=['Lua'])
|
||||
env.Append(LINKFLAGS=['-framework']);
|
||||
env.Append(LINKFLAGS=['Cocoa'])
|
||||
#env.Append(LINKFLAGS=['-framework SDL'])
|
||||
#env.Append(LINKFLAGS=['-framework Lua'])
|
||||
#env.Append(LINKFLAGS=['-framework Cocoa'])
|
||||
if GetOption('_64bit'):
|
||||
env.Append(LINKFLAGS=['-m64'])
|
||||
env.Append(CCFLAGS=['-m64'])
|
||||
else:
|
||||
env.Append(LINKFLAGS=['-m32'])
|
||||
env.Append(CCFLAGS=['-m32'])
|
||||
|
||||
if GetOption('_64bit'):
|
||||
env.Append(CPPDEFINES=["_64BIT"])
|
||||
|
||||
if(GetOption('beta')):
|
||||
env.Append(CPPDEFINES='BETA')
|
||||
|
||||
|
||||
if(not GetOption('snapshot') and not GetOption('beta') and not GetOption('release') and not GetOption('stable')):
|
||||
env.Append(CPPDEFINES='SNAPSHOT_ID=0')
|
||||
env.Append(CPPDEFINES='SNAPSHOT')
|
||||
elif(GetOption('snapshot') or GetOption('snapshot-id')):
|
||||
if(GetOption('snapshot-id')):
|
||||
env.Append(CPPDEFINES=['SNAPSHOT_ID=' + GetOption('snapshot-id')])
|
||||
else:
|
||||
env.Append(CPPDEFINES=['SNAPSHOT_ID=' + str(int(time.time()))])
|
||||
env.Append(CPPDEFINES='SNAPSHOT')
|
||||
elif(GetOption('stable')):
|
||||
env.Append(CPPDEFINES='STABLE')
|
||||
|
||||
if(GetOption('save-version')):
|
||||
env.Append(CPPDEFINES=['SAVE_VERSION=' + GetOption('save-version')])
|
||||
|
||||
if(GetOption('minor-version')):
|
||||
env.Append(CPPDEFINES=['MINOR_VERSION=' + GetOption('minor-version')])
|
||||
|
||||
if(GetOption('build-number')):
|
||||
env.Append(CPPDEFINES=['BUILD_NUM=' + GetOption('build-number')])
|
||||
|
||||
if(GetOption('x86')):
|
||||
env.Append(CPPDEFINES='X86')
|
||||
|
||||
if(GetOption('debug')):
|
||||
env.Append(CPPDEFINES='DEBUG')
|
||||
env.Append(CCFLAGS='-g')
|
||||
|
||||
if(GetOption('sse')):
|
||||
env.Append(CCFLAGS='-msse')
|
||||
env.Append(CPPDEFINES='X86_SSE')
|
||||
|
||||
if(GetOption('sse2')):
|
||||
env.Append(CCFLAGS='-msse2')
|
||||
env.Append(CPPDEFINES='X86_SSE2')
|
||||
|
||||
if(GetOption('sse3')):
|
||||
env.Append(CCFLAGS='-msse3')
|
||||
env.Append(CPPDEFINES='X86_SSE3')
|
||||
|
||||
if(GetOption('opengl')):
|
||||
env.Append(CPPDEFINES=["OGLI", "PIX32OGL"])
|
||||
env.Append(LIBS=openGLLibs)
|
||||
|
||||
if(GetOption('opengl') and GetOption('opengl-renderer')):
|
||||
env.Append(CPPDEFINES=["OGLR"])
|
||||
elif(GetOption('opengl-renderer')):
|
||||
print "opengl-renderer requires opengl"
|
||||
raise SystemExit(1)
|
||||
|
||||
sources=Glob("src/*.cpp")
|
||||
if(GetOption('macosx')):
|
||||
sources +=["SDLMain.m"]
|
||||
if(GetOption('win')):
|
||||
sources += env.RES('resources/powder-res.rc')
|
||||
sources+=Glob("src/*/*.cpp")
|
||||
sources+=Glob("src/simulation/elements/*.cpp")
|
||||
sources+=Glob("src/simulation/tools/*.cpp")
|
||||
sources+=Glob("src/client/requestbroker/*.cpp")
|
||||
|
||||
#for source in sources:
|
||||
# print str(source)
|
||||
|
||||
if(GetOption('win')):
|
||||
sources = filter(lambda source: not 'src\\simulation\\Gravity.cpp' in str(source), sources)
|
||||
sources = filter(lambda source: not 'src/simulation/Gravity.cpp' in str(source), sources)
|
||||
|
||||
SetupSpawn(env)
|
||||
|
||||
programName = "powder"
|
||||
|
||||
if(GetOption('renderer')):
|
||||
programName = "render"
|
||||
|
||||
if(GetOption('win')):
|
||||
if(GetOption('renderer')):
|
||||
programName = "Render"
|
||||
else:
|
||||
programName = "Powder"
|
||||
|
||||
if(GetOption('_64bit')):
|
||||
programName += "64"
|
||||
|
||||
if(not (GetOption('sse2') or GetOption('sse3'))):
|
||||
programName += "-legacy"
|
||||
|
||||
if(GetOption('macosx')):
|
||||
programName += "-x"
|
||||
|
||||
if(GetOption('win')):
|
||||
programName += ".exe"
|
||||
|
||||
if(GetOption('release')):
|
||||
if GetOption('macosx'):
|
||||
env.Append(CCFLAGS=['-O3', '-ftree-vectorize', '-funsafe-math-optimizations', '-ffast-math', '-fomit-frame-pointer'])
|
||||
else:
|
||||
env.Append(CCFLAGS=['-O3', '-ftree-vectorize', '-funsafe-math-optimizations', '-ffast-math', '-fomit-frame-pointer', '-funsafe-loop-optimizations', '-Wunsafe-loop-optimizations'])
|
||||
|
||||
|
||||
if(GetOption('pythonver')):
|
||||
pythonVer = GetOption('pythonver')
|
||||
elif(GetOption('lin')):
|
||||
pythonVer = "python2"
|
||||
else:
|
||||
pythonVer = "python"
|
||||
|
||||
if(GetOption('win')):
|
||||
envCopy = env.Clone()
|
||||
envCopy.Append(CCFLAGS=['-mincoming-stack-boundary=2'])
|
||||
sources+=envCopy.Object('src/simulation/Gravity.cpp')
|
||||
|
||||
env.Command(['generated/ElementClasses.cpp', 'generated/ElementClasses.h'], Glob('src/simulation/elements/*.cpp'), pythonVer + " generator.py elements $TARGETS $SOURCES")
|
||||
sources+=Glob("generated/ElementClasses.cpp")
|
||||
|
||||
env.Command(['generated/ToolClasses.cpp', 'generated/ToolClasses.h'], Glob('src/simulation/tools/*.cpp'), pythonVer + " generator.py tools $TARGETS $SOURCES")
|
||||
sources+=Glob("generated/ToolClasses.cpp")
|
||||
|
||||
env.Decider('MD5')
|
||||
t=env.Program(target=programName, source=sources)
|
||||
Default(t)
|
@ -1,2 +0,0 @@
|
||||
AddOption('--builddir',dest="builddir",default="build",help="Directory to build to.")
|
||||
SConscript('SConscript', variant_dir=GetOption('builddir'), duplicate=0)
|
37
cmake/modules/FindClockGettime.cmake
Normal file
37
cmake/modules/FindClockGettime.cmake
Normal file
@ -0,0 +1,37 @@
|
||||
|
||||
include(CheckFunctionExists)
|
||||
|
||||
if(NOT CLOCK_GETTIME_FOUND)
|
||||
check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
|
||||
if(HAVE_CLOCK_GETTIME)
|
||||
set(CLOCK_GETTIME_FOUND TRUE)
|
||||
set(CLOCK_GETTIME_LIBRARIES "")
|
||||
else()
|
||||
message(STATUS "clock_gettime() not found, searching for library")
|
||||
endif()
|
||||
|
||||
if(NOT CLOCK_GETTIME_FOUND)
|
||||
find_path(CLOCK_GETTIME_INCLUDE_DIR
|
||||
NAMES
|
||||
time.h
|
||||
PATHS
|
||||
${LIBRT_PREFIX}/include/
|
||||
)
|
||||
|
||||
find_library(
|
||||
CLOCK_GETTIME_LIBRARIES rt
|
||||
PATHS
|
||||
${LIBRT_PREFIX}/lib/
|
||||
/usr/local/lib64/
|
||||
/usr/local/lib/
|
||||
/usr/lib/i386-linux-gnu/
|
||||
/usr/lib/x86_64-linux-gnu/
|
||||
/usr/lib64/
|
||||
/usr/lib/
|
||||
)
|
||||
|
||||
find_package_handle_standard_args (clock_gettime DEFAULT_MSG CLOCK_GETTIME_LIBRARIES CLOCK_GETTIME_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(CLOCK_GETTIME_LIBRARIES CLOCK_GETTIME_INCLUDE_DIR)
|
||||
endif()
|
||||
endif()
|
16
cmake/modules/FindFFTW3F.cmake
Normal file
16
cmake/modules/FindFFTW3F.cmake
Normal file
@ -0,0 +1,16 @@
|
||||
# - Find FFTW3F
|
||||
# Find the native FFTW includes and library (single precision version)
|
||||
#
|
||||
# FFTW3F_INCLUDE_DIR - where to find fftw3.h
|
||||
# FFTW3F_LIBRARIES - List of libraries when using FFTW.
|
||||
# FFTW3F_FOUND - True if FFTW found.
|
||||
|
||||
find_path (FFTW3F_INCLUDE_DIR fftw3.h)
|
||||
find_library (FFTW3F_LIBRARIES NAMES fftw3f)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set FFTW3F_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
include (FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args (FFTW3F DEFAULT_MSG FFTW3F_LIBRARIES FFTW3F_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced (FFTW3F_LIBRARIES FFTW3F_INCLUDE_DIR)
|
22
cmake/modules/FindGnuRegex.cmake
Normal file
22
cmake/modules/FindGnuRegex.cmake
Normal file
@ -0,0 +1,22 @@
|
||||
# - Find GnuRegex
|
||||
# Find the native GnuRegex includes and library
|
||||
#
|
||||
# GNUREGEX_INCLUDE_DIR - where to find regex.h
|
||||
# GNUREGEX_LIBRARIES - List of libraries when using GnuRegex.
|
||||
# GNUREGEX_FOUND - True if GnuRegex found.
|
||||
|
||||
find_path (GNUREGEX_INCLUDE_DIR regex.h)
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
# Windows, library needed
|
||||
find_library(GNUREGEX_LIBRARIES NAMES regex gnurx)
|
||||
else(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
# library not needed
|
||||
set(GNUREGEX_LIBRARIES TRUE)
|
||||
endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set GNUREGEX_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
include (FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args (GnuRegex DEFAULT_MSG GNUREGEX_LIBRARIES GNUREGEX_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced (GNUREGEX_LIBRARIES GNUREGEX_INCLUDE_DIR)
|
296
cmake/modules/FindPackageHandleStandardArgs.cmake
Normal file
296
cmake/modules/FindPackageHandleStandardArgs.cmake
Normal file
@ -0,0 +1,296 @@
|
||||
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(<name> ... )
|
||||
#
|
||||
# This function is intended to be used in FindXXX.cmake modules files.
|
||||
# It handles the REQUIRED, QUIET and version-related arguments to FIND_PACKAGE().
|
||||
# It also sets the <UPPERCASED_NAME>_FOUND variable.
|
||||
# The package is considered found if all variables <var1>... listed contain
|
||||
# valid results, e.g. valid filepaths.
|
||||
#
|
||||
# There are two modes of this function. The first argument in both modes is
|
||||
# the name of the Find-module where it is called (in original casing).
|
||||
#
|
||||
# The first simple mode looks like this:
|
||||
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(<name> (DEFAULT_MSG|"Custom failure message") <var1>...<varN> )
|
||||
# If the variables <var1> to <varN> are all valid, then <UPPERCASED_NAME>_FOUND
|
||||
# will be set to TRUE.
|
||||
# If DEFAULT_MSG is given as second argument, then the function will generate
|
||||
# itself useful success and error messages. You can also supply a custom error message
|
||||
# for the failure case. This is not recommended.
|
||||
#
|
||||
# The second mode is more powerful and also supports version checking:
|
||||
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME [REQUIRED_VARS <var1>...<varN>]
|
||||
# [VERSION_VAR <versionvar>]
|
||||
# [HANDLE_COMPONENTS]
|
||||
# [CONFIG_MODE]
|
||||
# [FAIL_MESSAGE "Custom failure message"] )
|
||||
#
|
||||
# As above, if <var1> through <varN> are all valid, <UPPERCASED_NAME>_FOUND
|
||||
# will be set to TRUE.
|
||||
# After REQUIRED_VARS the variables which are required for this package are listed.
|
||||
# Following VERSION_VAR the name of the variable can be specified which holds
|
||||
# the version of the package which has been found. If this is done, this version
|
||||
# will be checked against the (potentially) specified required version used
|
||||
# in the find_package() call. The EXACT keyword is also handled. The default
|
||||
# messages include information about the required version and the version
|
||||
# which has been actually found, both if the version is ok or not.
|
||||
# If the package supports components, use the HANDLE_COMPONENTS option to enable
|
||||
# handling them. In this case, find_package_handle_standard_args() will report
|
||||
# which components have been found and which are missing, and the <NAME>_FOUND
|
||||
# variable will be set to FALSE if any of the required components (i.e. not the
|
||||
# ones listed after OPTIONAL_COMPONENTS) are missing.
|
||||
# Use the option CONFIG_MODE if your FindXXX.cmake module is a wrapper for
|
||||
# a find_package(... NO_MODULE) call. In this case VERSION_VAR will be set
|
||||
# to <NAME>_VERSION and the macro will automatically check whether the
|
||||
# Config module was found.
|
||||
# Via FAIL_MESSAGE a custom failure message can be specified, if this is not
|
||||
# used, the default message will be displayed.
|
||||
#
|
||||
# Example for mode 1:
|
||||
#
|
||||
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR)
|
||||
#
|
||||
# LibXml2 is considered to be found, if both LIBXML2_LIBRARY and
|
||||
# LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to TRUE.
|
||||
# If it is not found and REQUIRED was used, it fails with FATAL_ERROR,
|
||||
# independent whether QUIET was used or not.
|
||||
# If it is found, success will be reported, including the content of <var1>.
|
||||
# On repeated Cmake runs, the same message won't be printed again.
|
||||
#
|
||||
# Example for mode 2:
|
||||
#
|
||||
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(BISON REQUIRED_VARS BISON_EXECUTABLE
|
||||
# VERSION_VAR BISON_VERSION)
|
||||
# In this case, BISON is considered to be found if the variable(s) listed
|
||||
# after REQUIRED_VAR are all valid, i.e. BISON_EXECUTABLE in this case.
|
||||
# Also the version of BISON will be checked by using the version contained
|
||||
# in BISON_VERSION.
|
||||
# Since no FAIL_MESSAGE is given, the default messages will be printed.
|
||||
#
|
||||
# Another example for mode 2:
|
||||
#
|
||||
# FIND_PACKAGE(Automoc4 QUIET NO_MODULE HINTS /opt/automoc4)
|
||||
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(Automoc4 CONFIG_MODE)
|
||||
# In this case, FindAutmoc4.cmake wraps a call to FIND_PACKAGE(Automoc4 NO_MODULE)
|
||||
# and adds an additional search directory for automoc4.
|
||||
# The following FIND_PACKAGE_HANDLE_STANDARD_ARGS() call produces a proper
|
||||
# success/error message.
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2007-2009 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
INCLUDE(FindPackageMessage)
|
||||
INCLUDE(CMakeParseArguments)
|
||||
|
||||
# internal helper macro
|
||||
MACRO(_FPHSA_FAILURE_MESSAGE _msg)
|
||||
IF (${_NAME}_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "${_msg}")
|
||||
ELSE (${_NAME}_FIND_REQUIRED)
|
||||
IF (NOT ${_NAME}_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "${_msg}")
|
||||
ENDIF (NOT ${_NAME}_FIND_QUIETLY)
|
||||
ENDIF (${_NAME}_FIND_REQUIRED)
|
||||
ENDMACRO(_FPHSA_FAILURE_MESSAGE _msg)
|
||||
|
||||
|
||||
# internal helper macro to generate the failure message when used in CONFIG_MODE:
|
||||
MACRO(_FPHSA_HANDLE_FAILURE_CONFIG_MODE)
|
||||
# <name>_CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found:
|
||||
IF(${_NAME}_CONFIG)
|
||||
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing: ${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})")
|
||||
ELSE(${_NAME}_CONFIG)
|
||||
# If _CONSIDERED_CONFIGS is set, the config-file has been found, but no suitable version.
|
||||
# List them all in the error message:
|
||||
IF(${_NAME}_CONSIDERED_CONFIGS)
|
||||
SET(configsText "")
|
||||
LIST(LENGTH ${_NAME}_CONSIDERED_CONFIGS configsCount)
|
||||
MATH(EXPR configsCount "${configsCount} - 1")
|
||||
FOREACH(currentConfigIndex RANGE ${configsCount})
|
||||
LIST(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename)
|
||||
LIST(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version)
|
||||
SET(configsText "${configsText} ${filename} (version ${version})\n")
|
||||
ENDFOREACH(currentConfigIndex)
|
||||
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:\n${configsText}")
|
||||
|
||||
ELSE(${_NAME}_CONSIDERED_CONFIGS)
|
||||
# Simple case: No Config-file was found at all:
|
||||
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: found neither ${_NAME}Config.cmake nor ${_NAME_LOWER}-config.cmake ${VERSION_MSG}")
|
||||
ENDIF(${_NAME}_CONSIDERED_CONFIGS)
|
||||
ENDIF(${_NAME}_CONFIG)
|
||||
ENDMACRO(_FPHSA_HANDLE_FAILURE_CONFIG_MODE)
|
||||
|
||||
|
||||
FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG)
|
||||
|
||||
# set up the arguments for CMAKE_PARSE_ARGUMENTS and check whether we are in
|
||||
# new extended or in the "old" mode:
|
||||
SET(options CONFIG_MODE HANDLE_COMPONENTS)
|
||||
SET(oneValueArgs FAIL_MESSAGE VERSION_VAR)
|
||||
SET(multiValueArgs REQUIRED_VARS)
|
||||
SET(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} )
|
||||
LIST(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX)
|
||||
|
||||
IF(${INDEX} EQUAL -1)
|
||||
SET(FPHSA_FAIL_MESSAGE ${_FIRST_ARG})
|
||||
SET(FPHSA_REQUIRED_VARS ${ARGN})
|
||||
SET(FPHSA_VERSION_VAR)
|
||||
ELSE(${INDEX} EQUAL -1)
|
||||
|
||||
CMAKE_PARSE_ARGUMENTS(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN})
|
||||
|
||||
IF(FPHSA_UNPARSED_ARGUMENTS)
|
||||
MESSAGE(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"")
|
||||
ENDIF(FPHSA_UNPARSED_ARGUMENTS)
|
||||
|
||||
IF(NOT FPHSA_FAIL_MESSAGE)
|
||||
SET(FPHSA_FAIL_MESSAGE "DEFAULT_MSG")
|
||||
ENDIF(NOT FPHSA_FAIL_MESSAGE)
|
||||
ENDIF(${INDEX} EQUAL -1)
|
||||
|
||||
# now that we collected all arguments, process them
|
||||
|
||||
IF("${FPHSA_FAIL_MESSAGE}" STREQUAL "DEFAULT_MSG")
|
||||
SET(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}")
|
||||
ENDIF("${FPHSA_FAIL_MESSAGE}" STREQUAL "DEFAULT_MSG")
|
||||
|
||||
# In config-mode, we rely on the variable <package>_CONFIG, which is set by find_package()
|
||||
# when it successfully found the config-file, including version checking:
|
||||
IF(FPHSA_CONFIG_MODE)
|
||||
LIST(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG)
|
||||
LIST(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS)
|
||||
SET(FPHSA_VERSION_VAR ${_NAME}_VERSION)
|
||||
ENDIF(FPHSA_CONFIG_MODE)
|
||||
|
||||
IF(NOT FPHSA_REQUIRED_VARS)
|
||||
MESSAGE(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()")
|
||||
ENDIF(NOT FPHSA_REQUIRED_VARS)
|
||||
|
||||
LIST(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR)
|
||||
|
||||
STRING(TOUPPER ${_NAME} _NAME_UPPER)
|
||||
STRING(TOLOWER ${_NAME} _NAME_LOWER)
|
||||
|
||||
# collect all variables which were not found, so they can be printed, so the
|
||||
# user knows better what went wrong (#6375)
|
||||
SET(MISSING_VARS "")
|
||||
SET(DETAILS "")
|
||||
SET(${_NAME_UPPER}_FOUND TRUE)
|
||||
# check if all passed variables are valid
|
||||
FOREACH(_CURRENT_VAR ${FPHSA_REQUIRED_VARS})
|
||||
IF(NOT ${_CURRENT_VAR})
|
||||
SET(${_NAME_UPPER}_FOUND FALSE)
|
||||
SET(MISSING_VARS "${MISSING_VARS} ${_CURRENT_VAR}")
|
||||
ELSE(NOT ${_CURRENT_VAR})
|
||||
SET(DETAILS "${DETAILS}[${${_CURRENT_VAR}}]")
|
||||
ENDIF(NOT ${_CURRENT_VAR})
|
||||
ENDFOREACH(_CURRENT_VAR)
|
||||
|
||||
# component handling
|
||||
UNSET(FOUND_COMPONENTS_MSG)
|
||||
UNSET(MISSING_COMPONENTS_MSG)
|
||||
|
||||
IF(FPHSA_HANDLE_COMPONENTS)
|
||||
FOREACH(comp ${${_NAME}_FIND_COMPONENTS})
|
||||
IF(${_NAME}_${comp}_FOUND)
|
||||
|
||||
IF(NOT DEFINED FOUND_COMPONENTS_MSG)
|
||||
SET(FOUND_COMPONENTS_MSG "found components: ")
|
||||
ENDIF()
|
||||
SET(FOUND_COMPONENTS_MSG "${FOUND_COMPONENTS_MSG} ${comp}")
|
||||
|
||||
ELSE()
|
||||
|
||||
IF(NOT DEFINED MISSING_COMPONENTS_MSG)
|
||||
SET(MISSING_COMPONENTS_MSG "missing components: ")
|
||||
ENDIF()
|
||||
SET(MISSING_COMPONENTS_MSG "${MISSING_COMPONENTS_MSG} ${comp}")
|
||||
|
||||
IF(${_NAME}_FIND_REQUIRED_${comp})
|
||||
SET(${_NAME_UPPER}_FOUND FALSE)
|
||||
SET(MISSING_VARS "${MISSING_VARS} ${comp}")
|
||||
ENDIF()
|
||||
|
||||
ENDIF()
|
||||
ENDFOREACH(comp)
|
||||
SET(COMPONENT_MSG "${FOUND_COMPONENTS_MSG} ${MISSING_COMPONENTS_MSG}")
|
||||
SET(DETAILS "${DETAILS}[c${COMPONENT_MSG}]")
|
||||
ENDIF(FPHSA_HANDLE_COMPONENTS)
|
||||
|
||||
# version handling:
|
||||
SET(VERSION_MSG "")
|
||||
SET(VERSION_OK TRUE)
|
||||
SET(VERSION ${${FPHSA_VERSION_VAR}} )
|
||||
IF (${_NAME}_FIND_VERSION)
|
||||
|
||||
IF(VERSION)
|
||||
|
||||
IF(${_NAME}_FIND_VERSION_EXACT) # exact version required
|
||||
IF (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}")
|
||||
SET(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"")
|
||||
SET(VERSION_OK FALSE)
|
||||
ELSE (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}")
|
||||
SET(VERSION_MSG "(found suitable exact version \"${VERSION}\")")
|
||||
ENDIF (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}")
|
||||
|
||||
ELSE(${_NAME}_FIND_VERSION_EXACT) # minimum version specified:
|
||||
IF ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}")
|
||||
SET(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"")
|
||||
SET(VERSION_OK FALSE)
|
||||
ELSE ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}")
|
||||
SET(VERSION_MSG "(found suitable version \"${VERSION}\", required is \"${${_NAME}_FIND_VERSION}\")")
|
||||
ENDIF ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}")
|
||||
ENDIF(${_NAME}_FIND_VERSION_EXACT)
|
||||
|
||||
ELSE(VERSION)
|
||||
|
||||
# if the package was not found, but a version was given, add that to the output:
|
||||
IF(${_NAME}_FIND_VERSION_EXACT)
|
||||
SET(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")")
|
||||
ELSE(${_NAME}_FIND_VERSION_EXACT)
|
||||
SET(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")")
|
||||
ENDIF(${_NAME}_FIND_VERSION_EXACT)
|
||||
|
||||
ENDIF(VERSION)
|
||||
ELSE (${_NAME}_FIND_VERSION)
|
||||
IF(VERSION)
|
||||
SET(VERSION_MSG "(found version \"${VERSION}\")")
|
||||
ENDIF(VERSION)
|
||||
ENDIF (${_NAME}_FIND_VERSION)
|
||||
|
||||
IF(VERSION_OK)
|
||||
SET(DETAILS "${DETAILS}[v${VERSION}(${${_NAME}_FIND_VERSION})]")
|
||||
ELSE(VERSION_OK)
|
||||
SET(${_NAME_UPPER}_FOUND FALSE)
|
||||
ENDIF(VERSION_OK)
|
||||
|
||||
|
||||
# print the result:
|
||||
IF (${_NAME_UPPER}_FOUND)
|
||||
FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG} ${COMPONENT_MSG}" "${DETAILS}")
|
||||
ELSE (${_NAME_UPPER}_FOUND)
|
||||
|
||||
IF(FPHSA_CONFIG_MODE)
|
||||
_FPHSA_HANDLE_FAILURE_CONFIG_MODE()
|
||||
ELSE(FPHSA_CONFIG_MODE)
|
||||
IF(NOT VERSION_OK)
|
||||
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})")
|
||||
ELSE(NOT VERSION_OK)
|
||||
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}")
|
||||
ENDIF(NOT VERSION_OK)
|
||||
ENDIF(FPHSA_CONFIG_MODE)
|
||||
|
||||
ENDIF (${_NAME_UPPER}_FOUND)
|
||||
|
||||
SET(${_NAME_UPPER}_FOUND ${${_NAME_UPPER}_FOUND} PARENT_SCOPE)
|
||||
|
||||
ENDFUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _FIRST_ARG)
|
176
cmake/modules/FindSDL.cmake
Normal file
176
cmake/modules/FindSDL.cmake
Normal file
@ -0,0 +1,176 @@
|
||||
# Locate SDL library
|
||||
# This module defines
|
||||
# SDL_LIBRARY, the name of the library to link against
|
||||
# SDL_FOUND, if false, do not try to link to SDL
|
||||
# SDL_INCLUDE_DIR, where to find SDL.h
|
||||
#
|
||||
# This is nearly identical to the FindSDL included with cmake
|
||||
# This is in Powder Toy to avoid warnings when FindThreads is overridden
|
||||
#
|
||||
# This module responds to the the flag:
|
||||
# SDL_BUILDING_LIBRARY
|
||||
# If this is defined, then no SDL_main will be linked in because
|
||||
# only applications need main().
|
||||
# Otherwise, it is assumed you are building an application and this
|
||||
# module will attempt to locate and set the the proper link flags
|
||||
# as part of the returned SDL_LIBRARY variable.
|
||||
#
|
||||
# Don't forget to include SDLmain.h and SDLmain.m your project for the
|
||||
# OS X framework based version. (Other versions link to -lSDLmain which
|
||||
# this module will try to find on your behalf.) Also for OS X, this
|
||||
# module will automatically add the -framework Cocoa on your behalf.
|
||||
#
|
||||
#
|
||||
# Additional Note: If you see an empty SDL_LIBRARY_TEMP in your configuration
|
||||
# and no SDL_LIBRARY, it means CMake did not find your SDL library
|
||||
# (SDL.dll, libsdl.so, SDL.framework, etc).
|
||||
# Set SDL_LIBRARY_TEMP to point to your SDL library, and configure again.
|
||||
# Similarly, if you see an empty SDLMAIN_LIBRARY, you should set this value
|
||||
# as appropriate. These values are used to generate the final SDL_LIBRARY
|
||||
# variable, but when these values are unset, SDL_LIBRARY does not get created.
|
||||
#
|
||||
#
|
||||
# $SDLDIR is an environment variable that would
|
||||
# correspond to the ./configure --prefix=$SDLDIR
|
||||
# used in building SDL.
|
||||
# l.e.galup 9-20-02
|
||||
#
|
||||
# Modified by Eric Wing.
|
||||
# Added code to assist with automated building by using environmental variables
|
||||
# and providing a more controlled/consistent search behavior.
|
||||
# Added new modifications to recognize OS X frameworks and
|
||||
# additional Unix paths (FreeBSD, etc).
|
||||
# Also corrected the header search path to follow "proper" SDL guidelines.
|
||||
# Added a search for SDLmain which is needed by some platforms.
|
||||
# Added a search for threads which is needed by some platforms.
|
||||
# Added needed compile switches for MinGW.
|
||||
#
|
||||
# On OSX, this will prefer the Framework version (if found) over others.
|
||||
# People will have to manually change the cache values of
|
||||
# SDL_LIBRARY to override this selection or set the CMake environment
|
||||
# CMAKE_INCLUDE_PATH to modify the search paths.
|
||||
#
|
||||
# Note that the header path has changed from SDL/SDL.h to just SDL.h
|
||||
# This needed to change because "proper" SDL convention
|
||||
# is #include "SDL.h", not <SDL/SDL.h>. This is done for portability
|
||||
# reasons because not all systems place things in SDL/ (see FreeBSD).
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2003-2009 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
FIND_PATH(SDL_INCLUDE_DIR SDL.h
|
||||
HINTS
|
||||
$ENV{SDLDIR}
|
||||
PATH_SUFFIXES include/SDL include
|
||||
PATHS
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local/include/SDL12
|
||||
/usr/local/include/SDL11 # FreeBSD ports
|
||||
/usr/include/SDL12
|
||||
/usr/include/SDL11
|
||||
/sw # Fink
|
||||
/opt/local # DarwinPorts
|
||||
/opt/csw # Blastwave
|
||||
/opt
|
||||
)
|
||||
|
||||
# SDL-1.1 is the name used by FreeBSD ports...
|
||||
# don't confuse it for the version number.
|
||||
FIND_LIBRARY(SDL_LIBRARY_TEMP
|
||||
NAMES SDL SDL-1.1
|
||||
HINTS
|
||||
$ENV{SDLDIR}
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
)
|
||||
|
||||
IF(NOT SDL_BUILDING_LIBRARY)
|
||||
IF(NOT ${SDL_INCLUDE_DIR} MATCHES ".framework")
|
||||
# Non-OS X framework versions expect you to also dynamically link to
|
||||
# SDLmain. This is mainly for Windows and OS X. Other (Unix) platforms
|
||||
# seem to provide SDLmain for compatibility even though they don't
|
||||
# necessarily need it.
|
||||
FIND_LIBRARY(SDLMAIN_LIBRARY
|
||||
NAMES SDLmain SDLmain-1.1
|
||||
HINTS
|
||||
$ENV{SDLDIR}
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
)
|
||||
ENDIF(NOT ${SDL_INCLUDE_DIR} MATCHES ".framework")
|
||||
ENDIF(NOT SDL_BUILDING_LIBRARY)
|
||||
|
||||
# SDL may require threads on your system.
|
||||
# The Apple build may not need an explicit flag because one of the
|
||||
# frameworks may already provide it.
|
||||
# But for non-OSX systems, I will use the CMake Threads package.
|
||||
IF(NOT APPLE)
|
||||
FIND_PACKAGE(Threads)
|
||||
ENDIF(NOT APPLE)
|
||||
|
||||
# MinGW needs an additional library, mwindows
|
||||
# It's total link flags should look like -lmingw32 -lSDLmain -lSDL -lmwindows
|
||||
# (Actually on second look, I think it only needs one of the m* libraries.)
|
||||
IF(MINGW)
|
||||
SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW")
|
||||
ENDIF(MINGW)
|
||||
|
||||
IF(SDL_LIBRARY_TEMP)
|
||||
# For SDLmain
|
||||
IF(NOT SDL_BUILDING_LIBRARY)
|
||||
IF(SDLMAIN_LIBRARY)
|
||||
SET(SDL_LIBRARY_TEMP ${SDLMAIN_LIBRARY} ${SDL_LIBRARY_TEMP})
|
||||
ENDIF(SDLMAIN_LIBRARY)
|
||||
ENDIF(NOT SDL_BUILDING_LIBRARY)
|
||||
|
||||
# For OS X, SDL uses Cocoa as a backend so it must link to Cocoa.
|
||||
# CMake doesn't display the -framework Cocoa string in the UI even
|
||||
# though it actually is there if I modify a pre-used variable.
|
||||
# I think it has something to do with the CACHE STRING.
|
||||
# So I use a temporary variable until the end so I can set the
|
||||
# "real" variable in one-shot.
|
||||
IF(APPLE)
|
||||
SET(SDL_LIBRARY_TEMP ${SDL_LIBRARY_TEMP} "-framework Cocoa")
|
||||
ENDIF(APPLE)
|
||||
|
||||
# For threads, as mentioned Apple doesn't need this.
|
||||
# In fact, there seems to be a problem if I used the Threads package
|
||||
# and try using this line, so I'm just skipping it entirely for OS X.
|
||||
IF(NOT APPLE)
|
||||
SET(SDL_LIBRARY_TEMP ${SDL_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
|
||||
ENDIF(NOT APPLE)
|
||||
|
||||
# For MinGW library
|
||||
IF(MINGW)
|
||||
SET(SDL_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL_LIBRARY_TEMP})
|
||||
ENDIF(MINGW)
|
||||
|
||||
# Set the final string here so the GUI reflects the final state.
|
||||
SET(SDL_LIBRARY ${SDL_LIBRARY_TEMP} CACHE STRING "Where the SDL Library can be found")
|
||||
# Set the temp variable to INTERNAL so it is not seen in the CMake GUI
|
||||
SET(SDL_LIBRARY_TEMP "${SDL_LIBRARY_TEMP}" CACHE INTERNAL "")
|
||||
ENDIF(SDL_LIBRARY_TEMP)
|
||||
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL
|
||||
REQUIRED_VARS SDL_LIBRARY SDL_INCLUDE_DIR)
|
26
cmake/modules/FindSDL_static_extra.cmake
Normal file
26
cmake/modules/FindSDL_static_extra.cmake
Normal file
@ -0,0 +1,26 @@
|
||||
# Find some extra libraries needed when linking SDL statically on Windows
|
||||
#
|
||||
# SDL_STATIC_EXTRA_LIBRARIES - List of libraries to link
|
||||
# SDL_STATIC_EXTRA_FOUND - True if all the necessary libraries were found
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
find_library(SDL_STATIC_EXTRA_LIBRARY_DXGUID NAMES dxguid
|
||||
HINTS
|
||||
C:/MinGW/lib/)
|
||||
find_library(SDL_STATIC_EXTRA_LIBRARY_WINMM NAMES winmm
|
||||
HINTS
|
||||
C:/MinGW/lib/)
|
||||
if(SDL_STATIC_EXTRA_LIBRARY_DXGUID AND SDL_STATIC_EXTRA_LIBRARY_WINMM)
|
||||
set(SDL_STATIC_EXTRA_LIBRARIES "${SDL_STATIC_EXTRA_LIBRARY_DXGUID};${SDL_STATIC_EXTRA_LIBRARY_WINMM}")
|
||||
endif()
|
||||
else(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
# Do nothing if not on Windows
|
||||
set(SDL_STATIC_EXTRA_LIBRARY_DXGUID TRUE)
|
||||
set(SDL_STATIC_EXTRA_LIBRARY_WINMM TRUE)
|
||||
set(SDL_STATIC_EXTRA_LIBRARIES TRUE)
|
||||
endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args (SDL_static_extra DEFAULT_MSG SDL_STATIC_EXTRA_LIBRARY_DXGUID SDL_STATIC_EXTRA_LIBRARY_WINMM SDL_STATIC_EXTRA_LIBRARIES)
|
||||
|
||||
mark_as_advanced(SDL_STATIC_EXTRA_LIBRARY_DXGUID SDL_STATIC_EXTRA_LIBRARY_WINMM SDL_STATIC_EXTRA_LIBRARIES)
|
164
cmake/modules/FindThreads.cmake
Normal file
164
cmake/modules/FindThreads.cmake
Normal file
@ -0,0 +1,164 @@
|
||||
# - This module determines the thread library of the system.
|
||||
# The following variables are set
|
||||
# CMAKE_THREAD_LIBS_INIT - the thread library
|
||||
# CMAKE_USE_SPROC_INIT - are we using sproc?
|
||||
# CMAKE_USE_WIN32_THREADS_INIT - using WIN32 threads?
|
||||
# CMAKE_USE_PTHREADS_INIT - are we using pthreads
|
||||
# CMAKE_HP_PTHREADS_INIT - are we using hp pthreads
|
||||
|
||||
# custom FindThreads to allow static linking of PTW32
|
||||
# (prefers static PTW32 library)
|
||||
|
||||
INCLUDE (CheckIncludeFiles)
|
||||
INCLUDE (CheckLibraryExists)
|
||||
SET(Threads_FOUND FALSE)
|
||||
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
find_package(Winsock)
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${WINSOCK_LIBRARIES})
|
||||
endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
|
||||
# Do we have sproc?
|
||||
IF(CMAKE_SYSTEM MATCHES IRIX)
|
||||
CHECK_INCLUDE_FILES("sys/types.h;sys/prctl.h" CMAKE_HAVE_SPROC_H)
|
||||
ENDIF(CMAKE_SYSTEM MATCHES IRIX)
|
||||
|
||||
IF(CMAKE_HAVE_SPROC_H)
|
||||
# We have sproc
|
||||
SET(CMAKE_USE_SPROC_INIT 1)
|
||||
ELSE(CMAKE_HAVE_SPROC_H)
|
||||
# Do we have pthreads?
|
||||
CHECK_INCLUDE_FILES("pthread.h" CMAKE_HAVE_PTHREAD_H)
|
||||
IF(CMAKE_HAVE_PTHREAD_H)
|
||||
# We have pthread.h
|
||||
# Let's check for the library now.
|
||||
SET(CMAKE_HAVE_THREADS_LIBRARY)
|
||||
IF(NOT THREADS_HAVE_PTHREAD_ARG)
|
||||
set(CMAKE_THREAD_LIB)
|
||||
set(CMAKE_HAVE_PTHREADS_CREATE)
|
||||
find_library(CMAKE_THREAD_LIB NAMES pthreads pthread pthreadGC2 thread)
|
||||
if (CMAKE_THREAD_LIB)
|
||||
CHECK_LIBRARY_EXISTS(${CMAKE_THREAD_LIB} pthread_create "" CMAKE_HAVE_PTHREADS_CREATE)
|
||||
if(CMAKE_HAVE_PTHREADS_CREATE)
|
||||
message(STATUS "Checking whether pthreads is static pthreads-win32")
|
||||
set(CMAKE_REQUIRED_DEFINITIONS -DPTW32_STATIC_LIB)
|
||||
set(CMAKE_PTHREADS_W32_STATIC)
|
||||
CHECK_LIBRARY_EXISTS(${CMAKE_THREAD_LIB} pthread_win32_process_detach_np "" CMAKE_PTHREADS_W32_STATIC)
|
||||
SET(CMAKE_REQUIRED_DEFINITIONS "")
|
||||
if(CMAKE_PTHREADS_W32_STATIC)
|
||||
message(STATUS "Static pthreads-win32 found")
|
||||
ADD_DEFINITIONS("-DPTW32_STATIC_LIB")
|
||||
endif()
|
||||
SET(CMAKE_THREAD_LIBS_INIT ${CMAKE_THREAD_LIB})
|
||||
SET(CMAKE_HAVE_THREADS_LIBRARY 1)
|
||||
SET(Threads_FOUND TRUE)
|
||||
endif(CMAKE_HAVE_PTHREADS_CREATE)
|
||||
endif(CMAKE_THREAD_LIB)
|
||||
|
||||
if(NOT CMAKE_HAVE_PTHREADS_CREATE)
|
||||
# Original behaviour
|
||||
# Do we have -lpthreads
|
||||
CHECK_LIBRARY_EXISTS(pthreads pthread_create "" CMAKE_HAVE_PTHREADS_CREATE)
|
||||
IF(CMAKE_HAVE_PTHREADS_CREATE)
|
||||
SET(CMAKE_THREAD_LIBS_INIT "-lpthreads")
|
||||
SET(CMAKE_HAVE_THREADS_LIBRARY 1)
|
||||
SET(Threads_FOUND TRUE)
|
||||
ENDIF(CMAKE_HAVE_PTHREADS_CREATE)
|
||||
# Ok, how about -lpthread
|
||||
CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE)
|
||||
IF(CMAKE_HAVE_PTHREAD_CREATE)
|
||||
SET(CMAKE_THREAD_LIBS_INIT "-lpthread")
|
||||
SET(Threads_FOUND TRUE)
|
||||
SET(CMAKE_HAVE_THREADS_LIBRARY 1)
|
||||
ENDIF(CMAKE_HAVE_PTHREAD_CREATE)
|
||||
IF(CMAKE_SYSTEM MATCHES "SunOS.*")
|
||||
# On sun also check for -lthread
|
||||
CHECK_LIBRARY_EXISTS(thread thr_create "" CMAKE_HAVE_THR_CREATE)
|
||||
IF(CMAKE_HAVE_THR_CREATE)
|
||||
SET(CMAKE_THREAD_LIBS_INIT "-lthread")
|
||||
SET(CMAKE_HAVE_THREADS_LIBRARY 1)
|
||||
SET(Threads_FOUND TRUE)
|
||||
ENDIF(CMAKE_HAVE_THR_CREATE)
|
||||
ENDIF(CMAKE_SYSTEM MATCHES "SunOS.*")
|
||||
endif(NOT CMAKE_HAVE_PTHREADS_CREATE)
|
||||
ENDIF(NOT THREADS_HAVE_PTHREAD_ARG)
|
||||
|
||||
IF(NOT CMAKE_HAVE_THREADS_LIBRARY)
|
||||
# If we did not found -lpthread, -lpthread, or -lthread, look for -pthread
|
||||
IF("THREADS_HAVE_PTHREAD_ARG" MATCHES "^THREADS_HAVE_PTHREAD_ARG")
|
||||
MESSAGE(STATUS "Check if compiler accepts -pthread")
|
||||
TRY_RUN(THREADS_PTHREAD_ARG THREADS_HAVE_PTHREAD_ARG
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_ROOT}/Modules/CheckForPthreads.c
|
||||
CMAKE_FLAGS -DLINK_LIBRARIES:STRING=-pthread
|
||||
COMPILE_OUTPUT_VARIABLE OUTPUT)
|
||||
IF(THREADS_HAVE_PTHREAD_ARG)
|
||||
IF(THREADS_PTHREAD_ARG MATCHES "^2$")
|
||||
SET(Threads_FOUND TRUE)
|
||||
MESSAGE(STATUS "Check if compiler accepts -pthread - yes")
|
||||
ELSE(THREADS_PTHREAD_ARG MATCHES "^2$")
|
||||
MESSAGE(STATUS "Check if compiler accepts -pthread - no")
|
||||
FILE(APPEND
|
||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||
"Determining if compiler accepts -pthread returned ${THREADS_PTHREAD_ARG} instead of 2. The compiler had the following output:\n${OUTPUT}\n\n")
|
||||
ENDIF(THREADS_PTHREAD_ARG MATCHES "^2$")
|
||||
ELSE(THREADS_HAVE_PTHREAD_ARG)
|
||||
MESSAGE(STATUS "Check if compiler accepts -pthread - no")
|
||||
FILE(APPEND
|
||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||
"Determining if compiler accepts -pthread failed with the following output:\n${OUTPUT}\n\n")
|
||||
ENDIF(THREADS_HAVE_PTHREAD_ARG)
|
||||
ENDIF("THREADS_HAVE_PTHREAD_ARG" MATCHES "^THREADS_HAVE_PTHREAD_ARG")
|
||||
IF(THREADS_HAVE_PTHREAD_ARG)
|
||||
SET(Threads_FOUND TRUE)
|
||||
SET(CMAKE_THREAD_LIBS_INIT "-pthread")
|
||||
ENDIF(THREADS_HAVE_PTHREAD_ARG)
|
||||
ENDIF(NOT CMAKE_HAVE_THREADS_LIBRARY)
|
||||
ENDIF(CMAKE_HAVE_PTHREAD_H)
|
||||
ENDIF(CMAKE_HAVE_SPROC_H)
|
||||
|
||||
IF(CMAKE_THREAD_LIBS_INIT)
|
||||
SET(CMAKE_USE_PTHREADS_INIT 1)
|
||||
SET(Threads_FOUND TRUE)
|
||||
ENDIF(CMAKE_THREAD_LIBS_INIT)
|
||||
|
||||
IF(CMAKE_SYSTEM MATCHES "Windows")
|
||||
SET(CMAKE_USE_WIN32_THREADS_INIT 1)
|
||||
SET(Threads_FOUND TRUE)
|
||||
ENDIF(CMAKE_SYSTEM MATCHES "Windows")
|
||||
|
||||
IF(CMAKE_USE_PTHREADS_INIT)
|
||||
IF(CMAKE_SYSTEM MATCHES "HP-UX-*")
|
||||
# Use libcma if it exists and can be used. It provides more
|
||||
# symbols than the plain pthread library. CMA threads
|
||||
# have actually been deprecated:
|
||||
# http://docs.hp.com/en/B3920-90091/ch12s03.html#d0e11395
|
||||
# http://docs.hp.com/en/947/d8.html
|
||||
# but we need to maintain compatibility here.
|
||||
# The CMAKE_HP_PTHREADS setting actually indicates whether CMA threads
|
||||
# are available.
|
||||
CHECK_LIBRARY_EXISTS(cma pthread_attr_create "" CMAKE_HAVE_HP_CMA)
|
||||
IF(CMAKE_HAVE_HP_CMA)
|
||||
SET(CMAKE_THREAD_LIBS_INIT "-lcma")
|
||||
SET(CMAKE_HP_PTHREADS_INIT 1)
|
||||
SET(Threads_FOUND TRUE)
|
||||
ENDIF(CMAKE_HAVE_HP_CMA)
|
||||
SET(CMAKE_USE_PTHREADS_INIT 1)
|
||||
ENDIF(CMAKE_SYSTEM MATCHES "HP-UX-*")
|
||||
|
||||
IF(CMAKE_SYSTEM MATCHES "OSF1-V*")
|
||||
SET(CMAKE_USE_PTHREADS_INIT 0)
|
||||
SET(CMAKE_THREAD_LIBS_INIT )
|
||||
ENDIF(CMAKE_SYSTEM MATCHES "OSF1-V*")
|
||||
|
||||
IF(CMAKE_SYSTEM MATCHES "CYGWIN_NT*")
|
||||
SET(CMAKE_USE_PTHREADS_INIT 1)
|
||||
SET(Threads_FOUND TRUE)
|
||||
SET(CMAKE_THREAD_LIBS_INIT )
|
||||
SET(CMAKE_USE_WIN32_THREADS_INIT 0)
|
||||
ENDIF(CMAKE_SYSTEM MATCHES "CYGWIN_NT*")
|
||||
ENDIF(CMAKE_USE_PTHREADS_INIT)
|
||||
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Threads DEFAULT_MSG Threads_FOUND)
|
24
cmake/modules/FindWinsock.cmake
Normal file
24
cmake/modules/FindWinsock.cmake
Normal file
@ -0,0 +1,24 @@
|
||||
# - Find Winsock
|
||||
# Find the Windows socket includes and library
|
||||
#
|
||||
# WINSOCK_INCLUDE_DIR - where to find regex.h
|
||||
# WINSOCK_LIBRARIES - List of libraries when using Winsock.
|
||||
# WINSOCK_FOUND - True if Winsock found.
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
find_path(WINSOCK_INCLUDE_DIR winsock2.h
|
||||
HINTS
|
||||
C:/MinGW/include/)
|
||||
find_library(WINSOCK_LIBRARIES NAMES ws2_32
|
||||
HINTS
|
||||
C:/MinGW/lib/)
|
||||
else(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
# Do nothing if not on Windows
|
||||
set(WINSOCK_INCLUDE_DIR TRUE)
|
||||
set(WINSOCK_LIBRARIES TRUE)
|
||||
endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args (Winsock DEFAULT_MSG WINSOCK_LIBRARIES WINSOCK_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(WINSOCK_LIBRARIES WINSOCK_INCLUDE_DIR)
|
92
cmake/modules/FindZLIB.cmake
Normal file
92
cmake/modules/FindZLIB.cmake
Normal file
@ -0,0 +1,92 @@
|
||||
# - Find zlib
|
||||
# Find the native ZLIB includes and library.
|
||||
# Once done this will define
|
||||
#
|
||||
# ZLIB_INCLUDE_DIRS - where to find zlib.h, etc.
|
||||
# ZLIB_LIBRARIES - List of libraries when using zlib.
|
||||
# ZLIB_FOUND - True if zlib found.
|
||||
#
|
||||
# ZLIB_VERSION_STRING - The version of zlib found (x.y.z)
|
||||
# ZLIB_VERSION_MAJOR - The major version of zlib
|
||||
# ZLIB_VERSION_MINOR - The minor version of zlib
|
||||
# ZLIB_VERSION_PATCH - The patch version of zlib
|
||||
# ZLIB_VERSION_TWEAK - The tweak version of zlib
|
||||
#
|
||||
# The following variable are provided for backward compatibility
|
||||
#
|
||||
# ZLIB_MAJOR_VERSION - The major version of zlib
|
||||
# ZLIB_MINOR_VERSION - The minor version of zlib
|
||||
# ZLIB_PATCH_VERSION - The patch version of zlib
|
||||
#
|
||||
# An includer may set ZLIB_ROOT to a zlib installation root to tell
|
||||
# this module where to look.
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2001-2011 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
SET(_ZLIB_SEARCHES)
|
||||
|
||||
# Search ZLIB_ROOT first if it is set.
|
||||
IF(ZLIB_ROOT)
|
||||
SET(_ZLIB_SEARCH_ROOT PATHS ${ZLIB_ROOT} NO_DEFAULT_PATH)
|
||||
LIST(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_ROOT)
|
||||
ENDIF()
|
||||
|
||||
# Normal search.
|
||||
SET(_ZLIB_SEARCH_NORMAL
|
||||
PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]"
|
||||
"$ENV{PROGRAMFILES}/zlib"
|
||||
)
|
||||
LIST(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_NORMAL)
|
||||
|
||||
SET(ZLIB_NAMES z zlib zdll zlib1 zlibd zlibd1)
|
||||
|
||||
# Try each search configuration.
|
||||
FOREACH(search ${_ZLIB_SEARCHES})
|
||||
FIND_PATH(ZLIB_INCLUDE_DIR NAMES zlib.h ${${search}} PATH_SUFFIXES include)
|
||||
FIND_LIBRARY(ZLIB_LIBRARY NAMES ${ZLIB_NAMES} ${${search}} PATH_SUFFIXES lib)
|
||||
ENDFOREACH()
|
||||
|
||||
MARK_AS_ADVANCED(ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
|
||||
|
||||
IF(ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h")
|
||||
FILE(STRINGS "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_H REGEX "^#define ZLIB_VERSION \"[^\"]*\"$")
|
||||
|
||||
STRING(REGEX REPLACE "^.*ZLIB_VERSION \"([0-9]+).*$" "\\1" ZLIB_VERSION_MAJOR "${ZLIB_H}")
|
||||
STRING(REGEX REPLACE "^.*ZLIB_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" ZLIB_VERSION_MINOR "${ZLIB_H}")
|
||||
STRING(REGEX REPLACE "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" ZLIB_VERSION_PATCH "${ZLIB_H}")
|
||||
SET(ZLIB_VERSION_STRING "${ZLIB_VERSION_MAJOR}.${ZLIB_VERSION_MINOR}.${ZLIB_VERSION_PATCH}")
|
||||
|
||||
# only append a TWEAK version if it exists:
|
||||
SET(ZLIB_VERSION_TWEAK "")
|
||||
IF( "${ZLIB_H}" MATCHES "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*$")
|
||||
SET(ZLIB_VERSION_TWEAK "${CMAKE_MATCH_1}")
|
||||
SET(ZLIB_VERSION_STRING "${ZLIB_VERSION_STRING}.${ZLIB_VERSION_TWEAK}")
|
||||
ENDIF( "${ZLIB_H}" MATCHES "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*$")
|
||||
|
||||
SET(ZLIB_MAJOR_VERSION "${ZLIB_VERSION_MAJOR}")
|
||||
SET(ZLIB_MINOR_VERSION "${ZLIB_VERSION_MINOR}")
|
||||
SET(ZLIB_PATCH_VERSION "${ZLIB_VERSION_PATCH}")
|
||||
ENDIF()
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set ZLIB_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB REQUIRED_VARS ZLIB_LIBRARY ZLIB_INCLUDE_DIR
|
||||
VERSION_VAR ZLIB_VERSION_STRING)
|
||||
|
||||
IF(ZLIB_FOUND)
|
||||
SET(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR})
|
||||
SET(ZLIB_LIBRARIES ${ZLIB_LIBRARY})
|
||||
ENDIF()
|
||||
|
46
cmake/toolchain-cross-mingw-linux.cmake
Normal file
46
cmake/toolchain-cross-mingw-linux.cmake
Normal file
@ -0,0 +1,46 @@
|
||||
# adapted from http://www.cmake.org/Wiki/File:Toolchain-cross-mingw32-linux.cmake
|
||||
|
||||
# the name of the target operating system
|
||||
SET(CMAKE_SYSTEM_NAME Windows)
|
||||
|
||||
IF(NOT ("${GNU_HOST}" STREQUAL ""))
|
||||
find_program(CC_GNUHOST NAMES ${GNU_HOST}-gcc)
|
||||
ENDIF()
|
||||
|
||||
if(CC_GNUHOST)
|
||||
set(COMPILER_PREFIX "${GNU_HOST}")
|
||||
else()
|
||||
find_program(CC_W64 NAMES i686-w64-mingw32-gcc)
|
||||
if(CC_W64)
|
||||
# for 32 or 64 bits mingw-w64
|
||||
# see http://mingw-w64.sourceforge.net/
|
||||
set(COMPILER_PREFIX "i686-w64-mingw32")
|
||||
else()
|
||||
# for classical mingw32
|
||||
# see http://www.mingw.org/
|
||||
set(COMPILER_PREFIX "i586-mingw32msvc")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#set(COMPILER_PREFIX "x86_64-w64-mingw32"
|
||||
|
||||
# which compilers to use for C and C++
|
||||
find_program(CMAKE_RC_COMPILER NAMES ${COMPILER_PREFIX}-windres)
|
||||
#SET(CMAKE_RC_COMPILER ${COMPILER_PREFIX}-windres)
|
||||
find_program(CMAKE_C_COMPILER NAMES ${COMPILER_PREFIX}-gcc)
|
||||
#SET(CMAKE_C_COMPILER ${COMPILER_PREFIX}-gcc)
|
||||
find_program(CMAKE_CXX_COMPILER NAMES ${COMPILER_PREFIX}-g++)
|
||||
#SET(CMAKE_CXX_COMPILER ${COMPILER_PREFIX}-g++)
|
||||
|
||||
|
||||
# here is the target environment located
|
||||
SET(CMAKE_FIND_ROOT_PATH /usr/${COMPILER_PREFIX} /usr/${COMPILER_PREFIX}/sys-root/${COMPILER_PREFIX} /usr/${COMPILER_PREFIX}/sys-root/mingw)
|
||||
SET(CMAKE_SYSTEM_PREFIX_PATH ${CMAKE_FIND_ROOT_PATH}) # needed to make FindSDL find includes
|
||||
|
||||
# adjust the default behaviour of the FIND_XXX() commands:
|
||||
# search headers and libraries in the target environment, search
|
||||
# programs in the host environment
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
|
@ -1,126 +0,0 @@
|
||||
#
|
||||
# SCons builder for gcc's precompiled headers
|
||||
# Copyright (C) 2006 Tim Blechmann
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
# 1.1
|
||||
#
|
||||
# 09-11-2011 Pedro Larroy: Fixed dependency emitter not working with variant dir
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
import SCons.Action
|
||||
import SCons.Builder
|
||||
import SCons.Scanner.C
|
||||
import SCons.Util
|
||||
import SCons.Script
|
||||
import os
|
||||
|
||||
SCons.Script.EnsureSConsVersion(0,96,92)
|
||||
|
||||
GchAction = SCons.Action.Action('$GCHCOM', '$GCHCOMSTR')
|
||||
GchShAction = SCons.Action.Action('$GCHSHCOM', '$GCHSHCOMSTR')
|
||||
|
||||
def gen_suffix(env, sources):
|
||||
return sources[0].get_suffix() + env['GCHSUFFIX']
|
||||
|
||||
GchShBuilder = SCons.Builder.Builder(action = GchShAction,
|
||||
source_scanner = SCons.Scanner.C.CScanner(),
|
||||
suffix = gen_suffix)
|
||||
|
||||
GchBuilder = SCons.Builder.Builder(action = GchAction,
|
||||
source_scanner = SCons.Scanner.C.CScanner(),
|
||||
suffix = gen_suffix)
|
||||
|
||||
def header_path(node):
|
||||
h_path = node.abspath
|
||||
idx = h_path.rfind('.gch')
|
||||
if idx != -1:
|
||||
h_path = h_path[0:idx]
|
||||
if not os.path.isfile(h_path):
|
||||
raise SCons.Errors.StopError("can't find header file: {0}".format(h_path))
|
||||
return h_path
|
||||
|
||||
else:
|
||||
raise SCons.Errors.StopError("{0} file doesn't have .gch extension".format(h_path))
|
||||
|
||||
|
||||
def static_pch_emitter(target,source,env):
|
||||
SCons.Defaults.StaticObjectEmitter( target, source, env )
|
||||
scanner = SCons.Scanner.C.CScanner()
|
||||
path = scanner.path(env)
|
||||
|
||||
deps = scanner(source[0], env, path)
|
||||
if env.get('Gch'):
|
||||
h_path = header_path(env['Gch'])
|
||||
if h_path in [x.abspath for x in deps]:
|
||||
#print 'Found dep. on pch: ', target[0], ' -> ', env['Gch']
|
||||
env.Depends(target, env['Gch'])
|
||||
|
||||
return (target, source)
|
||||
|
||||
def shared_pch_emitter(target,source,env):
|
||||
SCons.Defaults.SharedObjectEmitter( target, source, env )
|
||||
|
||||
scanner = SCons.Scanner.C.CScanner()
|
||||
path = scanner.path(env)
|
||||
deps = scanner(source[0], env, path)
|
||||
|
||||
if env.get('GchSh'):
|
||||
h_path = header_path(env['GchSh'])
|
||||
if h_path in [x.abspath for x in deps]:
|
||||
#print 'Found dep. on pch (shared): ', target[0], ' -> ', env['Gch']
|
||||
env.Depends(target, env['GchSh'])
|
||||
|
||||
return (target, source)
|
||||
|
||||
def generate(env):
|
||||
"""
|
||||
Add builders and construction variables for the Gch builder.
|
||||
"""
|
||||
env.Append(BUILDERS = {
|
||||
'gch': env.Builder(
|
||||
action = GchAction,
|
||||
target_factory = env.fs.File,
|
||||
),
|
||||
'gchsh': env.Builder(
|
||||
action = GchShAction,
|
||||
target_factory = env.fs.File,
|
||||
),
|
||||
})
|
||||
|
||||
try:
|
||||
bld = env['BUILDERS']['Gch']
|
||||
bldsh = env['BUILDERS']['GchSh']
|
||||
except KeyError:
|
||||
bld = GchBuilder
|
||||
bldsh = GchShBuilder
|
||||
env['BUILDERS']['Gch'] = bld
|
||||
env['BUILDERS']['GchSh'] = bldsh
|
||||
|
||||
env['GCHCOM'] = '$CXX -Wall -o $TARGET -x c++-header -c $CXXFLAGS $CCFLAGS $_CCCOMCOM $SOURCE'
|
||||
env['GCHSHCOM'] = '$CXX -o $TARGET -x c++-header -c $SHCXXFLAGS $CCFLAGS $_CCCOMCOM $SOURCE'
|
||||
env['GCHSUFFIX'] = '.gch'
|
||||
|
||||
for suffix in SCons.Util.Split('.c .C .cc .cxx .cpp .c++'):
|
||||
env['BUILDERS']['StaticObject'].add_emitter( suffix, static_pch_emitter )
|
||||
env['BUILDERS']['SharedObject'].add_emitter( suffix, shared_pch_emitter )
|
||||
|
||||
|
||||
def exists(env):
|
||||
return env.Detect('g++')
|
Binary file not shown.
@ -1,241 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2010 Western Digital Corporation
|
||||
# Alan Somers asomers (at) gmail (dot) com
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
|
||||
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
####
|
||||
import os
|
||||
import new
|
||||
import sys
|
||||
##
|
||||
import SCons
|
||||
|
||||
if sys.version_info < (2,6,0):
|
||||
from relpath import relpath
|
||||
else:
|
||||
from os.path import relpath
|
||||
|
||||
|
||||
def sc_relpath(src, destdir):
|
||||
"""Like relpath but aware of SCons convention regarding '#' in pathnames"""
|
||||
if src[0] == '#':
|
||||
return relpath(src[1:], destdir)
|
||||
else:
|
||||
return relpath(os.path.join(destdir, src), destdir)
|
||||
|
||||
|
||||
|
||||
class MF_Executor(SCons.Executor.Executor):
|
||||
"""Custom Executor that can scan each target file for its dependencies
|
||||
individually, rather than giving every target the same deps.
|
||||
Assumes that there is a one-to-one relationship between sources and targets
|
||||
and the targets have the same basenames as their respective sources
|
||||
ie. [[foo.o, bar.o], [foo.c, bar.c]]"""
|
||||
def scan(self, scanner, node_list):
|
||||
tgt_names = [os.path.splitext(
|
||||
os.path.basename(str(i)))[0] for i in self.targets]
|
||||
env = self.get_build_env()
|
||||
|
||||
if scanner:
|
||||
for node in node_list:
|
||||
tgt = \
|
||||
self.targets[tgt_names.index(
|
||||
os.path.splitext(
|
||||
os.path.basename(str(node)))[0])]
|
||||
node.disambiguate()
|
||||
s = scanner.select(node)
|
||||
if not s:
|
||||
continue
|
||||
path = self.get_build_scanner_path(s)
|
||||
tgt.add_to_implicit(node.get_implicit_deps(env, s, path))
|
||||
else:
|
||||
kw = self.get_kw()
|
||||
for node in node_list:
|
||||
tgt = \
|
||||
self.targets[tgt_names.index(
|
||||
os.path.splitext(
|
||||
os.path.basename(str(node)))[0])]
|
||||
node.disambiguate()
|
||||
scanner = node.get_env_scanner(env, kw)
|
||||
if not scanner:
|
||||
continue
|
||||
scanner = scanner.select(node)
|
||||
if not scanner:
|
||||
continue
|
||||
path = self.get_build_scanner_path(scanner)
|
||||
tgt.add_to_implicit(node.get_implicit_deps(env, scanner, path))
|
||||
|
||||
|
||||
def MF_get_single_executor(self, env, tlist, slist, executor_kw):
|
||||
if not self.action:
|
||||
raise UserError, "Builder %s must have an action to build %s." % \
|
||||
(self.get_name(env or self.env), map(str,tlist))
|
||||
return MF_Executor(self.action, env, [], tlist, slist, executor_kw)
|
||||
|
||||
def exists(env):
|
||||
return env.WhereIs(env.subst['$CC']) or env.WhereIs(env.subst['$CXX'])
|
||||
|
||||
def MFProgramEmitter(target, source, env):
|
||||
"""Ensures that target list is complete, and does validity checking. Sets precious"""
|
||||
if len(target) == 1 and len(source) > 1:
|
||||
#Looks like the user specified many sources and SCons created 1 target
|
||||
#targets are implicit, but the builder doesn't know how to handle
|
||||
#suffixes for multiple target files, so we'll do it here
|
||||
objdir = env.get('OBJDIR', '')
|
||||
#target = [os.path.join(
|
||||
# objdir,
|
||||
# os.path.splitext(
|
||||
# os.path.basename(str(i)))[0] + '.o' ) for i in source]
|
||||
elif len(source) == 1 and 'OBJDIR' in env:
|
||||
target = os.path.join(
|
||||
env['OBJDIR'],
|
||||
os.path.splitext(
|
||||
os.path.basename(str(source[0])))[0] + '.o' )
|
||||
else:
|
||||
#targets are explicit, we need to check their validity
|
||||
tgt_names = [os.path.splitext(
|
||||
os.path.basename(str(i)))[0] for i in target]
|
||||
src_names = [os.path.splitext(
|
||||
os.path.basename(str(i)))[0] for i in source]
|
||||
tgt_dirs = [os.path.dirname(str(i)) for i in target]
|
||||
if sorted(tgt_names) != sorted(src_names):
|
||||
raise ValueError, "target files do not have obvious one-one relationship to source files"
|
||||
if len(set(src_names)) != len(src_names):
|
||||
raise ValueError, "source files may not include identically named files in different directories"
|
||||
if len(set(tgt_dirs)) != 1:
|
||||
raise ValueError, "Target files must all be in same directory"
|
||||
|
||||
for t in target:
|
||||
env.Precious(t)
|
||||
return target, source
|
||||
|
||||
def MFProgramGenerator(source, target, env, for_signature):
|
||||
#Rebuild everything if
|
||||
# a) the number of dependencies has changed
|
||||
# b) any target does not exist
|
||||
# c) the build command has changed
|
||||
#Else rebuild only those c files that have changed_since_last_build
|
||||
#The signature of this builder should always be the same, because the
|
||||
#multifile compile is always functionally equivalent to rebuilding
|
||||
#everything
|
||||
|
||||
if for_signature:
|
||||
pared_sources = source
|
||||
else:
|
||||
#First a sanity check
|
||||
assert len(set([os.path.splitext(str(i))[1] for i in source])) == 1, \
|
||||
"All source files must have the same extension."
|
||||
pared_sources = []
|
||||
src_names = [os.path.splitext(os.path.basename(str(i)))[0]
|
||||
for i in source]
|
||||
tgt_names = [os.path.splitext(os.path.basename(str(t)))[0]
|
||||
for t in target]
|
||||
ni = target[0].get_binfo()
|
||||
oi = target[0].get_stored_info().binfo
|
||||
if ni.bactsig != oi.bactsig:
|
||||
#Command line has changed
|
||||
pared_sources = source
|
||||
else:
|
||||
for i in range(len(tgt_names)):
|
||||
t = target[i]
|
||||
tgt_name = tgt_names[i]
|
||||
if not t.exists():
|
||||
#a target does not exist
|
||||
pared_sources = source
|
||||
break
|
||||
bi = t.get_stored_info().binfo
|
||||
then = bi.bsourcesigs + bi.bdependsigs + bi.bimplicitsigs
|
||||
children = t.children()
|
||||
if len(children) != len(then):
|
||||
#the number of dependencies has changed
|
||||
pared_sources = source
|
||||
break
|
||||
for child, prev_ni in zip(children, then):
|
||||
if child.changed_since_last_build(t, prev_ni) and \
|
||||
not t in pared_sources:
|
||||
#If child is a source file, not an explicit or implicit
|
||||
#dependency, then it is not truly a dependency of any target
|
||||
#except that with the same basename. This is a limitation
|
||||
#of SCons.node, which assumes that all sources of a Node
|
||||
#are dependencies of all targets. So we check for that case
|
||||
#here and only rebuild as necessary.
|
||||
src_name = os.path.splitext(os.path.basename(str(child)))[0]
|
||||
if src_name not in tgt_names or src_name == tgt_name:
|
||||
s = source[src_names.index(tgt_name)]
|
||||
pared_sources.append(s)
|
||||
assert len(pared_sources) > 0
|
||||
destdir = str(target[0].dir)
|
||||
#finding sconscript_dir is a bit of a hack. It assumes that the source
|
||||
#files are always going to be in the same directory as the SConscript file
|
||||
#which is not necessarily true. BUG BY Alan Somers
|
||||
sconscript_dir = os.path.dirname(str(pared_sources[0]))
|
||||
prefixed_sources = [relpath(str(i), destdir) for i in pared_sources]
|
||||
prefixed_sources_str = ' '.join([str(i) for i in prefixed_sources])
|
||||
lang_ext = os.path.splitext(prefixed_sources[0])[1]
|
||||
tgt_names2 = [os.path.splitext(os.path.basename(str(t)))[0]
|
||||
for t in target]
|
||||
|
||||
_CPPPATH = []
|
||||
if 'CPPPATH' in env:
|
||||
for i in env['CPPPATH']:
|
||||
#if i[0] == '#':
|
||||
##_CPPPATH.append(relpath(i[1:], destdir))
|
||||
_CPPPATH.append(i)
|
||||
#else:
|
||||
# _CPPPATH.append(relpath(os.path.join(sconscript_dir, i),
|
||||
# destdir))
|
||||
|
||||
defines = ""
|
||||
for t in env['CPPDEFINES']:
|
||||
defines += ("-D"+str(t)+" ")
|
||||
|
||||
_CPPINCFLAGS = ['-I' + i for i in _CPPPATH]
|
||||
_CCOMCOM = '$CPPFLAGS $_CPPDEFFLAGS $defines %s' % ' '.join(_CPPINCFLAGS)
|
||||
|
||||
libstr = ""
|
||||
for t in env['LIBS']:
|
||||
libstr += ("-l"+t+" ")
|
||||
|
||||
if lang_ext == '.c' :
|
||||
_CCCOM = 'cd %s && $CC $CFLAGS $CCFLAGS %s %s $LINKFLAGS %s -o %s' % \
|
||||
(destdir, _CCOMCOM, prefixed_sources_str, libstr, tgt_names2[0])
|
||||
#XXX BUG BY Alan Somers. $CCCOMSTR gets substituted using the full list of target files,
|
||||
#not prefixed_sources
|
||||
cmd = SCons.Script.Action(env.subst(_CCCOM), "$CCCOMSTR")
|
||||
elif lang_ext in ['.cc', '.cpp']:
|
||||
_CXXCOM = 'cd %s && $CXX $CXXFLAGS $CCFLAGS %s %s $LINKFLAGS %s -o %s' % \
|
||||
(destdir, _CCOMCOM, prefixed_sources_str, libstr, tgt_names2[0])
|
||||
cmd = SCons.Script.Action(env.subst(_CXXCOM), "$CXXCOMSTR")
|
||||
else:
|
||||
assert False, "Unknown source file extension %s" % lang_ext
|
||||
return cmd
|
||||
|
||||
def generate(env):
|
||||
"""Adds the MFObject builder to your environment"""
|
||||
MFProgramBld = env.Builder(generator = MFProgramGenerator,
|
||||
emitter = MFProgramEmitter,
|
||||
suffix = '.o',
|
||||
source_scanner=SCons.Tool.SourceFileScanner)
|
||||
MFProgramBld.get_single_executor = new.instancemethod(MF_get_single_executor,
|
||||
MFProgramBld, MFProgramBld.__class__)
|
||||
|
||||
env.Append(BUILDERS = {'MFProgram': MFProgramBld})
|
Binary file not shown.
@ -1,73 +0,0 @@
|
||||
#PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
|
||||
#--------------------------------------------
|
||||
#
|
||||
#1. This LICENSE AGREEMENT is between the Python Software Foundation
|
||||
#("PSF"), and the Individual or Organization ("Licensee") accessing and
|
||||
#otherwise using this software ("Python") in source or binary form and
|
||||
#its associated documentation.
|
||||
#
|
||||
#2. Subject to the terms and conditions of this License Agreement, PSF hereby
|
||||
#grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
|
||||
#analyze, test, perform and/or display publicly, prepare derivative works,
|
||||
#distribute, and otherwise use Python alone or in any derivative version,
|
||||
#provided, however, that PSF's License Agreement and PSF's notice of copyright,
|
||||
#i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
|
||||
#Python Software Foundation; All Rights Reserved" are retained in Python alone or
|
||||
#in any derivative version prepared by Licensee.
|
||||
#
|
||||
#3. In the event Licensee prepares a derivative work that is based on
|
||||
#or incorporates Python or any part thereof, and wants to make
|
||||
#the derivative work available to others as provided herein, then
|
||||
#Licensee hereby agrees to include in any such work a brief summary of
|
||||
#the changes made to Python.
|
||||
#
|
||||
#4. PSF is making Python available to Licensee on an "AS IS"
|
||||
#basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
||||
#IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
|
||||
#DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||
#FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
|
||||
#INFRINGE ANY THIRD PARTY RIGHTS.
|
||||
#
|
||||
#5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
|
||||
#FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
|
||||
#A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
|
||||
#OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
||||
#
|
||||
#6. This License Agreement will automatically terminate upon a material
|
||||
#breach of its terms and conditions.
|
||||
#
|
||||
#7. Nothing in this License Agreement shall be deemed to create any
|
||||
#relationship of agency, partnership, or joint venture between PSF and
|
||||
#Licensee. This License Agreement does not grant permission to use PSF
|
||||
#trademarks or trade name in a trademark sense to endorse or promote
|
||||
#products or services of Licensee, or any third party.
|
||||
#
|
||||
#8. By copying, installing or otherwise using Python, Licensee
|
||||
#agrees to be bound by the terms and conditions of this License
|
||||
#Agreement.
|
||||
|
||||
|
||||
|
||||
# Changelog:
|
||||
# 3-12-2010 Alan Somers Copied verbatim from posixpath.py in Python 2.6.4
|
||||
|
||||
|
||||
|
||||
from os.path import *
|
||||
|
||||
def relpath(path, start=curdir):
|
||||
"""Return a relative version of a path"""
|
||||
|
||||
if not path:
|
||||
raise ValueError("no path specified")
|
||||
|
||||
start_list = abspath(start).split(sep)
|
||||
path_list = abspath(path).split(sep)
|
||||
|
||||
# Work out how much of the filepath is shared by start and path.
|
||||
i = len(commonprefix([start_list, path_list]))
|
||||
|
||||
rel_list = [pardir] * (len(start_list)-i) + path_list[i:]
|
||||
if not rel_list:
|
||||
return curdir
|
||||
return join(*rel_list)
|
Loading…
Reference in New Issue
Block a user