3dfsb-dev/3dfsb

Buildsystem support

Closed this issue · 3 comments

A "proper" build system should make things easier for developers and distributors.

  • Support multiple compilers such as gcc, clang, or icc without patching a compile script
  • Multiple configurations and trivial switching, e.g.
    • "debug" with -ggdb3 and -fsanitize=undefined
    • "release" with -O2 and no debugging
  • easier cross compilation
  • cross platform support with e.g. cmake (potential windows support)
  • sub targets
    • convert images once unless changed
    • compile str_replace once unless changed
    • clean up generated files and executables
  • optional features
    • e.g. make libmagic optional
  • easier debugging (hint :-) )
  • distribution side tool support for cmake or autotools vs full-custom script (hint :-) )

Thanks for the great list of requirements. I agree.

Would a simple Makefile do it for you, or do you really want cmake or autotools...? Do you have any suggestions on what to use or an example project that does it in a good way that matches your requirements?

I think that a simple Makefile would make things rather difficult in the long run, especially with cross platform stuff (if you don't happen to be running freebsd or Haiku as well.

To make it easier I cooked up this CMakeLists.txt in a few minutes (terrible hack)

cmake_minimum_required(VERSION 2.8)

project(3dfsb C)

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
find_package(SDL REQUIRED)
find_package(SDL_image REQUIRED)
find_package(OpenGL REQUIRED)
find_package(GLUT)
find_package(GStreamer REQUIRED)
find_package(LibMagic REQUIRED)
find_package(ImageMagick COMPONENTS mogrify REQUIRED)

include_directories(${SDL_INCLUDE_DIR}
                    ${GSTREAMER_INCLUDE_DIRS}
                   )

add_custom_command(OUTPUT images
                   COMMAND mogrify -format xpm *
                   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/images
                  )

add_library(str_replace str_replace.c)

add_executable(3dfsb 3dfsb.c)
add_dependencies(3dfsb images)
target_link_libraries(3dfsb str_replace ${SDL_LIBRARY} ${SDL_IMAGE_LIBRARIES} ${OPENGL_LIBRARIES} ${GSTREAMER_LIBRARIES} ${GLUT_glut_LIBRARY} ${LibMagic_LIBRARY})

I used https://github.com/WebKit/webkit/blob/master/Source/cmake/FindGStreamer.cmake
and https://github.com/bro/cmake/blob/master/FindLibMagic.cmake

Configures and builds for me. Can't get it to run but I think it's a good start. Had to work around GLUT b/c some problems regarding Xmu but that's specific to my system I think.

Like I said, tons of space for improvement ... but you got to start somewhere :-).

CMake compilation works now, and the old compile.sh script is also still present, for people who don't want to install CMake. I guess improvements could be made, but indeed, we've got to start somewhere :-)