Browse Source

Remove obsoleted build systems

After the switch to cmake, we don't need the hand-written Makefile
nor the contrib/ version of the cmake file.
Benno Evers 4 years ago
parent
commit
cab80f33cd
4 changed files with 18 additions and 113 deletions
  1. 0 41
      Makefile
  2. 18 34
      README.md
  3. 0 26
      contrib/CMakeLists.txt
  4. 0 12
      numpy_flags.py

+ 0 - 41
Makefile

@@ -1,41 +0,0 @@
-# Use C++11, dont warn on long-to-float conversion
-CXXFLAGS += -std=c++11 -Wno-conversion
-
-# Default to using system's default version of python
-PYTHON_BIN     ?= python3
-PYTHON_CONFIG  := $(PYTHON_BIN)-config
-PYTHON_INCLUDE ?= $(shell $(PYTHON_CONFIG) --includes)
-EXTRA_FLAGS    := $(PYTHON_INCLUDE)
-# NOTE: Since python3.8, the correct invocation is `python3-config --libs --embed`.
-# So of course the proper way to get python libs for embedding now is to
-# invoke that, check if it crashes, and fall back to just `--libs` if it does.
-LDFLAGS        += $(shell if $(PYTHON_CONFIG) --ldflags --embed >/dev/null; then $(PYTHON_CONFIG) --ldflags --embed; else $(PYTHON_CONFIG) --ldflags; fi)
-
-# Either finds numpy or set -DWITHOUT_NUMPY
-EXTRA_FLAGS     += $(shell $(PYTHON_BIN) $(CURDIR)/numpy_flags.py)
-WITHOUT_NUMPY   := $(findstring $(EXTRA_FLAGS), WITHOUT_NUMPY)
-
-# Examples requiring numpy support to compile
-EXAMPLES_NUMPY  := surface colorbar
-EXAMPLES        := minimal basic modern animation nonblock xkcd quiver bar \
-	           fill_inbetween fill update subplot2grid lines3d \
-                   $(if $(WITHOUT_NUMPY),,$(EXAMPLES_NUMPY))
-
-# Prefix every example with 'examples/build/'
-EXAMPLE_TARGETS := $(patsubst %,examples/build/%,$(EXAMPLES))
-
-.PHONY: examples
-
-examples: $(EXAMPLE_TARGETS)
-
-docs:
-	doxygen
-	moxygen doc/xml --noindex -o doc/api.md
-
-# Assume every *.cpp file is a separate example
-$(EXAMPLE_TARGETS): examples/build/%: examples/%.cpp matplotlibcpp.h
-	mkdir -p examples/build
-	$(CXX) -o $@ $< $(EXTRA_FLAGS) $(CXXFLAGS) $(LDFLAGS)
-
-clean:
-	rm -f ${EXAMPLE_TARGETS}

+ 18 - 34
README.md

@@ -202,39 +202,34 @@ If, for some reason, you're unable to get a working installation of numpy on you
 you can define the macro `WITHOUT_NUMPY` before including the header file to erase this
 you can define the macro `WITHOUT_NUMPY` before including the header file to erase this
 dependency.
 dependency.
 
 
-The C++-part of the library consists of the single header file `matplotlibcpp.h` which can be placed
-anywhere.
+The C++-part of the library consists of the single header file `matplotlibcpp.h` which
+can be placed anywhere.
 
 
-Since a python interpreter is opened internally, it is necessary to link against `libpython` in order
-to user matplotlib-cpp. Most versions should work, although `libpython2.7` and `libpython3.6` are
-probably the most regularly testedr.
+Since a python interpreter is opened internally, it is necessary to link
+against `libpython` in order to user matplotlib-cpp. Most versions should
+work, although python likes to randomly break compatibility from time to time
+so some caution is advised when using the bleeding edge.
 
 
 
 
 # CMake
 # CMake
 
 
