KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am using cmake to build my project. For UNIX, I would like to type make from my project's root directory, and have cmake invoked to create the proper Makefiles (if they don't exist yet) and then build my project. I would like the cmake "internal" files (object files, cmake internal Makefiles, etc.) to be hidden (e.g. put in a .build directory) so it doesn't clutter my project directory. My project has several sub-projects (in particular, a library, a user executable, and a unit test executable). I would like Makefiles (i.e. I type make and this happens) for each sub-project to execute cmake (as above) and build only that sub-project (with dependencies, so the library would be built from the executables' Makefiles, if needed). The resulting binary (.so library or executable) should be in the sub-project's directory. I made a Makefile which does the main project bit somewhat well, though it feels somewhat hackish. I can't build specific targets using it, because my Makefile simply calls make in cmake 's build directory. Note that because the library is a sole dependency (and probably doesn't need to be build manually, and because I'm lazy) I omitted it in my Makefile. BUILD_DIR := .build .PHONY: all clean project-gui ${BUILD_DIR}/Makefile all: project-gui project-test clean: @([ -d ${BUILD_DIR} ] && make -C ${BUILD_DIR} clean && rm -r ${BUILD_DIR}) || echo Nothing to clean project-gui: ${BUILD_DIR}/Makefile @make -C ${BUILD_DIR} project-gui @cp ${BUILD_DIR}/project-gui/project-gui $@ project-test: ${BUILD_DIR}/Makefile @make -C ${BUILD_DIR} project-test @cp ${BUILD_DIR}/project-test/project-test $@ ${BUILD_DIR}/Makefile: @[ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR} @[ -f ${BUILD_DIR}/Makefile ] || (cd ${BUILD_DIR} && cmake ${C
Tags (comma-separated)
Save Edits
Cancel