For blender we currently support 2 build systems - SCons and CMake, Quite a few technical users build from source on *nix just to get the latest version and use scons, I suspect this is because scons configures every time and its simple just to type "scons" in the source dir and end up with a build. We have SCons configured to do an out-of-source build by default with a predefined directory.
I wasn't aware of anything similar for CMake so I write a GNUmakefile (included below) in the root source dir to do something similar for CMake. (note, we don't allow in-source builds at the moment so there is no conflict with possible in-source makefiles). This makefile creates a per-defined out-of-source build dir if necessary and runs make, since we explicitly list source files and headers in the CMakeLists.txt cmake will re-configure if needed. So my questions are... - Do other projects do this? is there some preferred way to do this? - Is it possible to setup the CMakeLists.txt so the generated makefiles are written to a directory other then the CWD? - Is there any way to default to our-of-source build when running "cmake ." in the source dir? (rather then aborting which is what we do now). Probably our users should just get the hang on setting up out of source builds but I think they like the convenience. # ------------ # This Makefile does an out-of-source CMake build in ../build/`OS`_`CPU` # eg: # ../build/Linux_i386 # This is for users who like to configure & build blender with a single command. # System Vars OS:=$(shell uname -s) OS_NCASE:=$(shell uname -s | tr '[A-Z]' '[a-z]') # Source and Build DIR's BLENDER_DIR:=$(shell pwd -P) BUILD_DIR:=$(shell dirname $(BLENDER_DIR))/build/$(OS_NCASE) # Get the number of cores for threaded build NPROCS:=1 ifeq ($(OS), Linux) NPROCS:=$(shell grep -c ^processor /proc/cpuinfo) endif ifeq ($(OS), Darwin) NPROCS:=$(shell system_profiler | awk '/Number Of CPUs/{print $4}{next;}') endif ifeq ($(OS), FreeBSD) NPROCS:=$(shell sysctl -a | grep "hw.ncpu " | cut -d" " -f3 ) endif ifeq ($(OS), NetBSD) NPROCS:=$(shell sysctl -a | grep "hw.ncpu " | cut -d" " -f3 ) endif # Build Blender all: @echo @echo Configuring Blender ... if test ! -f $(BUILD_DIR)/CMakeCache.txt ; then \ mkdir -p $(BUILD_DIR) ; \ cd $(BUILD_DIR) ; \ cmake $(BLENDER_DIR) -DCMAKE_BUILD_TYPE:STRING=Release ; \ fi @echo @echo Building Blender ... cd $(BUILD_DIR) ; make -s -j $(NPROCS) @echo @echo run blender from "$(BUILD_DIR)/bin/blender" @echo .PHONY: all # ------------ - Campbell _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake