2014-05-25 10:43:06 +02:00
|
|
|
set(CMAKE_SHARED_MODULE_PREFIX)
|
|
|
|
|
2014-06-04 18:06:48 +02:00
|
|
|
include_directories(${NUMPY_INCLUDE_DIRS} ${PYTHON_INCLUDE_PATH} ${CMAKE_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/src ${CMAKE_SOURCE_DIR}/python)
|
2014-05-25 10:43:06 +02:00
|
|
|
|
|
|
|
IF(CYTHON)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/_cosmotool.cpp
|
|
|
|
COMMAND ${CYTHON} --cplus -o ${CMAKE_CURRENT_BINARY_DIR}/_cosmotool.cpp ${CMAKE_CURRENT_SOURCE_DIR}/_cosmotool.pyx
|
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/_cosmotool.pyx)
|
|
|
|
|
2014-06-04 14:00:54 +02:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/_project.cpp
|
|
|
|
COMMAND ${CYTHON} --cplus -o ${CMAKE_CURRENT_BINARY_DIR}/_project.cpp ${CMAKE_CURRENT_SOURCE_DIR}/_project.pyx
|
2014-06-05 16:24:05 +02:00
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/_project.pyx ${CMAKE_CURRENT_SOURCE_DIR}/project_tool.hpp )
|
2014-06-04 14:00:54 +02:00
|
|
|
|
2014-05-25 10:43:06 +02:00
|
|
|
ENDIF(CYTHON)
|
|
|
|
|
|
|
|
|
|
|
|
add_library(_cosmotool MODULE ${CMAKE_CURRENT_BINARY_DIR}/_cosmotool.cpp)
|
2014-06-04 14:00:54 +02:00
|
|
|
add_library(_project MODULE ${CMAKE_CURRENT_BINARY_DIR}/_project.cpp)
|
2014-05-25 10:43:06 +02:00
|
|
|
|
|
|
|
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Bsymbolic-functions")
|
|
|
|
|
|
|
|
target_link_libraries(_cosmotool ${CosmoTool_local} ${PYTHON_LIBRARIES} ${GSL_LIBRARIES})
|
2014-06-04 14:00:54 +02:00
|
|
|
target_link_libraries(_project ${PYTHON_LIBRARIES})
|
2014-05-25 10:43:06 +02:00
|
|
|
|
|
|
|
# Discover where to put packages
|
|
|
|
if (NOT PYTHON_SITE_PACKAGES)
|
|
|
|
execute_process (COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()" OUTPUT_VARIABLE internal_PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
SET(SYSTEM_PYTHON_SITE_PACKAGES ${internal_PYTHON_SITE_PACKAGES} CACHE PATH "Path to the target system-wide site-package where to install python modules")
|
|
|
|
|
|
|
|
execute_process (COMMAND ${PYTHON_EXECUTABLE} -c "from site import USER_SITE; print USER_SITE" OUTPUT_VARIABLE internal_PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
SET(USER_PYTHON_SITE_PACKAGES ${internal_PYTHON_SITE_PACKAGES} CACHE PATH "Path to the target user site-package where to install python modules")
|
|
|
|
|
|
|
|
mark_as_advanced(USER_PYTHON_SITE_PACKAGES SYSTEM_PYTHON_SITE_PACKAGES)
|
|
|
|
endif (NOT PYTHON_SITE_PACKAGES)
|
|
|
|
|
|
|
|
OPTION(INSTALL_PYTHON_LOCAL OFF)
|
|
|
|
|
|
|
|
IF (NOT INSTALL_PYTHON_LOCAL)
|
|
|
|
SET(PYTHON_SITE_PACKAGES ${SYSTEM_PYTHON_SITE_PACKAGES})
|
|
|
|
ELSE (NOT INSTALL_PYTHON_LOCAL)
|
|
|
|
SET(PYTHON_SITE_PACKAGES ${USER_PYTHON_SITE_PACKAGES})
|
|
|
|
ENDIF(NOT INSTALL_PYTHON_LOCAL)
|
|
|
|
|
|
|
|
|
|
|
|
if (WIN32 AND NOT CYGWIN)
|
|
|
|
SET_TARGET_PROPERTIES(_cosmotool PROPERTIES SUFFIX ".pyd")
|
|
|
|
endif (WIN32 AND NOT CYGWIN)
|
|
|
|
|
2014-06-04 14:00:54 +02:00
|
|
|
INSTALL(TARGETS _cosmotool _project
|
2014-05-26 14:24:53 +02:00
|
|
|
LIBRARY DESTINATION ${PYTHON_SITE_PACKAGES}/cosmotool
|
2014-05-25 10:43:06 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
INSTALL(DIRECTORY cosmotool DESTINATION ${PYTHON_SITE_PACKAGES}
|
|
|
|
FILES_MATCHING PATTERN "*.py")
|