# Aliens vs Predator Linux - http://icculus.org/avp/ # CMake 2.8 project CMAKE_MINIMUM_REQUIRED(VERSION 2.8) # default to Release IF(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) MESSAGE(STATUS "No build type specified, defaulting to Release") SET(CMAKE_BUILD_TYPE Release CACHE STRING "Build type; one of: Debug Release RelWithDebInfo MinSizeRel" FORCE) SET_PROPERTY(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") ENDIF(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) PROJECT(avp) # required dependencies INCLUDE(FindOpenGLES.cmake) INCLUDE(FindOpenGLES2.cmake) INCLUDE(FindSDL2.cmake) INCLUDE(FindSDL) INCLUDE(FindOpenGL) INCLUDE(FindOpenAL) # Use SDL 1.2 if it is installed, else use SDL 2.0. IF(NOT SDL_TYPE) SET(SDL_TYPE AUTO CACHE STRING "SDL Version; one of: AUTO SDL SDL2") SET_PROPERTY(CACHE SDL_TYPE PROPERTY STRINGS "AUTO" "SDL" "SDL2") ENDIF(NOT SDL_TYPE) IF(NOT SDL_TYPE STREQUAL "AUTO" AND NOT SDL_TYPE STREQUAL "SDL" AND NOT SDL_TYPE STREQUAL "SDL2") MESSAGE(FATAL_ERROR "Invalid SDL_TYPE setting ${SDL_TYPE}; must be one of AUTO SDL SDL2") ENDIF(NOT SDL_TYPE STREQUAL "AUTO" AND NOT SDL_TYPE STREQUAL "SDL" AND NOT SDL_TYPE STREQUAL "SDL2") IF(SDL_FOUND) IF(SDL_VERSION_STRING VERSION_LESS "1.2.0") MESSAGE(WARNING "SDL 1.2 was claimed to be found with version ${SDL_VERSION_STRING}, ignoring...") UNSET(SDL_FOUND) ENDIF(SDL_VERSION_STRING VERSION_LESS "1.2.0") IF(SDL_VERSION_STRING VERSION_GREATER "1.2.99") MESSAGE(WARNING "SDL 1.2 was claimed to be found with version ${SDL_VERSION_STRING}, ignoring...") UNSET(SDL_FOUND) ENDIF(SDL_VERSION_STRING VERSION_GREATER "1.2.99") ENDIF(SDL_FOUND) IF(SDL_TYPE STREQUAL "AUTO") IF(SDL_FOUND) MESSAGE(STATUS "SDL 1.2 found; using that.") SET(SDL_TYPE "SDL") ENDIF(SDL_FOUND) ENDIF(SDL_TYPE STREQUAL "AUTO") IF(SDL_TYPE STREQUAL "AUTO") IF(SDL2_FOUND) MESSAGE(STATUS "SDL 2.0 found; using that.") SET(SDL_TYPE "SDL2") ENDIF(SDL2_FOUND) ENDIF(SDL_TYPE STREQUAL "AUTO") IF(SDL_TYPE STREQUAL "AUTO") MESSAGE(FATAL_ERROR "SDL 1.2 or SDL 2.0 is required but CMake couldn't find it.") ENDIF(SDL_TYPE STREQUAL "AUTO") IF(SDL_TYPE STREQUAL "SDL") IF(NOT SDL_FOUND) MESSAGE(FATAL_ERROR "SDL 1.2 was requested but CMake couldn't find it.") ENDIF(NOT SDL_FOUND) ENDIF(SDL_TYPE STREQUAL "SDL") IF(SDL_TYPE STREQUAL "SDL2") IF(NOT SDL2_FOUND) MESSAGE(FATAL_ERROR "SDL 2.0 was requested but CMake couldn't find it.") ENDIF(NOT SDL2_FOUND) MESSAGE(WARNING "SDL 2.0 support is EXPERIMENTAL and INCOMPLETE.") ENDIF(SDL_TYPE STREQUAL "SDL2") # Use Desktop OpenGL if it is available, else try OpenGL ES. IF(NOT OPENGL_TYPE) SET(OPENGL_TYPE AUTO CACHE STRING "OpenGL Version; one of: AUTO OPENGL OPENGLES") SET_PROPERTY(CACHE OPENGL_TYPE PROPERTY STRINGS "AUTO" "OPENGL" "OPENGLES") ENDIF(NOT OPENGL_TYPE) IF(NOT OPENGL_TYPE STREQUAL "AUTO" AND NOT OPENGL_TYPE STREQUAL "OPENGL" AND NOT OPENGL_TYPE STREQUAL "OPENGLES") MESSAGE(FATAL_ERROR "Invalid OPENGL_TYPE setting ${OPENGL_TYPE}; must be one of AUTO OPENGL OPENGLES") ENDIF(NOT OPENGL_TYPE STREQUAL "AUTO" AND NOT OPENGL_TYPE STREQUAL "OPENGL" AND NOT OPENGL_TYPE STREQUAL "OPENGLES") IF(OPENGL_TYPE STREQUAL "AUTO") IF(OPENGL_FOUND) MESSAGE(STATUS "OpenGL found; using that.") SET(OPENGL_TYPE "OPENGL") ENDIF(OPENGL_FOUND) ENDIF(OPENGL_TYPE STREQUAL "AUTO") IF(OPENGL_TYPE STREQUAL "AUTO") IF(OPENGLES_FOUND) MESSAGE(STATUS "OpenGL ES found; using that.") SET(OPENGL_TYPE "OPENGLES") ENDIF(OPENGLES_FOUND) ENDIF(OPENGL_TYPE STREQUAL "AUTO") IF(OPENGL_TYPE STREQUAL "AUTO") MESSAGE(FATAL_ERROR "OpenGL is required but CMake couldn't find it.") ENDIF(OPENGL_TYPE STREQUAL "AUTO") IF(OPENGL_TYPE STREQUAL "OPENGL") IF(NOT OPENGL_FOUND) MESAGE(FATAL_ERROR "OpenGL was requested but CMake couldn't find it.") ENDIF(NOT OPENGL_FOUND) ENDIF(OPENGL_TYPE STREQUAL "OPENGL") IF(OPENGL_TYPE STREQUAL "OPENGLES") IF(NOT OPENGLES_FOUND) MESSAGE(FATAL_ERROR "OpenGL ES was requested but CMake couldn't find it.") ENDIF(NOT OPENGLES_FOUND) ENDIF(OPENGL_TYPE STREQUAL "OPENGLES") # OpenAL IF(NOT OPENAL_FOUND) MESSAGE(FATAL_ERROR "OpenAL is required but CMake couldn't find it.") ENDIF(NOT OPENAL_FOUND) # required source files LIST(APPEND source src/files.c) LIST(APPEND source src/winapi.c) LIST(APPEND source src/stubs.c) LIST(APPEND source src/version.c) LIST(APPEND source src/mathline.c) LIST(APPEND source src/net.c) LIST(APPEND source src/frustum.c) LIST(APPEND source src/kshape.c) LIST(APPEND source src/map.c) LIST(APPEND source src/maths.c) LIST(APPEND source src/md5.c) LIST(APPEND source src/mem3dc.c) LIST(APPEND source src/mem3dcpp.cpp) LIST(APPEND source src/module.c) LIST(APPEND source src/morph.c) LIST(APPEND source src/object.c) LIST(APPEND source src/shpanim.c) LIST(APPEND source src/sphere.c) LIST(APPEND source src/tables.c) LIST(APPEND source src/vdb.c) LIST(APPEND source src/avp/ai_sight.c) LIST(APPEND source src/avp/avpview.c) LIST(APPEND source src/avp/bh_agun.c) LIST(APPEND source src/avp/bh_ais.c) LIST(APPEND source src/avp/bh_alien.c) LIST(APPEND source src/avp/bh_binsw.c) LIST(APPEND source src/avp/bh_cable.c) LIST(APPEND source src/avp/bh_corpse.c) LIST(APPEND source src/avp/bh_deathvol.c) LIST(APPEND source src/avp/bh_debri.c) LIST(APPEND source src/avp/bh_dummy.c) LIST(APPEND source src/avp/bh_fan.c) LIST(APPEND source src/avp/bh_far.c) LIST(APPEND source src/avp/bh_fhug.c) LIST(APPEND source src/avp/bh_gener.c) LIST(APPEND source src/avp/bh_ldoor.c) LIST(APPEND source src/avp/bh_lift.c) LIST(APPEND source src/avp/bh_light.c) LIST(APPEND source src/avp/bh_lnksw.c) LIST(APPEND source src/avp/bh_ltfx.c) LIST(APPEND source src/avp/bh_marin.c) LIST(APPEND source src/avp/bh_mission.c) LIST(APPEND source src/avp/bh_near.c) LIST(APPEND source src/avp/bh_pargen.c) LIST(APPEND source src/avp/bh_plachier.c) LIST(APPEND source src/avp/bh_plift.c) LIST(APPEND source src/avp/bh_pred.c) LIST(APPEND source src/avp/bh_queen.c) LIST(APPEND source src/avp/bh_rubberduck.c) LIST(APPEND source src/avp/bh_selfdest.c) LIST(APPEND source src/avp/bh_snds.c) LIST(APPEND source src/avp/bh_spcl.c) LIST(APPEND source src/avp/bh_swdor.c) LIST(APPEND source src/avp/bh_track.c) LIST(APPEND source src/avp/bh_types.c) LIST(APPEND source src/avp/bh_videoscreen.c) LIST(APPEND source src/avp/bh_waypt.c) LIST(APPEND source src/avp/bh_weap.c) LIST(APPEND source src/avp/bh_xeno.c) LIST(APPEND source src/avp/bonusabilities.c) LIST(APPEND source src/avp/cconvars.cpp) LIST(APPEND source src/avp/cdtrackselection.cpp) LIST(APPEND source src/avp/cheatmodes.c) LIST(APPEND source src/avp/comp_map.c) LIST(APPEND source src/avp/comp_shp.c) LIST(APPEND source src/avp/consolelog.cpp) LIST(APPEND source src/avp/davehook.cpp) LIST(APPEND source src/avp/deaths.c) LIST(APPEND source src/avp/decal.c) LIST(APPEND source src/avp/detaillevels.c) LIST(APPEND source src/avp/dynamics.c) LIST(APPEND source src/avp/dynblock.c) LIST(APPEND source src/avp/equipmnt.c) LIST(APPEND source src/avp/extents.c) LIST(APPEND source src/avp/game.c) LIST(APPEND source src/avp/game_statistics.c) LIST(APPEND source src/avp/gamecmds.cpp) LIST(APPEND source src/avp/gamevars.cpp) LIST(APPEND source src/avp/hmodel.c) LIST(APPEND source src/avp/hud.c) LIST(APPEND source src/avp/inventry.c) LIST(APPEND source src/avp/language.c) LIST(APPEND source src/avp/lighting.c) LIST(APPEND source src/avp/load_shp.c) LIST(APPEND source src/avp/los.c) LIST(APPEND source src/avp/mempool.c) LIST(APPEND source src/avp/messagehistory.c) LIST(APPEND source src/avp/missions.cpp) LIST(APPEND source src/avp/movement.c) LIST(APPEND source src/avp/paintball.c) LIST(APPEND source src/avp/particle.c) LIST(APPEND source src/avp/pfarlocs.c) LIST(APPEND source src/avp/pheromon.c) LIST(APPEND source src/avp/player.c) LIST(APPEND source src/avp/pmove.c) LIST(APPEND source src/avp/psnd.c) LIST(APPEND source src/avp/psndproj.c) LIST(APPEND source src/avp/pvisible.c) LIST(APPEND source src/avp/savegame.c) LIST(APPEND source src/avp/scream.cpp) LIST(APPEND source src/avp/secstats.c) LIST(APPEND source src/avp/sfx.c) LIST(APPEND source src/avp/stratdef.c) LIST(APPEND source src/avp/targeting.c) LIST(APPEND source src/avp/track.c) LIST(APPEND source src/avp/triggers.c) LIST(APPEND source src/avp/weapons.c) LIST(APPEND source src/avp/shapes/cube.c) LIST(APPEND source src/avp/support/consbind.cpp) LIST(APPEND source src/avp/support/consbtch.cpp) LIST(APPEND source src/avp/support/coordstr.cpp) LIST(APPEND source src/avp/support/daemon.cpp) LIST(APPEND source src/avp/support/indexfnt.cpp) LIST(APPEND source src/avp/support/r2base.cpp) LIST(APPEND source src/avp/support/r2pos666.cpp) LIST(APPEND source src/avp/support/reflist.cpp) LIST(APPEND source src/avp/support/refobj.cpp) LIST(APPEND source src/avp/support/rentrntq.cpp) LIST(APPEND source src/avp/support/scstring.cpp) LIST(APPEND source src/avp/support/strtab.cpp) LIST(APPEND source src/avp/support/strutil.c) LIST(APPEND source src/avp/support/trig666.cpp) LIST(APPEND source src/avp/support/wrapstr.cpp) LIST(APPEND source src/avp/win95/avpchunk.cpp) LIST(APPEND source src/avp/win95/cheat.c) LIST(APPEND source src/avp/win95/chtcodes.cpp) LIST(APPEND source src/avp/win95/d3d_hud.cpp) LIST(APPEND source src/avp/win95/ddplat.cpp) LIST(APPEND source src/avp/win95/endianio.c) LIST(APPEND source src/avp/win95/ffread.cpp) LIST(APPEND source src/avp/win95/ffstdio.cpp) LIST(APPEND source src/avp/win95/gammacontrol.cpp) LIST(APPEND source src/avp/win95/hierplace.cpp) LIST(APPEND source src/avp/win95/iofocus.cpp) LIST(APPEND source src/avp/win95/jsndsup.cpp) LIST(APPEND source src/avp/win95/kzsort.c) LIST(APPEND source src/avp/win95/langplat.c) LIST(APPEND source src/avp/win95/modcmds.cpp) LIST(APPEND source src/avp/win95/npcsetup.cpp) LIST(APPEND source src/avp/win95/objsetup.cpp) LIST(APPEND source src/avp/win95/pathchnk.cpp) LIST(APPEND source src/avp/win95/platsup.c) LIST(APPEND source src/avp/win95/pldghost.c) LIST(APPEND source src/avp/win95/pldnet.c) LIST(APPEND source src/avp/win95/progress_bar.cpp) LIST(APPEND source src/avp/win95/projload.cpp) LIST(APPEND source src/avp/win95/scrshot.cpp) LIST(APPEND source src/avp/win95/strachnk.cpp) LIST(APPEND source src/avp/win95/system.c) LIST(APPEND source src/avp/win95/usr_io.c) LIST(APPEND source src/avp/win95/vision.c) LIST(APPEND source src/avp/win95/frontend/avp_envinfo.c) LIST(APPEND source src/avp/win95/frontend/avp_intro.cpp) LIST(APPEND source src/avp/win95/frontend/avp_menudata.c) LIST(APPEND source src/avp/win95/frontend/avp_menus.c) LIST(APPEND source src/avp/win95/frontend/avp_mp_config.cpp) LIST(APPEND source src/avp/win95/frontend/avp_userprofile.cpp) LIST(APPEND source src/avp/win95/gadgets/ahudgadg.cpp) LIST(APPEND source src/avp/win95/gadgets/conscmnd.cpp) LIST(APPEND source src/avp/win95/gadgets/conssym.cpp) LIST(APPEND source src/avp/win95/gadgets/consvar.cpp) LIST(APPEND source src/avp/win95/gadgets/gadget.cpp) LIST(APPEND source src/avp/win95/gadgets/hudgadg.cpp) LIST(APPEND source src/avp/win95/gadgets/rootgadg.cpp) LIST(APPEND source src/avp/win95/gadgets/t_ingadg.cpp) LIST(APPEND source src/avp/win95/gadgets/teletype.cpp) LIST(APPEND source src/avp/win95/gadgets/textexp.cpp) LIST(APPEND source src/avp/win95/gadgets/textin.cpp) LIST(APPEND source src/avp/win95/gadgets/trepgadg.cpp) LIST(APPEND source src/win95/animchnk.cpp) LIST(APPEND source src/win95/animobs.cpp) LIST(APPEND source src/win95/awtexld.cpp) LIST(APPEND source src/win95/awbmpld.cpp) LIST(APPEND source src/win95/awiffld.cpp) LIST(APPEND source src/win95/awpnmld.cpp) LIST(APPEND source src/win95/bmpnames.cpp) LIST(APPEND source src/win95/chnkload.cpp) LIST(APPEND source src/win95/chnktexi.cpp) LIST(APPEND source src/win95/chnktype.cpp) LIST(APPEND source src/win95/chunk.cpp) LIST(APPEND source src/win95/chunkpal.cpp) LIST(APPEND source src/win95/db.c) LIST(APPEND source src/win95/debuglog.cpp) LIST(APPEND source src/win95/dummyobjectchunk.cpp) LIST(APPEND source src/win95/enumchnk.cpp) LIST(APPEND source src/win95/enumsch.cpp) LIST(APPEND source src/win95/envchunk.cpp) LIST(APPEND source src/win95/fail.c) LIST(APPEND source src/win95/fragchnk.cpp) LIST(APPEND source src/win95/gsprchnk.cpp) LIST(APPEND source src/win95/hierchnk.cpp) LIST(APPEND source src/win95/huffman.cpp) LIST(APPEND source src/win95/iff.cpp) LIST(APPEND source src/win95/iff_ilbm.cpp) LIST(APPEND source src/win95/ilbm_ext.cpp) LIST(APPEND source src/win95/io.c) LIST(APPEND source src/win95/list_tem.cpp) LIST(APPEND source src/win95/ltchunk.cpp) LIST(APPEND source src/win95/media.cpp) LIST(APPEND source src/win95/mishchnk.cpp) LIST(APPEND source src/win95/obchunk.cpp) LIST(APPEND source src/win95/oechunk.cpp) LIST(APPEND source src/win95/our_mem.c) LIST(APPEND source src/win95/plat_shp.c) LIST(APPEND source src/win95/plspecfn.c) LIST(APPEND source src/win95/shpchunk.cpp) LIST(APPEND source src/win95/sndchunk.cpp) LIST(APPEND source src/win95/sprchunk.cpp) LIST(APPEND source src/win95/string.cpp) LIST(APPEND source src/win95/texio.c) LIST(APPEND source src/win95/toolchnk.cpp) LIST(APPEND source src/win95/txioctrl.cpp) LIST(APPEND source src/win95/wpchunk.cpp) LIST(APPEND source src/win95/zsp.cpp) LIST(APPEND source src/opengl.c) LIST(APPEND source src/oglfunc.c) LIST(APPEND source src/fmv.c) LIST(APPEND source src/openal.c) LIST(APPEND source src/cdplayer.c) LIST(APPEND source src/menus.c) IF(SDL_TYPE STREQUAL "SDL") LIST(APPEND source src/main.c) # SDL 1.2 on OS X requires this support file IF(APPLE AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") LIST(APPEND source src/sdl12/sdlmain.m) ENDIF(APPLE AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") ENDIF(SDL_TYPE STREQUAL "SDL") IF(SDL_TYPE STREQUAL "SDL2") LIST(APPEND source src/main2.c) ENDIF(SDL_TYPE STREQUAL "SDL2") ### build all source as C++ ### (not normally used) ##SET_SOURCE_FILES_PROPERTIES(${source} PROPERTIES LANGUAGE CXX) # auto-include directories with source files FOREACH(sourcefile IN LISTS source) GET_FILENAME_COMPONENT(includedir ${sourcefile} PATH) # newer CMake uses DIRECTORY LIST(APPEND include ${includedir}) ENDFOREACH(sourcefile) INCLUDE_DIRECTORIES(${include}) # manually include src/include INCLUDE_DIRECTORIES(src/include) ADD_EXECUTABLE(avp ${source}) # required dependencies IF(SDL_TYPE STREQUAL "SDL") INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR}) ENDIF(SDL_TYPE STREQUAL "SDL") IF(SDL_TYPE STREQUAL "SDL2") INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR}) ENDIF(SDL_TYPE STREQUAL "SDL2") IF(OPENGL_TYPE STREQUAL "OPENGL") INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR}) ENDIF(OPENGL_TYPE STREQUAL "OPENGL") IF(OPENGL_TYPE STREQUAL "OPENGLES") ADD_DEFINITIONS(-DUSE_OPENGL_ES=1) INCLUDE_DIRECTORIES(${OPENGLES_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${EGL_INCLUDE_DIR}) ENDIF(OPENGL_TYPE STREQUAL "OPENGLES") INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR}) IF(SDL_TYPE STREQUAL "SDL") TARGET_LINK_LIBRARIES(avp ${SDL_LIBRARY}) ENDIF(SDL_TYPE STREQUAL "SDL") IF(SDL_TYPE STREQUAL "SDL2") TARGET_LINK_LIBRARIES(avp ${SDL2_LIBRARY}) ENDIF(SDL_TYPE STREQUAL "SDL2") IF(OPENGL_TYPE STREQUAL "OPENGL") TARGET_LINK_LIBRARIES(avp ${OPENGL_gl_LIBRARY}) ENDIF(OPENGL_TYPE STREQUAL "OPENGL") IF(OPENGL_TYPE STREQUAL "OPENGLES") TARGET_LINK_LIBRARIES(avp ${OPENGLES_gl_LIBRARY}) TARGET_LINK_LIBRARIES(avp ${EGL_LIBRARIES}) ENDIF(OPENGL_TYPE STREQUAL "OPENGLES") TARGET_LINK_LIBRARIES(avp ${OPENAL_LIBRARY})