-If you prefer to use CMake as build system, you will want to add something like this to your
-CMakeLists.txt:
+The C++ code is compatible to both python2 and python3. However, the `CMakeLists.txt`
+file is currently set up to use python3 by default, so if python2 is required this
+has to be changed manually. (a PR that adds a cmake option for this would be highly
+welcomed)
 
 
-**Recommended way (since CMake 3.12):**
+**NOTE**: By design (of python), only a single python interpreter can be created per
+process. When using this library, *no other* library that is spawning a python
+interpreter internally can be used.
 
 
-It's easy to use cmake official [docs](https://cmake.org/cmake/help/git-stage/module/FindPython2.html#module:FindPython2) to find Python 2(or 3) interpreter, compiler and development environment (include directories and libraries).
+To compile the code without using cmake, the compiler invocation should look like
+this:
 
 
-NumPy is optional here, delete it from cmake script, if you don't need it.
+    g++ example.cpp -I/usr/include/python2.7 -lpython2.7
 
 
-```cmake
-find_package(Python2 COMPONENTS Development NumPy)
-target_include_directories(myproject PRIVATE ${Python2_INCLUDE_DIRS} ${Python2_NumPy_INCLUDE_DIRS})
-target_link_libraries(myproject Python2::Python Python2::NumPy)
-```
-
-**Alternative way (for CMake <= 3.11):**
-
-```cmake
-find_package(PythonLibs 2.7)
-target_include_directories(myproject PRIVATE ${PYTHON_INCLUDE_DIRS})
-target_link_libraries(myproject ${PYTHON_LIBRARIES})
-```
+This can also be used for linking against a custom build of python
 
 
+    g++ example.cpp -I/usr/local/include/fancy-python4 -L/usr/local/lib -lfancy-python4
 
 
 # Vcpkg
 # Vcpkg
 
 
@@ -258,17 +253,6 @@ Note that support for c++98 was dropped more or less accidentally, so if you hav
 with an ancient compiler and still want to enjoy the latest additional features, I'd
 with an ancient compiler and still want to enjoy the latest additional features, I'd
 probably merge a PR that restores support.
 probably merge a PR that restores support.
 
 
-# Python 3
-
-This library supports both python2 and python3 (although the python3 support is probably far less tested,
-so it is recommended to prefer python2.7). To switch the used python version, simply change
-the compiler flags accordingly.
-
-    g++ example.cpp -I/usr/include/python3.6 -lpython3.6
-
-The same technique can be used for linking against a custom build of python
-
-    g++ example.cpp -I/usr/local/include/fancy-python4 -L/usr/local/lib -lfancy-python4
 
 
 
 
 Why?
 Why?

+ 0 - 26
contrib/CMakeLists.txt

@@ -1,26 +0,0 @@
-cmake_minimum_required(VERSION 3.7)
-project (MatplotlibCPP_Test)
-
-set(CMAKE_CXX_STANDARD 11)
-set(CMAKE_CXX_STANDARD_REQUIRED ON)
-
-include_directories(${PYTHONHOME}/include)
-include_directories(${PYTHONHOME}/Lib/site-packages/numpy/core/include)
-link_directories(${PYTHONHOME}/libs)
-
-add_definitions(-DMATPLOTLIBCPP_PYTHON_HEADER=Python.h)
-
-# message(STATUS "*** dump start cmake variables ***")
-# get_cmake_property(_variableNames VARIABLES)
-# foreach(_variableName ${_variableNames})
-#         message(STATUS "${_variableName}=${${_variableName}}")
-# endforeach()
-# message(STATUS "*** dump end ***")
-
-add_executable(minimal ${CMAKE_CURRENT_SOURCE_DIR}/../examples/minimal.cpp)
-add_executable(basic ${CMAKE_CURRENT_SOURCE_DIR}/../examples/basic.cpp)
-add_executable(modern ${CMAKE_CURRENT_SOURCE_DIR}/../examples/modern.cpp)
-add_executable(animation ${CMAKE_CURRENT_SOURCE_DIR}/../examples/animation.cpp)
-add_executable(nonblock ${CMAKE_CURRENT_SOURCE_DIR}/../examples/nonblock.cpp)
-add_executable(xkcd ${CMAKE_CURRENT_SOURCE_DIR}/../examples/xkcd.cpp)
-add_executable(bar ${CMAKE_CURRENT_SOURCE_DIR}/../examples/bar.cpp)

+ 0 - 12
numpy_flags.py

@@ -1,12 +0,0 @@
-from os import path
-
-try:
-    from numpy import __file__ as numpyloc
-
-    # Get numpy directory
-    numpy_dir = path.dirname(numpyloc)
-
-    # Print the result of joining this to core and include
-    print("-I" + path.join(numpy_dir, "core", "include"))
-except:
-    print("-DWITHOUT_NUMPY")