Skip to content

Commit

Permalink
Use modern CMake install procedure
Browse files Browse the repository at this point in the history
Remove the non-standard CMAKE_INSTALL_EXEC_PREFIX variable in
favor of CMAKE_INSTALL_PREFIX. Install espressomd in the standard
python3.X folder instead of the deprecated python3 folder. Remove
duplicated code logic. Use explicit keyword arguments in calls to
functions from distutils.sysconfig.
  • Loading branch information
jngrad committed Oct 17, 2019
1 parent 1af7b0d commit 5a24d0a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,15 @@ if(WITH_PYTHON)
find_package(Cython 0.23 REQUIRED)
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c
"import distutils.sysconfig as cg; print(cg.get_python_inc())"
"import distutils.sysconfig as cg; print(cg.get_python_inc(prefix='${CMAKE_INSTALL_PREFIX}', plat_specific=True))"
OUTPUT_VARIABLE PYTHON_INCLUDE_DIRS
OUTPUT_STRIP_TRAILING_WHITESPACE)
find_package(NumPy REQUIRED)
if(NOT PYTHON_INSTDIR)
execute_process(
COMMAND
${PYTHON_EXECUTABLE} -c
"import distutils.sysconfig as cg; print(cg.get_python_lib(1,0,prefix='${CMAKE_INSTALL_EXEC_PREFIX}'))"
"import distutils.sysconfig as cg; print(cg.get_python_lib(prefix='${CMAKE_INSTALL_PREFIX}', plat_specific=True, standard_lib=False).replace('${CMAKE_INSTALL_PREFIX}/', '', 1))"
OUTPUT_VARIABLE PYTHON_INSTDIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif(NOT PYTHON_INSTDIR)
Expand Down
2 changes: 1 addition & 1 deletion src/python/espressomd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@ endforeach(auxfile)

# Install Python files
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DESTINATION ${PYTHON_INSTDIR}
FILES_MATCHING PATTERN "*.py")
FILES_MATCHING PATTERN "*.py" PATTERN "CMakeFiles" EXCLUDE)
5 changes: 1 addition & 4 deletions testsuite/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ function(CMAKE_TEST)
set(cmake_tests ${cmake_tests} ${TEST_FILE} PARENT_SCOPE)
endfunction(CMAKE_TEST)

execute_process(
COMMAND "${PYTHON_EXECUTABLE}" -c "from distutils import sysconfig as sc;print(sc.get_python_lib(prefix='${CMAKE_INSTALL_PREFIX}', plat_specific=True, standard_lib=False))"
OUTPUT_VARIABLE PYTHON_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(PYTHON_DIR ${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTDIR})

cmake_test(FILE test_install.sh DEPENDENCIES BashUnitTests.sh)

Expand Down

0 comments on commit 5a24d0a

Please sign in to comment.