diff --git a/.gitignore b/.gitignore index 2c95d04..1d8a575 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ usr/ *.sw? /.deps /.dirstamp +build/ diff --git a/.travis.yml b/.travis.yml index 6f9809e..d7be915 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,10 +4,17 @@ compiler: - gcc - clang -before_install: sudo apt-get install -y libtest-differences-perl +before_install: + - sudo apt-get update -qq + - sudo apt-get install -qq -y cmake libtest-differences-perl -install: make CC=$CC install +env: + - BUILD_TYPE="Debug" + - BUILD_TYPE="Release" -script: make CC=$CC test - -after_script: make uninstall +script: + - mkdir _build + - cd _build + - cmake -DCMAKE_INSTALL_PREFIX="../_install" -DCMAKE_BUILD_TYPE="$BUILD_TYPE" $OPTIONS .. + - cmake --build . + - cmake --build . --target install diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..7c90dc4 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required (VERSION 2.6) +project (tap C) + +option (LIBTAP_TESTS "Build libtap tests" OFF) + +include_directories ( + ${CMAKE_CURRENT_SOURCE_DIR}) + +add_library (tap + tap.c + tap.h) +install (TARGETS tap + DESTINATION lib) +install (FILES tap.h + DESTINATION "include") + +if (LIBTAP_TESTS) + enable_testing () + add_subdirectory (t) + add_test (prove + ${CMAKE_COMMAND} -E chdir ${CMAKE_CURRENT_SOURCE_DIR} prove) +endif () diff --git a/Makefile b/Makefile deleted file mode 100644 index c00bef1..0000000 --- a/Makefile +++ /dev/null @@ -1,72 +0,0 @@ -CC ?= gcc -CFLAGS += -Wall -I. -fPIC -PREFIX ?= $(DESTDIR)/usr/local -TESTS = $(patsubst %.c, %, $(wildcard t/*.c)) - -ifdef ANSI - # -D_BSD_SOURCE for MAP_ANONYMOUS - CFLAGS += -ansi -D_BSD_SOURCE - LDLIBS += -lbsd-compat -endif - -%: - $(CC) $(LDFLAGS) $(TARGET_ARCH) $(filter %.o %.a %.so, $^) $(LDLIBS) -o $@ - -%.o: - $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $(filter %.c, $^) $(LDLIBS) -o $@ - -%.a: - $(AR) rcs $@ $(filter %.o, $^) - -%.so: - $(CC) -shared $(LDFLAGS) $(TARGET_ARCH) $(filter %.o, $^) $(LDLIBS) -o $@ - -all: libtap.a libtap.so tap.pc tests - -tap.pc: - @echo generating tap.pc - @echo 'prefix='$(PREFIX) > tap.pc - @echo 'exec_prefix=$${prefix}' >> tap.pc - @echo 'libdir=$${prefix}/lib' >> tap.pc - @echo 'includedir=$${prefix}/include' >> tap.pc - @echo '' >> tap.pc - @echo 'Name: libtap' >> tap.pc - @echo 'Description: Write tests in C' >> tap.pc - @echo 'Version: 0.1.0' >> tap.pc - @echo 'URL: https://github.com/zorgnax/libtap' >> tap.pc - @echo 'Libs: -L$${libdir} -ltap' >> tap.pc - @echo 'Cflags: -I$${includedir}' >> tap.pc - -libtap.a: tap.o - -libtap.so: tap.o - -tap.o: tap.c tap.h - -tests: $(TESTS) - -$(TESTS): %: %.o libtap.a - -$(patsubst %, %.o, $(TESTS)): %.o: %.c tap.h - -clean: - rm -rf *.o t/*.o tap.pc libtap.a libtap.so $(TESTS) - -install: libtap.a tap.h libtap.so tap.pc - mkdir -p $(PREFIX)/lib $(PREFIX)/include $(PREFIX)/lib/pkgconfig - install -c libtap.a $(PREFIX)/lib - install -c libtap.so $(PREFIX)/lib - install -c tap.pc $(PREFIX)/lib/pkgconfig - install -c tap.h $(PREFIX)/include - -uninstall: - rm $(PREFIX)/lib/libtap.a $(PREFIX)/lib/libtap.so $(PREFIX)/include/tap.h - -dist: - rm libtap.zip - zip -r libtap * - -check test: all - ./t/test - -.PHONY: all clean install uninstall dist check test tests diff --git a/Makefile.win b/Makefile.win deleted file mode 100644 index 694d679..0000000 --- a/Makefile.win +++ /dev/null @@ -1,37 +0,0 @@ -CFLAGS = /Zi /Wall /wd4255 /wd4996 /wd4127 /wd4820 /wd4100 /wd4619 \ - /wd4514 /wd4668 /I. -CC = cl /nologo -TESTS = $(patsubst %.c, %.exe, $(wildcard t/*.c)) - -%.exe: - $(CC) $(LDFLAGS) $(filter %.obj %.lib %.dll, $^) $(LDLIBS) /Fe $@ - -%.o: - $(CC) $(CFLAGS) $(CPPFLAGS) /c $(filter %.c, $^) $(LDLIBS) /Fo $@ - -%.lib: - lib /nologo /out:$@ $(filter %.obj, $^) - -%.dll: - lib /nologo /out:$@ $(filter %.obj, $^) - -all: tap.lib tests - -tap.lib: tap.obj - -tap.obj: tap.c tap.h - -tests: $(TESTS) - -$(TESTS): %.exe: %.obj tap.lib - -$(patsubst %.exe, %.obj, $(TESTS)): %.obj: %.c tap.h - -clean: - rm -rf *.obj t/*.obj tap.lib $(TESTS) - -check test: all - prove - -.PHONY: all clean check test tests - diff --git a/t/CMakeLists.txt b/t/CMakeLists.txt new file mode 100644 index 0000000..543fe39 --- /dev/null +++ b/t/CMakeLists.txt @@ -0,0 +1,49 @@ +add_executable (cmp_mem + cmp_mem.c) +target_link_libraries (cmp_mem + tap) + +add_executable (cmpok + cmpok.c) +target_link_libraries (cmpok + tap) + +add_executable (diesok + diesok.c) +target_link_libraries (diesok + tap) + +add_executable (is + is.c) +target_link_libraries (is + tap) + +add_executable (like + like.c) +target_link_libraries (like + tap) + +add_executable (notediag + notediag.c) +target_link_libraries (notediag + tap) + +add_executable (simple + simple.c) +target_link_libraries (simple + tap) + +add_executable (skip + skip.c) +target_link_libraries (skip + tap) + +add_executable (synopsis + synopsis.c) +target_link_libraries (synopsis + tap) + +add_executable (todo + todo.c) +target_link_libraries (todo + tap)