From 77ef88559f346ff33e5f648dabe5e7edda223dc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Papierski?= Date: Fri, 7 Nov 2014 23:56:02 +0100 Subject: [PATCH 1/2] Removed Makefiles and replaced it with CMake. --- .gitignore | 1 + .travis.yml | 17 +++++++--- CMakeLists.txt | 20 ++++++++++++ Makefile | 53 -------------------------------- Makefile.win | 37 ---------------------- libtap.vcxproj | 80 ------------------------------------------------ t/CMakeLists.txt | 49 +++++++++++++++++++++++++++++ 7 files changed, 82 insertions(+), 175 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 Makefile delete mode 100644 Makefile.win delete mode 100644 libtap.vcxproj create mode 100644 t/CMakeLists.txt diff --git a/.gitignore b/.gitignore index 2e45fcb..8507381 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ *.a *.o *.sw? +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..79be61f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,20 @@ +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) + +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 750ae44..0000000 --- a/Makefile +++ /dev/null @@ -1,53 +0,0 @@ -CFLAGS = -g -Wall -I. -CC = gcc -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 tests - -libtap.a: 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 libtap.a $(TESTS) - -install: libtap.a tap.h - sudo cp libtap.a /usr/lib - sudo cp tap.h /usr/include - -uninstall: - sudo rm /usr/lib/libtap.a /usr/include/tap.h - -dist: - rm libtap.zip - zip -r libtap * - -check test: all - prove - -.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/libtap.vcxproj b/libtap.vcxproj deleted file mode 100644 index a790da4..0000000 --- a/libtap.vcxproj +++ /dev/null @@ -1,80 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {4DFC985A-83D7-4E61-85FE-C6EA6E43E3AA} - Win32Proj - libtap - - - - StaticLibrary - true - Unicode - - - StaticLibrary - false - true - Unicode - - - - - - - - - - - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - - - Windows - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - - - Windows - true - true - true - - - - - - - - - - - - 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) From a5dd9d01ea8ca26ecafb2501c4ea706f8b1ab759 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Fri, 16 Dec 2016 21:25:42 +0200 Subject: [PATCH 2/2] [CMake] install the header. --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 79be61f..7c90dc4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,8 @@ add_library (tap tap.h) install (TARGETS tap DESTINATION lib) +install (FILES tap.h + DESTINATION "include") if (LIBTAP_TESTS) enable_testing ()