Commit bdfcec4c authored by jcfr's avatar jcfr
Browse files

COMP: Superbuild - Integrated NUMPY depending on CLAPACK

It remove the dependency on Fortran compiler

git-svn-id: http://svn.slicer.org/Slicer4/trunk@13557 3bd1e089-480b-0410-8dfb-8563597acbee
parent 217b69aa
......@@ -208,20 +208,16 @@ endif()
option(Slicer3_USE_PYTHON "Build Slicer with Python support" ON)
if(Slicer3_USE_PYTHON)
# Attempt to detect if we have a Fortran Compiler available.
include(CheckFortran)
if(CMAKE_Fortran_COMPILER)
option(Slicer3_BUILD_NUMPY "Build Slicer with NumPy (builds Blas and Lapack)." ON)
if(Slicer3_USE_PYTHON OR Slicer3_USE_PYTHONQT)
if(Slicer3_BUILD_NUMPY)
option(Slicer3_BUILD_SCIPY "Build Slicer with SciPy (requires NumPy)" ON)
endif()
option(Slicer3_BUILD_NUMPY "Build Slicer with NumPy (builds CLapack)." ON)
endif(CMAKE_Fortran_COMPILER)
endif() # Slicer3_USE_PYTHON
# Work in progress ...
#if(Slicer3_BUILD_NUMPY)
# option(Slicer3_BUILD_SCIPY "Build Slicer with SciPy (requires NumPy)" ON)
#endif()
endif()
#------------------------------------------------------------------------------
# Additional options
......@@ -271,7 +267,7 @@ endif()
# List of external projects
#------------------------------------------------------------------------------
set(external_project_list tk incrTcl iwidgets blt python blas lapack numpy scipy vtk CTK KWWidgets Insight BatchMake OpenIGTLink teem cmcurl slicer)
set(external_project_list tk incrTcl iwidgets blt python clapack numpy scipy vtk CTK KWWidgets Insight BatchMake OpenIGTLink teem cmcurl slicer)
#------------------------------------------------------------------------------
# Configure the CTest custom file - Used to suppress external project configure/build warnings
......@@ -310,10 +306,14 @@ if(Slicer3_USE_KWWIDGETS)
set(python_DEPENDENCIES tk)
endif()
endif()
set(clapack_DEPENDENCIES)
set(blas_DEPENDENCIES)
set(lapack_DEPENDENCIES)
set(numpy_DEPENDENCIES blas lapack python)
set(scipy_DEPENDENCIES numpy)
set(numpy_DEPENDENCIES CLAPACK python)
set(scipy_DEPENDENCIES NUMPY)
#set(lapack_DEPENDENCIES)
#set(numpy_DEPENDENCIES blas lapack python)
set(vtk_DEPENDENCIES)
set(CTK_DEPENDENCIES vtk)
if(Slicer3_USE_PYTHONQT)
......@@ -337,31 +337,29 @@ if(Slicer3_USE_KWWIDGETS)
include(External_incrTcl)
include(External_iwidgets)
include(External_blt)
endif(Slicer3_USE_KWWIDGETS)
endif()
if(Slicer3_USE_PYTHON OR Slicer3_USE_PYTHONQT)
include(External_Python26)
endif(Slicer3_USE_PYTHON OR Slicer3_USE_PYTHONQT)
if(CMAKE_Fortran_COMPILER AND Slicer3_BUILD_NUMPY)
include(External_BLAS)
include(External_LAPACK)
include(External_NumPy)
if(Slicer3_BUILD_SCIPY)
include(External_SciPy)
endif(Slicer3_BUILD_SCIPY)
endif(CMAKE_Fortran_COMPILER AND Slicer3_BUILD_NUMPY)
if(Slicer3_BUILD_NUMPY)
#include(External_BLAS)
include(External_CLAPACK)
include(External_NUMPY)
if(Slicer3_BUILD_SCIPY)
include(External_SciPy)
endif(Slicer3_BUILD_SCIPY)
endif()
endif()
include(External_VTK)
if(Slicer3_USE_QT)
include(External_CTK)
endif(Slicer3_USE_QT)
endif()
if(Slicer3_USE_KWWIDGETS)
include(External_KWWidgets)
endif(Slicer3_USE_KWWIDGETS)
endif()
include(External_Insight)
include(External_teem)
......@@ -380,19 +378,21 @@ if(Slicer3_USE_KWWIDGETS)
else()
list(APPEND slicer_DEPENDENCIES tcl tk itcl KWWidgets)
endif()
endif(Slicer3_USE_KWWIDGETS)
if(CMAKE_Fortran_COMPILER)
list(APPEND slicer_DEPENDENCIES numpy blas lapack)
endif(CMAKE_Fortran_COMPILER)
endif()
if(Slicer3_USE_QT)
list(APPEND slicer_DEPENDENCIES CTK)
endif(Slicer3_USE_QT)
endif()
if(Slicer3_USE_PYTHON)
if(Slicer3_USE_PYTHON OR Slicer3_USE_PYTHONQT)
list(APPEND slicer_DEPENDENCIES python)
endif(Slicer3_USE_PYTHON)
if(Slicer3_BUILD_NUMPY)
list(APPEND slicer_DEPENDENCIES NUMPY)
if(Slicer3_BUILD_SCIPY)
list(APPEND slicer_DEPENDENCIES scipy)
endif()
endif()
endif()
#-----------------------------------------------------------------------------
# Dump external project dependencies
......
set(clapack_version 3.2.1)
set(clapack_file "http://www.netlib.org/clapack/clapack-${clapack_version}-CMAKE.tgz")
# The CLAPACK external project for Titan
set(clapack_source "${CMAKE_CURRENT_BINARY_DIR}/CLAPACK")
set(clapack_binary "${CMAKE_CURRENT_BINARY_DIR}/CLAPACK-build")
# turn off the warnings for clapack on windows
string(REPLACE "/W3" "/W0" CMAKE_CXX_FLAGS_CLAPACK "${CMAKE_CXX_FLAGS}")
string(REPLACE "/W4" "/W0" CMAKE_CXX_FLAGS_CLAPACK
"${CMAKE_CXX_FLAGS_CLAPACK}")
string(REPLACE "/W3" "/W0" CMAKE_C_FLAGS_CLAPACK "${CMAKE_C_FLAGS}")
string(REPLACE "/W4" "/W0" CMAKE_C_FLAGS_CLAPACK
"${CMAKE_C_FLAGS_CLAPACK}")
ExternalProject_Add(CLAPACK
DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}
SOURCE_DIR ${clapack_source}
BINARY_DIR ${clapack_binary}
URL ${clapack_file}
CMAKE_GENERATOR ${gen}
CMAKE_ARGS
-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS_CLAPACK}
-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS_CLAPACK}
-DBUILD_SHARED_LIBS:BOOL=OFF
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
INSTALL_COMMAND ""
DEPENDS ${clapack_DEPENDENCIES}
)
set(CLAPACK_DIR "${clapack_binary}" CACHE PATH
"CLAPACK binary directory" FORCE)
mark_as_advanced(CLAPACK_DIR)
# The Numpy external project
set(numpy_source "${CMAKE_CURRENT_BINARY_DIR}/NUMPY")
set(numpy_binary "${CMAKE_CURRENT_BINARY_DIR}/NUMPY")
# to configure numpy we run a cmake -P script
# the script will create a site.cfg file
# then run python setup.py config to verify setup
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/NUMPY_configure_step.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/NUMPY_configure_step.cmake @ONLY)
# to build numpy we also run a cmake -P script.
# the script will set LD_LIBRARY_PATH so that
# python can run after it is built on linux
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/NUMPY_make_step.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/NUMPY_make_step.cmake @ONLY)
# create an external project to download numpy,
# and configure and build it
ExternalProject_Add(NUMPY
DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}
SOURCE_DIR ${numpy_source}
BINARY_DIR ${numpy_binary}
CONFIGURE_COMMAND ${CMAKE_COMMAND}
-P ${CMAKE_CURRENT_BINARY_DIR}/NUMPY_configure_step.cmake
BUILD_COMMAND ${CMAKE_COMMAND}
-P ${CMAKE_CURRENT_BINARY_DIR}/NUMPY_make_step.cmake
SVN_REPOSITORY http://svn.scipy.org/svn/numpy/trunk
INSTALL_COMMAND ""
DEPENDS ${numpy_DEPENDENCIES}
)
......@@ -8,4 +8,5 @@ ExternalProject_Add(${proj}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
DEPENDS ${scipy_DEPENDENCIES}
)
message("Configuring numpy:\n@numpy_binary@")
set(ENV{LD_LIBRARY_PATH} "@CMAKE_CURRENT_BINARY_DIR@/python-build/lib")
# setup the site.cfg file
file(WRITE "@numpy_binary@/site.cfg"
"
[blas]
library_dirs = @clapack_binary@/BLAS/SRC;@clapack_binary@/CLAPACK-build/F2CLIBS/libf2c
libraries = blas,libf2c
[lapack]
library_dirs = @clapack_binary@/SRC/
lapack_libs = lapack
")
execute_process(
COMMAND "@slicer_PYTHON_EXECUTABLE@" setup.py config
WORKING_DIRECTORY "@numpy_binary@"
RESULT_VARIABLE res)
if(NOT ${res} EQUAL 0)
message(FATAL_ERROR "Error in config of numpy")
endif()
message("Numpy config worked.")
message("Building numpy:\n@numpy_binary@")
set(ENV{LD_LIBRARY_PATH} "@CMAKE_CURRENT_BINARY_DIR@/python-build/lib")
execute_process(
COMMAND "@slicer_PYTHON_EXECUTABLE@" setup.py install
WORKING_DIRECTORY "@numpy_binary@"
RESULT_VARIABLE res)
if(NOT ${res} EQUAL 0)
message(FATAL_ERROR "Error in config of numpy")
endif()
message("Numpy config worked.")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment