diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f92958dfbfd..07cfaa291e2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -272,6 +272,37 @@ tutorials-samples-no-gpu: only: - schedules +installation: + <<: *global_job_definition + stage: build + image: gitlab.icp.uni-stuttgart.de:4567/espressomd/docker/ubuntu-python3:cuda-10.1 + script: + - export myconfig=maxset with_coverage=false make_check=false + - export srcdir=${CI_PROJECT_DIR} test_timeout=1800 + - bash maintainer/CI/build_cmake.sh + - cd build + # install ESPResSo (in CI, pypresso will run up to 5 times slower when + # located outside the build directory, hence the larger timeout value) + - make install + # get path of installed files + - CI_INSTALL_DIR="/tmp/espresso-unit-tests" + - CI_INSTALL_PYTHON_PATH=$(dirname $(find "${CI_INSTALL_DIR}/lib" -name espressomd)) + # deploy object-in-fluid module + - cp -r "src/python/object_in_fluid" "${CI_INSTALL_PYTHON_PATH}/object_in_fluid" + # run all tests with the installed files + - sed -i "s|$(pwd)/pypresso|${CI_INSTALL_DIR}/bin/pypresso|" testsuite/{python,scripts/samples,scripts/tutorials}/CTestTestfile.cmake + # skip long tests + - sed -i "/tutorial_11-ferrofluid_3/d" testsuite/scripts/tutorials/CTestTestfile.cmake + - make -j2 check_python_skip_long + - make -j2 check_samples + - make -j2 check_tutorials + tags: + - docker + - linux + - cuda + timeout: 3h + when: manual + empty: <<: *global_job_definition stage: build diff --git a/CMakeLists.txt b/CMakeLists.txt index 55ceaaf2bce..f6409ffcc1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,14 +29,6 @@ endif() enable_language(CXX) set(PROJECT_VERSION "4.1.0") -string(REGEX - REPLACE "^([1-9]+)\\.[0-9]+.*$" - "\\1" - SOVERSION - "${PROJECT_VERSION}") -if(NOT ${SOVERSION} MATCHES "^[1-9]+$") - message(FATAL_ERROR "Could not determine SOVERSION from ${PROJECT_VERSION}") -endif(NOT ${SOVERSION} MATCHES "^[1-9]+$") # # CMake internal vars diff --git a/doc/sphinx/conf.py.in b/doc/sphinx/conf.py.in index cb0b3c67570..9377954e60d 100644 --- a/doc/sphinx/conf.py.in +++ b/doc/sphinx/conf.py.in @@ -67,9 +67,9 @@ author = 'C. Holm, F. Weik, R. Weeber' # built documents. # # The short X.Y version. -version = '@PROJECT_VERSION@' +version = '.'.join('@PROJECT_VERSION@'.split('.')[:2]) # The full version, including alpha/beta/rc tags. -release = '@SOVERSION@' +release = '@PROJECT_VERSION@' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/sphinx/installation.rst b/doc/sphinx/installation.rst index 967f11ec242..bcec88d6d3c 100644 --- a/doc/sphinx/installation.rst +++ b/doc/sphinx/installation.rst @@ -640,7 +640,7 @@ build directory and create a new one. .. _make\: Compiling, testing and installing: ``make``: Compiling, testing and installing --------------------------------------------- +------------------------------------------- The command ``make`` is mainly used to compile the source code, but it can do a number of other things. The generic syntax of the ``make`` @@ -665,9 +665,12 @@ targets are available: Deletes all files that were created during the compilation. ``install`` - Install |es|. - Use ``make DESTDIR=/home/john install`` to install to a - specific directory. + Install |es| in the path specified by the CMake variable + ``CMAKE_INSTALL_PREFIX``. The path can be changed by calling CMake + with ``cmake .. -DCMAKE_INSTALL_PREFIX=/path/to/espresso``. Do not use + ``make DESTDIR=/path/to/espresso install`` to install to a specific path, + this will cause issues with the runtime path (RPATH) and will conflict + with the CMake variable ``CMAKE_INSTALL_PREFIX`` if it has been set. ``doxygen`` Creates the Doxygen code documentation in the :file:`doc/doxygen` diff --git a/src/config/CMakeLists.txt b/src/config/CMakeLists.txt index 618e4e59c60..dd34cb4b971 100644 --- a/src/config/CMakeLists.txt +++ b/src/config/CMakeLists.txt @@ -36,7 +36,6 @@ execute_process(COMMAND ${PYTHON_EXECUTABLE} add_library(EspressoConfig SHARED config-features.cpp) add_dependencies(EspressoConfig myconfig check_myconfig generate_config_features) install(TARGETS EspressoConfig LIBRARY DESTINATION ${PYTHON_INSTDIR}/espressomd) -set_target_properties(EspressoConfig PROPERTIES SOVERSION ${SOVERSION}) target_include_directories(EspressoConfig PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) # Parse repository info from git if available diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index de03ad86f82..c956b9de169 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -158,7 +158,6 @@ else(CUDA) endif(CUDA) install(TARGETS EspressoCore LIBRARY DESTINATION ${PYTHON_INSTDIR}/espressomd) -set_target_properties(EspressoCore PROPERTIES SOVERSION ${SOVERSION}) target_include_directories(EspressoCore PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) if(WITH_COVERAGE) target_compile_options(EspressoCore PUBLIC "$<$:-g>") diff --git a/src/core/cluster_analysis/CMakeLists.txt b/src/core/cluster_analysis/CMakeLists.txt index 354bdd8613a..7274fc6e3a1 100644 --- a/src/core/cluster_analysis/CMakeLists.txt +++ b/src/core/cluster_analysis/CMakeLists.txt @@ -2,12 +2,11 @@ set(cluster_analysis_SRC Cluster.cpp ClusterStructure.cpp ) -add_library(cluster_analysis SHARED ${cluster_analysis_SRC}) -install(TARGETS cluster_analysis LIBRARY DESTINATION ${PYTHON_INSTDIR}/espressomd) -set_target_properties(cluster_analysis PROPERTIES SOVERSION ${SOVERSION}) -set_target_properties(cluster_analysis PROPERTIES MACOSX_RPATH TRUE) -target_link_libraries(cluster_analysis PUBLIC EspressoCore PRIVATE EspressoConfig) +add_library(core_cluster_analysis SHARED ${cluster_analysis_SRC}) +install(TARGETS core_cluster_analysis LIBRARY DESTINATION ${PYTHON_INSTDIR}/espressomd) +set_target_properties(core_cluster_analysis PROPERTIES MACOSX_RPATH TRUE) +target_link_libraries(core_cluster_analysis PUBLIC EspressoCore PRIVATE EspressoConfig) if(GSL) -target_link_libraries(cluster_analysis PRIVATE GSL::gsl GSL::gslcblas) +target_link_libraries(core_cluster_analysis PRIVATE GSL::gsl GSL::gslcblas) endif() diff --git a/src/core/io/mpiio/CMakeLists.txt b/src/core/io/mpiio/CMakeLists.txt index 365c58295f9..7c4b0dc4228 100644 --- a/src/core/io/mpiio/CMakeLists.txt +++ b/src/core/io/mpiio/CMakeLists.txt @@ -1,3 +1,4 @@ add_library(mpiio SHARED mpiio.cpp) target_include_directories(mpiio PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(mpiio PRIVATE EspressoConfig EspressoCore MPI::MPI_CXX) +install(TARGETS mpiio LIBRARY DESTINATION ${PYTHON_INSTDIR}/espressomd) diff --git a/src/core/io/reader/CMakeLists.txt b/src/core/io/reader/CMakeLists.txt index 1b9ee38735c..6c2de627ac0 100644 --- a/src/core/io/reader/CMakeLists.txt +++ b/src/core/io/reader/CMakeLists.txt @@ -1,3 +1,4 @@ add_library(pdbreader SHARED readpdb.cpp) target_link_libraries(pdbreader PUBLIC EspressoConfig EspressoCore pdbparser) target_include_directories(pdbreader PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +install(TARGETS pdbreader LIBRARY DESTINATION ${PYTHON_INSTDIR}/espressomd) diff --git a/src/core/shapes/CMakeLists.txt b/src/core/shapes/CMakeLists.txt index 268172df6ae..c0e78aeeb56 100644 --- a/src/core/shapes/CMakeLists.txt +++ b/src/core/shapes/CMakeLists.txt @@ -13,5 +13,4 @@ set(Shapes_SRC ) add_library(Shapes SHARED ${Shapes_SRC}) install(TARGETS Shapes LIBRARY DESTINATION ${PYTHON_INSTDIR}/espressomd) -set_target_properties(Shapes PROPERTIES SOVERSION ${SOVERSION}) target_link_libraries(Shapes PUBLIC EspressoConfig EspressoCore) diff --git a/src/pdbparser/CMakeLists.txt b/src/pdbparser/CMakeLists.txt index c58d79e8cb7..3c4a66f1dc1 100644 --- a/src/pdbparser/CMakeLists.txt +++ b/src/pdbparser/CMakeLists.txt @@ -1,5 +1,6 @@ add_library(pdbparser SHARED ${CMAKE_CURRENT_SOURCE_DIR}/src/PdbParser.cpp) target_include_directories(pdbparser PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) +install(TARGETS pdbparser LIBRARY DESTINATION ${PYTHON_INSTDIR}/espressomd) if(WITH_UNIT_TESTS) add_subdirectory(unit_tests) endif(WITH_UNIT_TESTS) diff --git a/src/python/espressomd/CMakeLists.txt b/src/python/espressomd/CMakeLists.txt index ebe76992dae..598211d8449 100644 --- a/src/python/espressomd/CMakeLists.txt +++ b/src/python/espressomd/CMakeLists.txt @@ -38,9 +38,9 @@ add_custom_command(OUTPUT code_info.pyx WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/myconfig.pxi ) -file(GLOB cython_SRC *.pyx) # Make the cython_SRC, cython_HEADER and cython_AUX a cached variable to # be able to extend it in the subdirectories. +file(GLOB cython_SRC *.pyx) SET(cython_SRC "${cython_SRC}" CACHE INTERNAL "cython_SRC") file(GLOB cython_HEADER *.pxd) SET(cython_HEADER "${cython_HEADER}" CACHE INTERNAL "cython_HEADER") @@ -53,6 +53,7 @@ add_subdirectory(io) list(APPEND cython_SRC ${CMAKE_CURRENT_BINARY_DIR}/code_info.pyx) list(REMOVE_DUPLICATES cython_SRC) +# Configure, compile and install Cython files foreach(cython_file ${cython_SRC}) get_filename_component(basename ${cython_file} NAME_WE) file(RELATIVE_PATH relpath ${CMAKE_CURRENT_SOURCE_DIR} ${cython_file}) @@ -107,11 +108,13 @@ foreach(cython_file ${cython_SRC}) target_link_libraries(${target} PRIVATE EspressoConfig EspressoCore EspressoScriptInterface) target_include_directories(${target} SYSTEM PRIVATE ${PYTHON_INCLUDE_DIRS} ${NUMPY_INCLUDE_DIR}) add_dependencies(espressomd ${target}) + install(TARGETS ${target} LIBRARY DESTINATION ${PYTHON_INSTDIR}/espressomd) endif() endforeach() target_link_libraries(espressomd_profiler PRIVATE Profiler) +# Configure Python files foreach(auxfile ${cython_AUX}) get_filename_component(filename ${auxfile} NAME) file(RELATIVE_PATH relpath ${CMAKE_CURRENT_SOURCE_DIR} ${auxfile}) @@ -123,7 +126,6 @@ foreach(auxfile ${cython_AUX}) ) endforeach(auxfile) +# Install Python files install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DESTINATION ${PYTHON_INSTDIR} - PATTERN "CMakeFiles" EXCLUDE PATTERN "*.cpp" EXCLUDE - PATTERN "*.cmake" EXCLUDE PATTERN "Makefile" EXCLUDE) - + FILES_MATCHING PATTERN "*.py") diff --git a/src/script_interface/CMakeLists.txt b/src/script_interface/CMakeLists.txt index d28603f816e..848eab8dae2 100644 --- a/src/script_interface/CMakeLists.txt +++ b/src/script_interface/CMakeLists.txt @@ -33,8 +33,7 @@ endif() add_library(EspressoScriptInterface SHARED ${EspressoScriptInterface_SRC}) install(TARGETS EspressoScriptInterface LIBRARY DESTINATION ${PYTHON_INSTDIR}/espressomd) -set_target_properties(EspressoScriptInterface PROPERTIES SOVERSION ${SOVERSION}) -target_link_libraries(EspressoScriptInterface PRIVATE EspressoConfig PUBLIC EspressoCore Shapes cluster_analysis mpiio pdbreader) +target_link_libraries(EspressoScriptInterface PRIVATE EspressoConfig PUBLIC EspressoCore Shapes core_cluster_analysis mpiio pdbreader) if(HDF5_FOUND) target_link_libraries(EspressoScriptInterface PRIVATE H5mdCore) endif() diff --git a/testsuite/cmake/BashUnitTests.sh b/testsuite/cmake/BashUnitTests.sh index 108bb472a9a..1480aca9f73 100755 --- a/testsuite/cmake/BashUnitTests.sh +++ b/testsuite/cmake/BashUnitTests.sh @@ -24,13 +24,14 @@ ## #define ELECTROSTATICS ## #define EXTERNAL_FORCES ## EOF +## cmake .. -DCMAKE_INSTALL_PREFIX=/tmp/espresso ## make -## make install DESTDIR="install" +## make install ## } ## ## # cleanup ## function tear_down() { -## rm -rf install +## rm -rf /tmp/espresso ## make dist-clean ## } ## diff --git a/testsuite/cmake/CMakeLists.txt b/testsuite/cmake/CMakeLists.txt index f88ea945860..9e6045b5cf2 100644 --- a/testsuite/cmake/CMakeLists.txt +++ b/testsuite/cmake/CMakeLists.txt @@ -12,29 +12,16 @@ function(CMAKE_TEST) endfunction(CMAKE_TEST) if(WITH_PYTHON AND PYTHONINTERP_FOUND) - set(TESTING_PYTHON TRUE) # obtain Python*_SITEARCH without find_package(Python*) execute_process( COMMAND "${PYTHON_EXECUTABLE}" -c "from distutils import sysconfig as sc;print(sc.get_python_lib(prefix='', plat_specific=True, standard_lib=False))" OUTPUT_VARIABLE Python_SITEARCH OUTPUT_STRIP_TRAILING_WHITESPACE) -else() - set(TESTING_PYTHON FALSE) -endif() -set(DESTDIR "${CMAKE_CURRENT_BINARY_DIR}/install") -add_custom_target(setup_install) -add_custom_target(setup_install_destdir COMMAND make install DESTDIR="${DESTDIR}" WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) -add_dependencies(setup_install setup_install_destdir) -cmake_test(FILE test_install_destdir.sh DEPENDENCIES BashUnitTests.sh test_install.sh) -if(CMAKE_INSTALL_PREFIX STREQUAL "/tmp/espresso-unit-tests") - add_custom_target(setup_install_prefix COMMAND make install WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) - add_dependencies(setup_install setup_install_prefix) - cmake_test(FILE test_install_prefix.sh DEPENDENCIES BashUnitTests.sh) + cmake_test(FILE test_install.sh DEPENDENCIES BashUnitTests.sh) endif() -cmake_test(FILE test_python_bindings.sh DEPENDENCIES BashUnitTests.sh) - +add_custom_target(setup_install COMMAND make install WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) add_custom_target(check_cmake_install COMMAND ${CMAKE_CTEST_COMMAND} --timeout ${TEST_TIMEOUT} -C serial --output-on-failure) add_dependencies(check_cmake_install setup_install) diff --git a/testsuite/cmake/test_install.sh b/testsuite/cmake/test_install.sh old mode 100644 new mode 100755 index 7497b10fcd1..2e8fbc44fc5 --- a/testsuite/cmake/test_install.sh +++ b/testsuite/cmake/test_install.sh @@ -16,21 +16,24 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# test espresso installation -function helper_test_install_common() { - local root=$1 - local filepaths=("${root}/bin/pypresso" \ - "${root}/@Python_SITEARCH@/espressomd/EspressoCore.so" \ +# load bash unit testing library +source BashUnitTests.sh + +# test installation and Python bindings +function test_install() { + local filepaths=("@CMAKE_INSTALL_PREFIX@/bin/pypresso" \ + "@CMAKE_INSTALL_PREFIX@/@Python_SITEARCH@/espressomd/EspressoCore.so" \ + "@CMAKE_INSTALL_PREFIX@/@Python_SITEARCH@/espressomd/_init.so" \ + "@CMAKE_INSTALL_PREFIX@/@Python_SITEARCH@/espressomd/__init__.py" ) - if [ "@TESTING_PYTHON@" = "TRUE" ] - then - filepaths+=("${root}/@Python_SITEARCH@/espressomd/_init.so" \ - "${root}/@Python_SITEARCH@/espressomd/__init__.py" - ) - fi - for filepath in ${filepaths[@]} - do + + for filepath in ${filepaths[@]}; do assert_file_exists "${filepath}" done + + # check the espressomd module can be imported from pypresso + assert_return_code "@CMAKE_INSTALL_PREFIX@/bin/pypresso" -c "import espressomd" } +# run tests +run_test_suite diff --git a/testsuite/cmake/test_install_destdir.sh b/testsuite/cmake/test_install_destdir.sh deleted file mode 100755 index acdceb57c38..00000000000 --- a/testsuite/cmake/test_install_destdir.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash -# Copyright (C) 2018-2019 The ESPResSo project -# -# This file is part of ESPResSo. -# -# ESPResSo is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# ESPResSo is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# load bash unit testing library -source BashUnitTests.sh -source test_install.sh - -# test espresso installation via `make install DESTDIR=/some/dir` -function test_install_DESTDIR() { - helper_test_install_common "@DESTDIR@/@CMAKE_INSTALL_PREFIX@" -} - -# run tests -run_test_suite - diff --git a/testsuite/cmake/test_install_prefix.sh b/testsuite/cmake/test_install_prefix.sh deleted file mode 100755 index 04ffa228e8f..00000000000 --- a/testsuite/cmake/test_install_prefix.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash -# Copyright (C) 2018-2019 The ESPResSo project -# -# This file is part of ESPResSo. -# -# ESPResSo is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# ESPResSo is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# load bash unit testing library -source BashUnitTests.sh -source test_install.sh - -# test espresso installation via `cmake -DCMAKE_INSTALL_PREFIX=/some/dir ..` -function test_install_CMAKE_INSTALL_PREFIX() { - helper_test_install_common "@CMAKE_INSTALL_PREFIX@" -} - -# run tests -run_test_suite - diff --git a/testsuite/cmake/test_python_bindings.sh b/testsuite/cmake/test_python_bindings.sh deleted file mode 100755 index 87864120d6c..00000000000 --- a/testsuite/cmake/test_python_bindings.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash -# Copyright (C) 2018-2019 The ESPResSo project -# -# This file is part of ESPResSo. -# -# ESPResSo is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# ESPResSo is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# load bash unit testing library -source BashUnitTests.sh - -# test if Python module can be imported -function test_Python() { - # test espresso installation via `make install DESTDIR=/some/dir` - assert_return_code "@CMAKE_BINARY_DIR@/pypresso" -c "import sys;sys.path.insert(0, '@DESTDIR@/@CMAKE_INSTALL_PREFIX@/@Python_SITEARCH@');import espressomd" - # test espresso installation via `cmake -DCMAKE_INSTALL_PREFIX=/some/dir ..` - if [ "@CMAKE_INSTALL_PREFIX@" = "/tmp/espresso-unit-tests" ] - then - assert_return_code "@CMAKE_BINARY_DIR@/pypresso" -c "import sys;sys.path.insert(0, '@CMAKE_INSTALL_PREFIX@/@Python_SITEARCH@');import espressomd" - fi -} - -# run tests -run_test_suite -