Skip to content

Commit b515709

Browse files
authored
Merge pull request igfuw#278 from pdziekan/correct_python_module_path
correct python module path
2 parents 90072f5 + 7ffaba6 commit b515709

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

bindings/python/CMakeLists.txt

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,20 @@ else()
5050
endif()
5151
endif()
5252

53-
# ... where to find libclouph++
5453
target_link_libraries(cloudphxx cloudphxx_lgrngn)
5554

56-
# installation (see http://www.cmake.org/pipermail/cmake/2013-March/054138.html)
57-
execute_process (
58-
COMMAND ${PYTHON_EXECUTABLE} -c
59-
"import site, sys; sys.stdout.write(site.PREFIXES[-1])"
60-
OUTPUT_VARIABLE PYTHON_PREFIX
61-
)
62-
file ( TO_CMAKE_PATH "${PYTHON_PREFIX}" PYTHON_PREFIX )
63-
execute_process (
64-
COMMAND ${PYTHON_EXECUTABLE} -c
65-
"import site, sys; sys.stdout.write(site.getsitepackages()[-1])"
66-
OUTPUT_VARIABLE PYTHON_SITE_DIR
67-
)
68-
file ( TO_CMAKE_PATH "${PYTHON_SITE_DIR}" PYTHON_SITE_DIR )
69-
string ( REGEX REPLACE "^${PYTHON_PREFIX}/" ""
70-
PYTHON_SITE_DIR "${PYTHON_SITE_DIR}"
71-
)
55+
#to retain rpath to libcloudphxx_lgrngn.so linked by libcloudphxx.so after installation
56+
set_property(TARGET cloudphxx PROPERTY INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
57+
set_property(TARGET cloudphxx PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
58+
59+
# where to install python modules (see http://stackoverflow.com/questions/1242904/finding-python-site-packages-directory-with-cmake)
60+
execute_process(
61+
COMMAND "${PYTHON_EXECUTABLE}" -c "if True:
62+
import sysconfig as sc
63+
print(sc.get_path('platlib'))"
64+
OUTPUT_VARIABLE PYTHON_SITE_DIR
65+
OUTPUT_STRIP_TRAILING_WHITESPACE)
66+
7267

7368
install ( TARGETS cloudphxx
7469
LIBRARY

libcloudph++-config.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ cmake_minimum_required(VERSION 2.8.8)
55
# the policies we care about:
66
# - CMP0025 - make CMake distinguis between Apple and LLVM clang
77
# - CMP0042 - make CMake use RPATHs on OSX
8+
# - CMP0060 - make CMake always keep absoult RPATHs, even if installing in implicit directory
89
if(CMAKE_VERSION VERSION_GREATER 2.9)
910
cmake_policy(VERSION 3.0)
1011
endif()
1112

13+
set(CMAKE_MACOSX_RPATH ON) # explicit, since policy CMP0042 didn't work...
14+
1215
############################################################################################
1316
# the following variables will be set:
1417
set(libcloudphxx_FOUND False)
@@ -47,7 +50,8 @@ endif()
4750
# Boost libraries
4851
find_package(Boost)
4952
if(Boost_FOUND)
50-
set(libcloudphxx_LIBRARIES "${libcloudphxx_LIBRARIES};${Boost_LIBRARIES}")
53+
#TODO: if boost is not linked in some program, link boost libs to libcloudphxx_lgrngn.so ?
54+
# set(libcloudphxx_LIBRARIES "${libcloudphxx_LIBRARIES};${Boost_LIBRARIES}")
5155
set(libcloudphxx_INCLUDE_DIRS "${libcloudphxx_INCLUDE_DIRS};${Boost_INCLUDE_DIRS}")
5256
else()
5357
#TODO: check separately for optional and mandatory components

0 commit comments

Comments
 (0)