From cf5bfd5b7913ce020c1d3a333b3d774a1641a5ed Mon Sep 17 00:00:00 2001 From: anonimal Date: Wed, 20 Feb 2019 02:32:35 +0000 Subject: [PATCH 1/3] CMake: make test building optional --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6adb8998..4a0376c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -201,8 +201,11 @@ else() endif() endif() +set(BUILD_TESTS FALSE CACHE BOOL "Build Zano tests") add_subdirectory(contrib) add_subdirectory(src) -add_subdirectory(tests) +if (BUILD_TESTS) + add_subdirectory(tests) +endif() From 2c79dbc5a7abb350979f0de47011c6721fe7f048 Mon Sep 17 00:00:00 2001 From: anonimal Date: Wed, 20 Feb 2019 02:32:59 +0000 Subject: [PATCH 2/3] Makefile: refactor for extensibility + CMake MSYS --- Makefile | 51 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 451319b0..4e093a59 100644 --- a/Makefile +++ b/Makefile @@ -1,28 +1,43 @@ -all: all-release +# Define CMake generator +system := $(shell uname) +ifneq (, $(findstring MINGW, $(system))) + cmake_gen = -G 'MSYS Makefiles' +endif -cmake-debug: - mkdir -p build/debug - cd build/debug && cmake -D CMAKE_BUILD_TYPE=Debug ../.. +cmake = cmake $(cmake_gen) -build-debug: cmake-debug - cd build/debug && $(MAKE) +cmake_debug = $(cmake) -D CMAKE_BUILD_TYPE=Debug +cmake_release = $(cmake) -D CMAKE_BUILD_TYPE=Release +cmake_tests = $(cmake) -D BUILD_TESTS=ON -test-debug: build-debug - cd build/debug && $(MAKE) test +# Helper macro +define CMAKE + mkdir -p $1 && cd $1 && $2 ../../ +endef -all-debug: build-debug +build = build +dir_debug = $(build)/debug +dir_release = $(build)/release -cmake-release: - mkdir -p build/release - cd build/release && cmake -D CMAKE_BUILD_TYPE=Release ../.. +all: release -build-release: cmake-release - cd build/release && $(MAKE) +release: + $(eval command += $(cmake_release)) + $(call CMAKE,$(dir_release),$(command)) && $(MAKE) -test-release: build-release - cd build/release && $(MAKE) test +test-release: + $(eval command += $(cmake_release) $(cmake_tests)) + $(call CMAKE,$(dir_release),$(command)) && $(MAKE) && $(MAKE) test -all-release: build-release +test: test-release + +debug: + $(eval command += $(cmake_debug)) + $(call CMAKE,$(dir_debug),$(command)) && $(MAKE) + +test-debug: + $(eval command += $(cmake_debug) $(cmake_tests)) + $(call CMAKE,$(dir_debug),$(command)) && $(MAKE) && $(MAKE) test clean: rm -rf build @@ -30,4 +45,4 @@ clean: tags: ctags -R --sort=1 --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ src contrib tests/gtest -.PHONY: all cmake-debug build-debug test-debug all-debug cmake-release build-release test-release all-release clean tags +.PHONY: all release test-release test all-debug debug test-debug clean tags From 71daaa827d369fd15e6ce9126f3fc13d2b75e3e4 Mon Sep 17 00:00:00 2001 From: anonimal Date: Wed, 20 Feb 2019 02:42:47 +0000 Subject: [PATCH 3/3] Makefile: add copyright --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile b/Makefile index 4e093a59..7eff3b9e 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,8 @@ +# Copyright (c) 2014-2019 Zano Project +# Copyright (c) 2014 The Cryptonote developers +# Distributed under the MIT/X11 software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + # Define CMake generator system := $(shell uname) ifneq (, $(findstring MINGW, $(system)))