diff --git a/CMakeLists.txt b/CMakeLists.txt index 2867d9c..ae1c525 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,8 @@ include_directories(${CASACORE_INCLUDE_DIR}) add_compile_options(-std=c++11 -Wall -DNDEBUG -Wl,--no-undefined) +option (BUILD_PYTHON "Build the python bindings" YES) + add_library(stationresponse SHARED AntennaField.cc AntennaFieldHBA.cc @@ -65,37 +67,38 @@ elseif(DOXYGEN_FOUND) endif(DOXYGEN_FOUND) -find_package (Python COMPONENTS Development) -message("Compiling Python ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} support. If this is not the intended target use 'DPYTHON_EXECUTABLE' to control.") -# bind against boost-python for compilation of the python API -# depending on major release version of the python libraries -if (${PYTHON_VERSION_MAJOR} VERSION_LESS "3") - find_package (Boost REQUIRED COMPONENTS python numpy) - find_package (Casacore REQUIRED COMPONENTS python) - message(STATUS "Boost python library: ${Boost_PYTHON_LIBRARY}") - message(STATUS "Boost numpy library: ${Boost_NUMPY_LIBRARY}") - message(STATUS "Python library ${PYTHON_LIBRARIES}") - set(BOOST_PY_FOUND TRUE) -else (${PYTHON_VERSION_MAJOR} VERSION_LESS "3") - find_package (Boost REQUIRED COMPONENTS python3 numpy3) - find_package (Casacore REQUIRED COMPONENTS python3) - message(STATUS "Boost python library: ${Boost_PYTHON3_LIBRARY}") - message(STATUS "Boost numpy library: ${Boost_NUMPY3_LIBRARY}") - message(STATUS "Python library ${PYTHON_LIBRARIES}") - set(BOOST_PY_FOUND TRUE) -endif (${PYTHON_VERSION_MAJOR} VERSION_LESS "3") - - -if(BOOST_PY_FOUND) - add_library(_stationresponse MODULE pystationresponse.cc) - set_target_properties(_stationresponse PROPERTIES PREFIX "") - target_include_directories(_stationresponse PRIVATE ${PYTHON_INCLUDE_DIR} ${Boost_INCLUDE_DIRS}) - if (${PYTHON_VERSION_MAJOR} VERSION_LESS "3") - target_link_libraries(_stationresponse stationresponse ${CASA_PYTHON_LIBRARY} ${Boost_PYTHON_LIBRARY} ${Boost_NUMPY_LIBRARY} ${PYTHON_LIBRARIES}) - else (${PYTHON_VERSION_MAJOR} VERSION_LESS "3") - target_link_libraries(_stationresponse stationresponse ${CASA_PYTHON3_LIBRARY} ${Boost_PYTHON3_LIBRARY} ${Boost_NUMPY3_LIBRARY} ${PYTHON_LIBRARIES}) - endif (${PYTHON_VERSION_MAJOR} VERSION_LESS "3") - install(TARGETS _stationresponse DESTINATION ${PYTHON_INSTALL_DIR}/lofar/stationresponse) - install(FILES __init__.py DESTINATION ${PYTHON_INSTALL_DIR}/lofar/stationresponse) -endif(BOOST_PY_FOUND) - +if (BUILD_PYTHON) + find_package (Python COMPONENTS Development) + message("Compiling Python ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} support. If this is not the intended target use 'DPYTHON_EXECUTABLE' to control.") + # bind against boost-python for compilation of the python API + # depending on major release version of the python libraries + if (${PYTHON_VERSION_MAJOR} VERSION_LESS "3") + find_package (Boost REQUIRED COMPONENTS python numpy) + find_package (Casacore REQUIRED COMPONENTS python) + message(STATUS "Boost python library: ${Boost_PYTHON_LIBRARY}") + message(STATUS "Boost numpy library: ${Boost_NUMPY_LIBRARY}") + message(STATUS "Python library ${PYTHON_LIBRARIES}") + set(BOOST_PY_FOUND TRUE) + else (${PYTHON_VERSION_MAJOR} VERSION_LESS "3") + find_package (Boost REQUIRED COMPONENTS python3 numpy3) + find_package (Casacore REQUIRED COMPONENTS python3) + message(STATUS "Boost python library: ${Boost_PYTHON3_LIBRARY}") + message(STATUS "Boost numpy library: ${Boost_NUMPY3_LIBRARY}") + message(STATUS "Python library ${PYTHON_LIBRARIES}") + set(BOOST_PY_FOUND TRUE) + endif (${PYTHON_VERSION_MAJOR} VERSION_LESS "3") + + + if(BOOST_PY_FOUND) + add_library(_stationresponse MODULE pystationresponse.cc) + set_target_properties(_stationresponse PROPERTIES PREFIX "") + target_include_directories(_stationresponse PRIVATE ${PYTHON_INCLUDE_DIR} ${Boost_INCLUDE_DIRS}) + if (${PYTHON_VERSION_MAJOR} VERSION_LESS "3") + target_link_libraries(_stationresponse stationresponse ${CASA_PYTHON_LIBRARY} ${Boost_PYTHON_LIBRARY} ${Boost_NUMPY_LIBRARY} ${PYTHON_LIBRARIES}) + else (${PYTHON_VERSION_MAJOR} VERSION_LESS "3") + target_link_libraries(_stationresponse stationresponse ${CASA_PYTHON3_LIBRARY} ${Boost_PYTHON3_LIBRARY} ${Boost_NUMPY3_LIBRARY} ${PYTHON_LIBRARIES}) + endif (${PYTHON_VERSION_MAJOR} VERSION_LESS "3") + install(TARGETS _stationresponse DESTINATION ${PYTHON_INSTALL_DIR}/lofar/stationresponse) + install(FILES __init__.py DESTINATION ${PYTHON_INSTALL_DIR}/lofar/stationresponse) + endif(BOOST_PY_FOUND) +endif (BUILD_PYTHON)