in project have makefile looks this:
cxx = clang++ cflags = -std=c++11 common_sources = file1.cpp file2.cpp target_sources = main.cpp test_sources = run_tests.cpp test_file1.cpp test_file2.cpp common_objects = $(common_sources:.c=.o) target_objects = $(target_sources:.c=.o) test_objects = $(test_sources:.c=.o) executable = build/application test_executable = build/tests .phony: target tests all: target tests target: $(executable) tests: $(test_executable) clean: rm build/tests & rm build/application & $(executable): $(common_objects) $(target_objects) $(cxx) $(cflags) $(ldflags) $^ -o $@ $(test_executable): $(common_objects) $(test_objects) $(cxx) $(cflags) $(ldflags) $^ -o $@ .c.o: $(cxx) $(cflags) $< -o $@ this lets me run make tests or make target , build appropriate executable.
how set cmakelists file same convenient build system?
except using clang++, think if put following in cmakelists.txt file , run cmake configure step in build directory (i.e., mkdir build; cd build; cmake ..), should have asking for.
project(myproject) # not sure how cmake use clang++ on g++ # cxx = clang++ add_definitions(-std=c++11) set(common_sources file1.cpp file2.cpp) set(target_sources main.cpp) set(test_sources run_tests.cpp test_file1.cpp test_file2.cpp) add_executable(application ${common_sources} ${target_sources}) add_executable(tests ${common_sources} ${test_sources})
Comments
Post a Comment