I have been working on testing out cmake as a build system for Warzone. Its main advantage is that it can generated project files for other build systems, such as MSVC, KDevelop and Xcode. This means that we no longer would have the situation where a developer on one build system breaks the compile for all other build systems when a file is removed, renamed, moved or added. It should also help keep the build systems in sync when it comes to other things, but I am less clear on how this actually works on other platforms.
It is very clean and neat. I have a pure cmake local tree with 46 deleted files and 3 added. Although one more file still needs to be added to support gettext and the po/ directory. Installation ("make install") remains to be added in, and lots of stuff needs to be cleaned up and tested more before real use is recommended. But have a look. The worst that could happen is that you like it ;-) To test, apply diff and run "cmake . && make". - Per
Index: CMakeLists.txt =================================================================== --- CMakeLists.txt (revision 0) +++ CMakeLists.txt (revision 0) @@ -0,0 +1,64 @@ +PROJECT(warzone2100) +INCLUDE (CheckLibraryExists) +SET(CMAKE_COLOR_MAKEFILE TRUE) + +FIND_PACKAGE(PNG REQUIRED) +FIND_PACKAGE(JPEG REQUIRED) +FIND_PACKAGE(SDL REQUIRED) +FIND_PACKAGE(SDL_net REQUIRED) +FIND_PACKAGE(OpenGL REQUIRED) +FIND_PACKAGE(OpenAL REQUIRED) +FIND_PACKAGE(PhysFS REQUIRED) + +OPTION( PROJECT_DEBUG "Build the project using debugging code" ON ) +IF (PROJECT_DEBUG) + SET( CMAKE_BUILD_TYPE Debug ) + ADD_DEFINITIONS(-DDEBUG) +ENDIF (PROJECT_DEBUG) + +CHECK_LIBRARY_EXISTS(vorbisfile ov_info "" WZ_OGG) +IF (NOT WZ_OGG) + ADD_DEFINITIONS(-DWZ_NOOGG) + MESSAGE(SEND_ERROR "Could not find Ogg Vorbis library!") +ENDIF (NOT WZ_OGG) + +CHECK_LIBRARY_EXISTS(mad mad_frame_init "" WZ_MAD) +IF (NOT WZ_MAD) + ADD_DEFINITIONS(-DWZ_NOMAD) + MESSAGE(STATUS "Could not find Mad library.") +ENDIF (NOT WZ_MAD) + +ADD_DEFINITIONS(-DLOCALEDIR=\\\"/usr/local/share/locale\\\" -D_REENTRANT -DYY_STATIC) +ADD_DEFINITIONS(-DVERSION=\\\"TRUNK\\\" -DENABLE_NLS -DPACKAGE=\\\"warzone2100\\\") +# -D_GNU_SOURCE? +IF (MACOSX) + ADD_DEFINITIONS(-DWZ_OPENAL_MAC_H) +ENDIF (MACOSX) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) + +FIND_PROGRAM( + YACC_EXECUTABLE + NAMES bison yacc + PATHS /usr/bin + DOC "Bison executable" +) +FIND_PROGRAM( + FLEX_EXECUTABLE + NAMES flex + PATHS /usr/bin + DOC "Flex executable" +) +IF (NOT YACC_EXECUTABLE) + MESSAGE(SEND_ERROR "No yacc program found. We suggest you install GNU Bison.") +ENDIF (NOT YACC_EXECUTABLE) +IF (NOT FLEX_EXECUTABLE) + MESSAGE(SEND_ERROR "No flex program found. We suggest you install GNU Flex.") +ENDIF (NOT FLEX_EXECUTABLE) + +ADD_SUBDIRECTORY( win32 ) +ADD_SUBDIRECTORY( lib ) +ADD_SUBDIRECTORY( src ) +ADD_SUBDIRECTORY( data ) +ADD_SUBDIRECTORY( nsis ) + +INSTALL_FILES( AUTHORS ChangeLog README COPYING COPYING.README ) Index: lib/CMakeLists.txt =================================================================== --- lib/CMakeLists.txt (revision 0) +++ lib/CMakeLists.txt (revision 0) @@ -0,0 +1,113 @@ +INCLUDE_DIRECTORIES(framework script sequence ivis_common ivis_opengl gamelib sound netplay widget) + +SET(WZLIB_SRCS +gamelib/ptrlist.c +gamelib/pqueue.c +gamelib/gtime.c +gamelib/animobj.c +gamelib/anim.c +gamelib/hashtabl.c +ivis_common/piestate.c +ivis_common/bitimage.c +ivis_common/pieclip.c +ivis_common/imdload.c +ivis_common/imd.c +ivis_common/pcx.c +widget/editbox.c +widget/form.c +widget/bar.c +widget/scrap.c +widget/button.c +widget/label.c +widget/slider.c +widget/widget.c +widget/tip.c +script/interp.c +script/script.c +script/stack.c +script/event.c +script/codeprint.c +script/evntsave.c +sequence/rpl_reader.c +sequence/dec130.c +sequence/sequence_stub.c +sequence/adpcm.c +sound/audio.c +sound/openal_track.c +sound/playlist.c +sound/track.c +sound/cdaudio.c +sound/audio_id.c +netplay/netjoin_stub.c +netplay/netusers_stub.c +netplay/netcrypt.c +netplay/netlog.c +netplay/netplay.c +netplay/netaudio_stub.c +framework/frameresource.c +framework/SDL_framerate.c +framework/treap.c +framework/heap.c +framework/debug.c +framework/input.c +framework/configfile.c +framework/trig.c +framework/strres.c +framework/frame.c +framework/exceptionhandler.c +ivis_opengl/pieblitfunc.c +ivis_opengl/pietexture.c +ivis_opengl/tex.c +ivis_opengl/piematrix.c +ivis_opengl/textdraw.c +ivis_opengl/rendfunc.c +ivis_opengl/piestate.c +ivis_opengl/bspimd.c +ivis_opengl/screen.c +ivis_opengl/piemode.c +ivis_opengl/ivi.c +ivis_opengl/piefunc.c +ivis_opengl/piedraw.c +ivis_opengl/piepalette.c +ivis_opengl/rendmode.c +) + +SET(warzone2100_YACC framework/resource framework/strres gamelib/audp script/chat script/script) +SET(warzone2100_FLEX framework/resource framework/strres gamelib/audp script/chat script/script) + +# find a way not to duplicate the code below with identical code in src/CMakeLists.txt + +SET(yacc_files) +FOREACH(name ${warzone2100_YACC}) + SET(src "${CMAKE_CURRENT_SOURCE_DIR}/${name}_parser.y") + SET(dst "${CMAKE_CURRENT_BINARY_DIR}/${name}_parser.tab.c") + SET(hdr "${CMAKE_CURRENT_BINARY_DIR}/${name}_parser.tab.h") + ADD_CUSTOM_COMMAND( + OUTPUT "${dst}" + DEPENDS "${src}" + COMMAND ${YACC_EXECUTABLE} + ARGS -d -o"${dst}" "${src}" + ) +# MESSAGE(STATUS, "${YACC_EXECUTABLE} : Creating ${dst} and ${hdr} from ${src}") + SET(yacc_files ${yacc_files} "${dst}" "${hdr}") +ENDFOREACH(name) +SET_SOURCE_FILES_PROPERTIES(${yacc_files} PROPERTIES GENERATED true) +ADD_CUSTOM_TARGET(RerunYacc DEPENDS ${yacc_files}) + +SET(lex_files) +FOREACH(name ${warzone2100_FLEX}) + SET(src "${CMAKE_CURRENT_SOURCE_DIR}/${name}_lexer.l") + SET(dst "${CMAKE_CURRENT_BINARY_DIR}/${name}_lexer.lex.c") + ADD_CUSTOM_COMMAND( + OUTPUT "${dst}" + DEPENDS "${src}" + COMMAND ${FLEX_EXECUTABLE} + ARGS -o"${dst}" "${src}" + ) +# MESSAGE(STATUS, "${FLEX_EXECUTABLE} : Creating ${dst} from ${src}") + SET(lex_files ${lex_files} "${dst}") +ENDFOREACH(name) +SET_SOURCE_FILES_PROPERTIES(${lex_files} PROPERTIES GENERATED true) +ADD_CUSTOM_TARGET(RerunLex DEPENDS ${lex_files}) + +ADD_LIBRARY(wzframework ${WZLIB_SRCS} ${lex_files} ${yacc_files}) Index: src/CMakeLists.txt =================================================================== --- src/CMakeLists.txt (revision 0) +++ src/CMakeLists.txt (revision 0) @@ -0,0 +1,180 @@ +SET(warzone2100_SRCS +ai.c +aiexperience.c +astar.c +action.c +advvis.c +atmos.c +bridge.c +buildpos.c +cdspan.c +cheat.c +cluster.c +cmddroid.c +combat.c +component.c +console.c +data.c +design.c +difficulty.c +disp2d.c +display.c +droid.c +e3demo.c +edit2d.c +edit3d.c +effects.c +environ.c +fpath.c +feature.c +findpath.c +formation.c +frontend.c +gateway.c +gatewayroute.c +gatewaysup.c +geometry.c +group.c +hci.c +init.c +intdisplay.c +intimage.c +intorder.c +intelmap.c +keybind.c +keymap.c +levels.c +lighting.c +loop.c +main.c +map.c +mapdisplay.c +mapgrid.c +mechanics.c +message.c +miscimd.c +move.c +multiint.c +multimenu.c +multiopt.c +multisync.c +multibot.c +multistat.c +objmem.c +objects.c +optimisepath.c +order.c +player.c +powercrypt.c +radar.c +raycast.c +research.c +scores.c +scriptai.c +scriptcb.c +scriptextern.c +scriptfuncs.c +scriptobj.c +scripttabs.c +scriptvals.c +selection.c +stats.c +text.c +texture.c +transporter.c +visibility.c +warcam.c +wrappers.c +ani.c +arrow.c +aud.c +bucket3d.c +clparse.c +configuration.c +csnap.c +display3d.c +drive.c +function.c +game.c +ingameop.c +keyedit.c +loadsave.c +mission.c +multigifts.c +multijoin.c +multilimit.c +multiplay.c +multistruct.c +oprint.c +power.c +projectile.c +seqdisp.c +structure.c +target.c +warzoneconfig.c +) + +SET(warzone2100_YACC scriptvals) +SET(warzone2100_FLEX scriptvals level) + +SET(yacc_files) +FOREACH(name ${warzone2100_YACC}) + SET(src "${CMAKE_CURRENT_SOURCE_DIR}/${name}_parser.y") + SET(dst "${CMAKE_CURRENT_BINARY_DIR}/${name}_parser.tab.c") + SET(hdr "${CMAKE_CURRENT_BINARY_DIR}/${name}_parser.tab.h") + ADD_CUSTOM_COMMAND( + OUTPUT "${dst}" + DEPENDS "${src}" + COMMAND ${YACC_EXECUTABLE} + ARGS -d -o"${dst}" "${src}" + ) +# MESSAGE(STATUS, "${YACC_EXECUTABLE} : Creating ${dst} and ${hdr} from ${src}") + SET(yacc_files ${yacc_files} "${dst}" "${hdr}") +ENDFOREACH(name) +SET_SOURCE_FILES_PROPERTIES(${yacc_files} PROPERTIES GENERATED true) +ADD_CUSTOM_TARGET(RerunYacc DEPENDS ${yacc_files}) + +SET(lex_files) +FOREACH(name ${warzone2100_FLEX}) + SET(src "${CMAKE_CURRENT_SOURCE_DIR}/${name}_lexer.l") + SET(dst "${CMAKE_CURRENT_BINARY_DIR}/${name}_lexer.lex.c") + ADD_CUSTOM_COMMAND( + OUTPUT "${dst}" + DEPENDS "${src}" + COMMAND ${FLEX_EXECUTABLE} + ARGS -o"${dst}" "${src}" + ) +# MESSAGE(STATUS, "${FLEX_EXECUTABLE} : Creating ${dst} from ${src}") + SET(lex_files ${lex_files} "${dst}") +ENDFOREACH(name) +SET_SOURCE_FILES_PROPERTIES(${lex_files} PROPERTIES GENERATED true) +ADD_CUSTOM_TARGET(RerunLex DEPENDS ${lex_files}) + +ADD_EXECUTABLE(warzone2100 ${warzone2100_SRCS} ${lex_files} ${yacc_files}) +LINK_DIRECTORIES(../lib) +IF (WZ_OGG) + TARGET_LINK_LIBRARIES(warzone2100 vorbisfile vorbis ogg) +ENDIF (WZ_OGG) +IF (WZ_MAD) + TARGET_LINK_LIBRARIES(warzone2100 mad) +ENDIF (WZ_MAD) +INCLUDE_DIRECTORIES( + ${PNG_INCLUDE_DIR} + ${JPEG_INCLUDE_DIR} + ${SDL_INCLUDE_DIR} + ${SDLNET_INCLUDE_DIR} + ${OPENGL_INCLUDE_DIR} + ${OPENAL_INCLUDE_DIR} + ${PHYSFS_INCLUDE_DIR} +) +TARGET_LINK_LIBRARIES(warzone2100 + ${PNG_LIBRARY} + ${JPEG_LIBRARY} + ${SDL_LIBRARY} + ${SDLNET_LIBRARY} + ${OPENGL_LIBRARY} + ${OPENAL_LIBRARY} + ${PHYSFS_LIBRARY} + wzframework +) +INSTALL_TARGETS(/usr/local/bin warzone2100)
_______________________________________________ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev