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 )
2014-11-20 14:04:17 +01:00
add_custom_command (
O U T P U T $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / _ c o s m o t o o l . c p p
C O M M A N D $ { C Y T H O N } - - c p l u s - o $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / _ c o s m o t o o l . c p p $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / _ c o s m o t o o l . p y x
D E P E N D S $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / _ c o s m o t o o l . p y x )
add_custom_command (
O U T P U T $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / _ c o s m o _ p o w e r . c p p
C O M M A N D $ { C Y T H O N } - - c p l u s - o $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / _ c o s m o _ p o w e r . c p p $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / _ c o s m o _ p o w e r . p y x
D E P E N D S $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / _ c o s m o _ p o w e r . p y x )
2015-08-28 11:56:35 +02:00
add_custom_command (
O U T P U T $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / _ f a s t _ i n t e r p . c p p
C O M M A N D $ { C Y T H O N } - - c p l u s - o $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / _ f a s t _ i n t e r p . c p p $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / _ f a s t _ i n t e r p . p y x
D E P E N D S $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / _ f a s t _ i n t e r p . p y x )
2014-11-20 14:04:17 +01:00
add_custom_command (
O U T P U T $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / _ c o s m o _ c i c . c p p
C O M M A N D $ { C Y T H O N } - - c p l u s - o $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / _ c o s m o _ c i c . c p p $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / _ c o s m o _ c i c . p y x
D E P E N D S $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / _ c o s m o _ c i c . p y x )
add_custom_command (
O U T P U T $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / _ p r o j e c t . c p p
C O M M A N D $ { C Y T H O N } - - c p l u s - o $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / _ p r o j e c t . c p p $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / _ p r o j e c t . p y x
D E P E N D S $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / _ p r o j e c t . p y x $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / p r o j e c t _ t o o l . h p p )
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-11-20 14:04:17 +01:00
add_library ( _cosmo_power MODULE ${ CMAKE_CURRENT_BINARY_DIR } /_cosmo_power.cpp )
add_library ( _cosmo_cic MODULE ${ CMAKE_CURRENT_BINARY_DIR } /_cosmo_cic.cpp )
2015-08-28 11:56:35 +02:00
add_library ( _fast_interp MODULE ${ CMAKE_CURRENT_BINARY_DIR } /_fast_interp.cpp )
2014-06-04 14:00:54 +02:00
add_library ( _project MODULE ${ CMAKE_CURRENT_BINARY_DIR } /_project.cpp )
2016-11-26 21:30:44 +01:00
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-11-20 14:04:17 +01:00
target_link_libraries ( _cosmo_power ${ CosmoTool_local } ${ PYTHON_LIBRARIES } ${ GSL_LIBRARIES } )
target_link_libraries ( _cosmo_cic ${ CosmoTool_local } ${ PYTHON_LIBRARIES } ${ GSL_LIBRARIES } )
2014-06-04 14:00:54 +02:00
target_link_libraries ( _project ${ PYTHON_LIBRARIES } )
2015-08-28 11:56:35 +02:00
target_link_libraries ( _fast_interp ${ CosmoTool_local } ${ PYTHON_LIBRARIES } )
2016-11-26 21:30:44 +01:00
SET ( ct_TARGETS _cosmotool _project _cosmo_power _cosmo_cic _fast_interp )
if ( Boost_FOUND )
message ( STATUS "Building bispectrum support (path = ${Boost_INCLUDE_DIRS})" )
include_directories ( ${ Boost_INCLUDE_DIRS } )
add_library ( _cosmo_bispectrum MODULE _cosmo_bispectrum.cpp )
target_link_libraries ( _cosmo_bispectrum ${ MATH_LIBRARY } )
2017-05-13 15:25:18 +02:00
if ( ENABLE_OPENMP )
set_target_properties ( _cosmo_bispectrum PROPERTIES COMPILE_FLAGS "${OpenMP_CXX_FLAGS}" LINK_FLAGS "${OpenMP_CXX_FLAGS}" )
endif ( )
2016-11-26 21:43:49 +01:00
if ( Boost_DEP )
add_dependencies ( _cosmo_bispectrum ${ Boost_DEP } )
endif ( )
2016-11-26 21:30:44 +01:00
SET ( ct_TARGETS ${ ct_TARGETS } _cosmo_bispectrum )
endif ( )
2014-05-25 10:43:06 +02:00
# Discover where to put packages
if ( NOT PYTHON_SITE_PACKAGES )
2017-05-15 16:03:17 +02:00
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 )
2014-05-25 10:43:06 +02:00
SET ( SYSTEM_PYTHON_SITE_PACKAGES ${ internal_PYTHON_SITE_PACKAGES } CACHE PATH "Path to the target system-wide site-package where to install python modules" )
2017-05-15 16:03:17 +02:00
execute_process ( COMMAND ${ PYTHON_EXECUTABLE } -c "from site import USER_SITE; print(USER_SITE)" OUTPUT_VARIABLE internal_PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE )
2014-05-25 10:43:06 +02:00
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 )
2017-07-11 15:36:19 +02:00
message ( STATUS "System python site: ${SYSTEM_PYTHON_SITE_PACKAGES}" )
message ( STATUS "User python site: ${USER_PYTHON_SITE_PACKAGES}" )
2014-05-25 10:43:06 +02:00
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 )
2017-07-11 15:36:19 +02:00
cmessage ( STATUS "Python install location: ${PYTHON_SITE_PACKAGES}" )
2014-05-25 10:43:06 +02:00
if ( WIN32 AND NOT CYGWIN )
SET_TARGET_PROPERTIES ( _cosmotool PROPERTIES SUFFIX ".pyd" )
endif ( WIN32 AND NOT CYGWIN )
2016-11-26 21:30:44 +01:00
INSTALL ( TARGETS
$ { c t _ T A R G E T S }
2014-05-26 14:24:53 +02:00
L I B R A R Y D E S T I N A T I O N $ { P Y T H O N _ S I T E _ P A C K A G E S } / c o s m o t o o l
2014-05-25 10:43:06 +02:00
)
INSTALL ( DIRECTORY cosmotool DESTINATION ${ PYTHON_SITE_PACKAGES }
F I L E S _ M A T C H I N G P A T T E R N " * . p y " )