diff --git a/CMakeLists.txt b/CMakeLists.txt index bfc3baf9..e45da6df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,12 +17,26 @@ endif() find_package(SWIG 3.0) ################################################################################ -## Testing +## Options option(FORTRAN_ONLY "Build only the Fortran bindings." OFF) -if (NOT FORTRAN_ONLY) +option(NOSWIG "Don't build the swig bindings." OFF) +option(USE_MPIH "Use mpi.h for systems that don't have the mpi module" OFF) +option(NOIALLGATHER + "A (slower) alternative communication strategy if iallgather not implemented" + OFF) + +## Process these options +if (NOT SWIG_FOUND OR FORTRAN_ONLY) + set(NOSWIG TRUE) +endif() + +################################################################################ +## Testing +if (NOT NOSWIG) enable_testing() else() - message(WARNING "Fortran only! No local testing will be generated.") + message(WARNING + "Swig disabled. No python bindings or testing will be generated.") endif() ################################################################################ @@ -55,14 +69,10 @@ endif() ################################################################################ ## Check MPI Features -option(USE_MPIH "Use mpi.h for systems that don't have the mpi module" OFF) if (USE_MPIH OR NOT ${MPI_Fortran_HAVE_F90_MODULE}) add_definitions(-DUSE_MPIH) endif() -option(NOIALLGATHER - "A (slower) alternative communication strategy if iallgather not implemented" - OFF) if (NOIALLGATHER) add_definitions(-DNOIALLGATHER) message(STATUS "IAllgather replacement activated.") @@ -74,6 +84,6 @@ endif() subdirs(Documentation) subdirs(Source) -if (NOT FORTRAN_ONLY) +if (NOT NOSWIG) subdirs(UnitTests) endif() diff --git a/ReadMe.md b/ReadMe.md index b943f35a..ecca0244 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -26,38 +26,50 @@ The following optional software can greatly enhance the NTPoly experience: * BLAS: for multiplying dense matrices, if they emerge in the calculation. * A C++ Compiler for building C++ bindings. -* Doxygen: for building documentation. -* Python (Version 2.7+): for testing. +* Ford: for building documentation. +* Doxygen: for building C++ documentation. +* SWIG (Version 3.0+): for building the Python bindings. +* Python (Version 2.7+): if you would like python bindings. * MPI4PY: for testing. * SciPy: for testing. * NumPy: for testing. -* SWIG (Version 3.0+): for building the Python bindings. NTPoly uses CMake as a build system. First, take a look in the Targets -directory. You'll find a list of `.cmake` files which have example configurations -on popular systems. You should copy one of these files, and create your own -mymachine.cmake file. Then, cd into the Build directory, and type: +directory. You'll find a list of `.cmake` files which have example +configurations on popular systems. You should copy one of these files, and +create your own mymachine.cmake file. Then, cd into the Build directory, and +type: > cmake -DCMAKE_TOOLCHAIN_FILE=../Targets/mymachine.cmake .. -There are a few options you can pass to CMake to modify the build. You can set -`-DCMAKE_BUILD_TYPE=Debug` for debugging purposes. You can set the install -directory using the standard `-DCMAKE_INSTALL_PREFIX=/path/to/dir`. You can -also set `-DFORTRAN_ONLY=YES` if you want to only build the Fortran interface. -Note that with just the Fortran interface, it is not possible to perform local -tests. - After that you can build using: > make And for the documentation: > make doc -[Online documentation](https://william-dawson.github.io/NTPoly/documentation/) is also -available. Further details about the library can be found on the -[Wiki](https://github.com/william-dawson/NTPoly/wiki). -If you aren't cross compiling, you can perform local tests using: +If you aren't cross compiling and have built the python bindings, you can +perform local tests using: > make test +There are a few options you can pass to CMake to modify the build. A few +useful standard options are: +* `-DCMAKE_BUILD_TYPE=` `Debug` or `Release`. +* `-DCMAKE_INSTALL_PREFIX=` followed by the path to your desired install + directory. + +There are also some custom options special for NTPoly: +* `-DFORTRAN_ONLY=` set to `Yes` if you only want to build the Fortran bindings. +* `-DNOSWIG=` set to `Yes` if you don't want to build Python bindings. +* `-DUSE_MPIH=` on some systems, there is no `use mpi` feature for Fortran, + just `#include "mpi.h"`. You can set this option to activate the later. +* `-DNOIALLGATHER=` on older MPI implementations, there is no non blocking + collective operations. You can disable this feature using this option, but + beware this might reduce performance. + +[Online documentation](https://william-dawson.github.io/NTPoly/documentation/) +is also available. Further details about the library can be found on the +[Wiki](https://github.com/william-dawson/NTPoly/wiki). + Basic Theory -------------------------------------------------------------------------------- The theory of matrix functions is a long studied branch of matrix algebra. diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index d908f85d..4464de27 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -1,8 +1,17 @@ +################################################################################ +## Basic Code subdirs(Fortran) +## C++ Bindings if (NOT FORTRAN_ONLY) subdirs(C) subdirs(CPlusPlus) - subdirs(Swig) subdirs(Wrapper) endif() + +## Python bindings built with swig +if (NOT NOSWIG) + subdirs(Swig) +else() + message(WARNING "Swig is disabled. No python bindings with be generated.") +endif() diff --git a/Source/CPlusPlus/CMakeLists.txt b/Source/CPlusPlus/CMakeLists.txt index d162806d..c195dc71 100644 --- a/Source/CPlusPlus/CMakeLists.txt +++ b/Source/CPlusPlus/CMakeLists.txt @@ -56,7 +56,9 @@ set(Chead ################################################################################ add_library(NTPolyCPP ${Csrc} ${Chead}) -set_target_properties(NTPolyCPP PROPERTIES POSITION_INDEPENDENT_CODE True) +if (NOT NOSWIG) + set_target_properties(NTPolyCPP PROPERTIES POSITION_INDEPENDENT_CODE True) +endif() target_link_libraries(NTPolyCPP NTPolyWrapper) set_target_properties(NTPolyCPP PROPERTIES PUBLIC_HEADER "${Chead}") diff --git a/Source/Fortran/CMakeLists.txt b/Source/Fortran/CMakeLists.txt index 49115b7c..c8165990 100644 --- a/Source/Fortran/CMakeLists.txt +++ b/Source/Fortran/CMakeLists.txt @@ -40,7 +40,7 @@ set(Fsrc ################################################################################ add_library(NTPoly ${Fsrc}) -if (NOT FORTRAN_ONLY) +if (NOT NOSWIG) set_target_properties(NTPoly PROPERTIES POSITION_INDEPENDENT_CODE True) endif() target_link_libraries(NTPoly ${MPI_Fortran_LIBRARIES} diff --git a/Source/Swig/CMakeLists.txt b/Source/Swig/CMakeLists.txt index e0142440..0840049a 100644 --- a/Source/Swig/CMakeLists.txt +++ b/Source/Swig/CMakeLists.txt @@ -1,45 +1,41 @@ ################################################################################ -if (SWIG_FOUND) - # Probe some information about python - if(NOT DEFINED PYTHON_EXECUTABLE) - find_package(PythonInterp REQUIRED) - endif() +# Probe some information about python +if(NOT DEFINED PYTHON_EXECUTABLE) + find_package(PythonInterp REQUIRED) +endif() - include(ConfigPython.cmake) - if (APPLE) - get_py_lib() - message(STATUS "Using Python Library Path:" ${PYTHON_LIBRARIES}) - endif() - get_py_include() - message(STATUS "Using Python Include Path:" ${PYTHON_INCLUDE_PATH}) +include(ConfigPython.cmake) +if (APPLE) + get_py_lib() + message(STATUS "Using Python Library Path:" ${PYTHON_LIBRARIES}) +endif() +get_py_include() +message(STATUS "Using Python Include Path:" ${PYTHON_INCLUDE_PATH}) - include_directories(${PYTHON_INCLUDE_PATH}) - include_directories(${CMAKE_CURRENT_SOURCE_DIR}) - include_directories(${CMAKE_SOURCE_DIR}/Source/C) - include_directories(${CMAKE_SOURCE_DIR}/Source/CPlusPlus) +include_directories(${PYTHON_INCLUDE_PATH}) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(${CMAKE_SOURCE_DIR}/Source/C) +include_directories(${CMAKE_SOURCE_DIR}/Source/CPlusPlus) - include(${SWIG_USE_FILE}) - set(CMAKE_SWIG_FLAGS "") +include(${SWIG_USE_FILE}) +set(CMAKE_SWIG_FLAGS "") - set(Swigsrc - NTPolySwig.i - ) +set(Swigsrc + NTPolySwig.i +) - foreach(file ${Swigsrc}) - SET_SOURCE_FILES_PROPERTIES(${file} PROPERTIES CPLUSPLUS ON) - endforeach(file) - set(CMAKE_SWIG_OUTDIR ${CMAKE_BINARY_DIR}/python) - if(${CMAKE_VERSION} VERSION_LESS "3.8.0") - swig_add_module(NTPolySwig python ${Swigsrc}) - else() - swig_add_library(NTPolySwig LANGUAGE python SOURCES ${Swigsrc}) - endif() - swig_link_libraries(NTPolySwig NTPolyCPP NTPolyWrapper NTPoly - ${PYTHON_LIBRARIES} ${TOOLCHAIN_LIBS}) - set_target_properties(_NTPolySwig PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/python - LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/python - ) +foreach(file ${Swigsrc}) + SET_SOURCE_FILES_PROPERTIES(${file} PROPERTIES CPLUSPLUS ON) +endforeach(file) +set(CMAKE_SWIG_OUTDIR ${CMAKE_BINARY_DIR}/python) +if(${CMAKE_VERSION} VERSION_LESS "3.8.0") + swig_add_module(NTPolySwig python ${Swigsrc}) else() - message(WARNING "Swig not found! No python bindings will be generated.") + swig_add_library(NTPolySwig LANGUAGE python SOURCES ${Swigsrc}) endif() +swig_link_libraries(NTPolySwig NTPolyCPP NTPolyWrapper NTPoly + ${PYTHON_LIBRARIES} ${TOOLCHAIN_LIBS}) +set_target_properties(_NTPolySwig PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/python + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/python +) diff --git a/Source/Wrapper/CMakeLists.txt b/Source/Wrapper/CMakeLists.txt index b994fbf9..88ef071d 100644 --- a/Source/Wrapper/CMakeLists.txt +++ b/Source/Wrapper/CMakeLists.txt @@ -29,7 +29,10 @@ set(Wsrc ################################################################################ add_library(NTPolyWrapper ${Wsrc}) -set_target_properties(NTPolyWrapper PROPERTIES POSITION_INDEPENDENT_CODE True) +if (NOT NOSWIG) + set_target_properties(NTPolyWrapper PROPERTIES + POSITION_INDEPENDENT_CODE True) +endif() target_link_libraries(NTPolyWrapper NTPoly) include(GNUInstallDirs)