Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cmake install #3228

Closed
wants to merge 13 commits into from
31 changes: 31 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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]+$")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is SOVERSION not needed anymore?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All libraries get to installed in the python site-packages directory and in there so versioning isn’t required anymore. Plus half of the new library miss it anyhow.


#
# CMake internal vars
Expand Down
4 changes: 2 additions & 2 deletions doc/sphinx/conf.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 7 additions & 4 deletions doc/sphinx/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``
Expand All @@ -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`
Expand Down
1 change: 0 additions & 1 deletion src/config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$<$<CONFIG:Release>:-g>")
Expand Down
11 changes: 5 additions & 6 deletions src/core/cluster_analysis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
1 change: 1 addition & 0 deletions src/core/io/mpiio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of the new install() line here and in the other submodules?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These libraries were missing from the installation and hence made the espressomd module unusable.

1 change: 1 addition & 0 deletions src/core/io/reader/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
1 change: 0 additions & 1 deletion src/core/shapes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions src/pdbparser/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
10 changes: 6 additions & 4 deletions src/python/espressomd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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})
Expand Down Expand Up @@ -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})
Expand All @@ -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")
3 changes: 1 addition & 2 deletions src/script_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 3 additions & 2 deletions testsuite/cmake/BashUnitTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
## }
##
Expand Down
17 changes: 2 additions & 15 deletions testsuite/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

29 changes: 16 additions & 13 deletions testsuite/cmake/test_install.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,24 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

# 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
30 changes: 0 additions & 30 deletions testsuite/cmake/test_install_destdir.sh

This file was deleted.

30 changes: 0 additions & 30 deletions testsuite/cmake/test_install_prefix.sh

This file was deleted.

35 changes: 0 additions & 35 deletions testsuite/cmake/test_python_bindings.sh

This file was deleted.