2023-05-29 10:41:03 +02:00
OPTION ( INTERNAL_BOOST "Use internal version of the Boost library" ON )
OPTION ( INTERNAL_EIGEN "Use internal version of the Eigen library" ON )
OPTION ( INTERNAL_HDF5 "Use internal HDF5" ON )
OPTION ( INTERNAL_GSL "Use internal GSL" ON )
OPTION ( INTERNAL_FFTW "Use internal FFTW" ON )
OPTION ( STACKTRACE_USE_BACKTRACE "Use backtrace for stacktrace" ON )
message ( STATUS "Compiler ID is: C -> ${CMAKE_C_COMPILER_ID}, CXX -> ${CMAKE_CXX_COMPILER_ID}" )
MACRO ( CHECK_CHANGE_STATE VAR )
IF ( DEFINED _PREVIOUS_ ${ VAR } )
# message("Already defined value=${_PREVIOUS_${VAR}}")
IF ( NOT ${ _PREVIOUS_${VAR } }} EQUAL ${ ${VAR } } )
# message("Not equal to previous state")
foreach ( loopvar ${ ARGN } )
# message("Clearing ${loopvar}")
UNSET ( ${ loopvar } CACHE )
endforeach ( )
ENDIF ( NOT ${ _PREVIOUS_${VAR } }} EQUAL ${ ${VAR } } )
ENDIF ( DEFINED _PREVIOUS_ ${ VAR } )
# message("Marking internal ${VAR} with ${${VAR}}")
SET ( _PREVIOUS_ ${ VAR } ${ ${VAR } } CACHE INTERNAL "Internal value" )
ENDMACRO ( CHECK_CHANGE_STATE )
CHECK_CHANGE_STATE ( INTERNAL_BOOST Boost_LIBRARIES Boost_INCLUDE_DIRS )
CHECK_CHANGE_STATE ( INTERNAL_GSL GSL_LIBRARY GSL_CBLAS_LIBRARY GSL_INCLUDE )
CHECK_CHANGE_STATE ( INTERNAL_HDF5 HDF5_INCLUDE_DIR HDF5_LIBRARIES HDF5_CXX_LIBRARIES HDF5_DIR )
SET ( BUILD_PREFIX ${ CMAKE_BINARY_DIR } /external_build )
SET ( EXT_INSTALL ${ CMAKE_BINARY_DIR } /ext_install )
################
# BUILD CFITSIO
################
SET ( CFITSIO_URL "http://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-3.47.tar.gz" CACHE STRING "URL to download CFITSIO from" )
mark_as_advanced ( CFITSIO_URL )
ExternalProject_Add ( cfitsio
U R L $ { C F I T S I O _ U R L }
U R L _ H A S H S H A 1 = 5 a 2 5 0 1 6 d c a f 1 2 1 1 7 d 9 5 0 e 4 2 7 8 e 1 0 d 3 9 c 6 c 7 d 3 3 a 5
P R E F I X $ { B U I L D _ P R E F I X } / c f i t s i o - p r e f i x
C O N F I G U R E _ C O M M A N D . / c o n f i g u r e - - p r e f i x = $ { E X T _ I N S T A L L } - - d i s a b l e - c u r l C P P F L A G S = $ { C O N F I G U R E _ C P P _ F L A G S } C C = $ { C M A K E _ C _ C O M P I L E R } C X X = $ { C M A K E _ C X X _ C O M P I L E R }
B U I L D _ I N _ S O U R C E 1
B U I L D _ B Y P R O D U C T S $ { E X T _ I N S T A L L } / l i b / l i b c f i t s i o . a
)
SET ( CFITSIO_LIBRARY ${ EXT_INSTALL } /lib/libcfitsio.a )
SET ( ares_DEPS ${ ares_DEPS } cfitsio )
################
# BUILD HEALPIX
################
SET ( HEALPIX_URL "https://sourceforge.net/projects/healpix/files/Healpix_3.50/healpix_cxx-3.50.0.tar.gz/download" CACHE STRING "URL for Healpix" )
SET ( HEALPIX_BUILD ${ BUILD_PREFIX } /healpix-prefix/src/healpix-build )
SET ( HEALPIX_DIR ${ BUILD_PREFIX } /healpix-prefix/src/healpix )
ExternalProject_Add ( healpix
D E P E N D S c f i t s i o
P R E F I X $ { B U I L D _ P R E F I X } / h e a l p i x - p r e f i x
U R L $ { H E A L P I X _ U R L }
U R L _ H A S H S H A 1 = c 8 a 5 3 7 e 7 4 3 f 7 6 0 d f a 4 5 3 c a d 2 4 6 0 6 5 d 3 7 f 7 2 f c 0 c b
C O N F I G U R E _ C O M M A N D $ { C M A K E _ C O M M A N D }
- D H E A L P I X _ C C = $ { C M A K E _ C _ C O M P I L E R }
- D H E A L P I X _ C X X = $ { C M A K E _ C X X _ C O M P I L E R }
- D H E A L P I X _ D I R : S T R I N G = $ { H E A L P I X _ D I R }
- D H E A L P I X _ I N S T A L L : S T R I N G = $ { E X T _ I N S T A L L }
- D C F I T S I O _ L I B : S T R I N G = $ { C F I T S I O _ L I B R A R Y }
- P $ { C M A K E _ S O U R C E _ D I R } / e x t e r n a l / c o n f i g u r e _ h e a l p i x . c m a k e
B U I L D _ B Y P R O D U C T S $ { E X T _ I N S T A L L } / l i b / l i b h e a l p i x _ c x x . a
)
SET ( HEALPIX_LIBRARIES
$ { E X T _ I N S T A L L } / l i b / l i b h e a l p i x _ c x x . a
$ { E X T _ I N S T A L L } / l i b / l i b c f i t s i o . a
)
SET ( ares_DEPS ${ ares_DEPS } healpix )
#
# Backtrace
#
SET ( BACKTRACE_LIBRARY )
IF ( STACKTRACE_USE_BACKTRACE )
SET ( BACKTRACE_URL "https://github.com/ianlancetaylor/libbacktrace/archive/f24e9f401fde0249ca48fa98493a672e83b0f3dc.tar.gz" CACHE STRING "URL to download backtrace from" )
mark_as_advanced ( BACKTRACE_URL )
ExternalProject_Add ( backtrace
U R L $ { B A C K T R A C E _ U R L }
U R L _ H A S H S H A 1 = 1 a 1 2 c e 8 d b e 9 4 9 8 0 e b f 3 f c 7 e 8 b d 2 2 f 3 7 6 e 3 b d 2 1 c b
P R E F I X $ { B U I L D _ P R E F I X } / b a c k t r a c e - p r e f i x
C O N F I G U R E _ C O M M A N D . / c o n f i g u r e - - p r e f i x = $ { E X T _ I N S T A L L } - - w i t h - p i c C P P F L A G S = $ { C O N F I G U R E _ C P P _ F L A G S } C C = $ { C M A K E _ C _ C O M P I L E R } C X X = $ { C M A K E _ C X X _ C O M P I L E R }
B U I L D _ I N _ S O U R C E 1
B U I L D _ B Y P R O D U C T S $ { E X T _ I N S T A L L } / l i b / l i b b a c k t r a c e . a
)
SET ( ares_DEPS ${ ares_DEPS } backtrace )
SET ( BACKTRACE_LIBRARY ${ EXT_INSTALL } /lib/libbacktrace.a )
ENDIF ( )
################
# BUILD BOOST
################
IF ( INTERNAL_BOOST )
SET ( BOOST_URL "https://boostorg.jfrog.io/artifactory/main/release/1.74.0/source/boost_1_74_0.tar.bz2" CACHE STRING "URL to download Boost from" )
mark_as_advanced ( BOOST_URL )
SET ( BOOST_SOURCE_DIR ${ BUILD_PREFIX } /boost-prefix/src/boost )
set ( LINKER_EXTRA_FLAGS )
message ( STATUS "Compiler version is ${CMAKE_CXX_COMPILER_VERSION}, ID is ${CMAKE_CXX_COMPILER_ID}" )
string ( REGEX REPLACE "^([0-9]+\\.[0-9]+).*$" "\\1" ToolsetVer "${CMAKE_CXX_COMPILER_VERSION}" )
IF ( CMAKE_CXX_COMPILER_ID MATCHES "^Intel$" )
SET ( b2_toolset intel )
SET ( COMPILER_EXTRA_FLAGS "-fPIC" )
elseif ( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "Darwin" )
SET ( b2_toolset darwin )
else ( )
SET ( b2_toolset gcc )
SET ( COMPILER_EXTRA_FLAGS "-fPIC -std=gnu++14" )
endif ( )
add_definitions ( "-Wno-unused-local-typedefs" )
elseif ( CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" )
SET ( b2_toolset darwin )
SET ( COMPILER_EXTRA_FLAGS "-std=c++14" )
elseif ( CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
SET ( b2_toolset clang )
SET ( COMPILER_EXTRA_FLAGS "-std=c++14" )
endif ( )
SET ( COMPILER_EXTRA_FLAGS "${COMPILER_EXTRA_FLAGS} -I${EXT_INSTALL}/include" )
SET ( LINKER_EXTRA_FLAGS "${LINKER_EXTRA_FLAGS} -L${EXT_INSTALL}/lib" )
message ( STATUS "Building boost with toolset ${b2_toolset}" )
IF ( STACKTRACE_USE_BACKTRACE )
SET ( BOOST_STACKTRACE ${ BOOST_SOURCE_DIR } /stage/lib/libboost_stacktrace_backtrace.a )
SET ( BOOST_DEPS backtrace )
ELSE ( )
SET ( BOOST_STACKTRACE ${ BOOST_SOURCE_DIR } /stage/lib/libboost_stacktrace_basic.a )
SET ( BOOST_DEPS )
ENDIF ( )
SET ( BOOST_LIBRARIES
$ { B O O S T _ S O U R C E _ D I R } / s t a g e / l i b / l i b b o o s t _ t i m e r . a
$ { B O O S T _ S O U R C E _ D I R } / s t a g e / l i b / l i b b o o s t _ c h r o n o . a
$ { B O O S T _ S O U R C E _ D I R } / s t a g e / l i b / l i b b o o s t _ r a n d o m . a
$ { B O O S T _ S O U R C E _ D I R } / s t a g e / l i b / l i b b o o s t _ r e g e x . a
$ { B O O S T _ S O U R C E _ D I R } / s t a g e / l i b / l i b b o o s t _ p r o g r a m _ o p t i o n s . a
$ { B O O S T _ S O U R C E _ D I R } / s t a g e / l i b / l i b b o o s t _ s y s t e m . a
$ { B O O S T _ S T A C K T R A C E }
$ { B O O S T _ S O U R C E _ D I R } / s t a g e / l i b / l i b b o o s t _ e x c e p t i o n . a )
ExternalProject_Add ( boost
U R L $ { B O O S T _ U R L }
D E P E N D S $ { B O O S T _ D E P S }
U R L _ H A S H S H A 1 = f 8 2 c 0 d 8 6 8 5 b 4 d 0 e 3 9 7 1 e 8 e 2 a 8 f 9 e f 1 5 5 1 4 1 2 c 1 2 5
P R E F I X $ { B U I L D _ P R E F I X } / b o o s t - p r e f i x
C O N F I G U R E _ C O M M A N D $ { C M A K E _ C O M M A N D } - D T O O L S E T = $ { b 2 _ t o o l s e t } " - D C O M P I L E R : S T R I N G = $ { C M A K E _ C X X _ C O M P I L E R } " " - D C O M P I L E R _ E X T R A _ F L A G S = $ { C O M P I L E R _ E X T R A _ F L A G S } " " - D I N S T A L L _ P A T H : S T R I N G = $ { E X T _ I N S T A L L } " " - D L I N K E R _ E X T R A _ F L A G S = $ { L I N K E R _ E X T R A _ F L A G S } " " - D S R C _ D I R : S T R I N G = $ { B O O S T _ S O U R C E _ D I R } " - P $ { C M A K E _ S O U R C E _ D I R } / e x t e r n a l / c o n f i g u r e _ b o o s t . c m a k e
B U I L D _ I N _ S O U R C E 1
B U I L D _ C O M M A N D $ { B O O S T _ S O U R C E _ D I R } / b 2 - - w i t h - r e g e x - d + 2 - - w i t h - e x c e p t i o n - - w i t h - c h r o n o - - w i t h - t i m e r - - w i t h - p r o g r a m _ o p t i o n s - - w i t h - r a n d o m - - w i t h - s t a c k t r a c e t o o l s e t = $ { b 2 _ t o o l s e t } - c m a k e v a r i a n t = r e l e a s e
I N S T A L L _ C O M M A N D e c h o " N o i n s t a l l "
B U I L D _ B Y P R O D U C T S $ { B O O S T _ L I B R A R I E S }
)
# PATCH_COMMAND patch -p1 -d ${BOOST_SOURCE_DIR} -i ${CMAKE_SOURCE_DIR}/external/patch-boost
SET ( Boost_INCLUDE_DIRS ${ BOOST_SOURCE_DIR } CACHE STRING "Boost path" FORCE )
SET ( boost_built boost )
mark_as_advanced ( Boost_INCLUDE_DIRS )
SET ( ares_DEPS ${ ares_DEPS } boost )
ELSE ( INTERNAL_BOOST )
find_package ( Boost 1.69 REQUIRED COMPONENTS random chrono regex system program_options timer stacktrace_basic OPTIONAL_COMPONENTS stacktrace_backtrace stacktrace_addr2line )
if ( ${ Boost_VERSION } VERSION_GREATER 1000 )
math ( EXPR TMP_MAJOR "${Boost_VERSION} / 100000" )
math ( EXPR TMP_MINOR "(${Boost_VERSION} - ${TMP_MAJOR} * 100000) / 100" )
math ( EXPR TMP_PATCHLEVEL "${Boost_VERSION} - ${TMP_MAJOR} * 100000 - ${TMP_MINOR} * 100" )
set ( Boost_VERSION ${ TMP_MAJOR } . ${ TMP_MINOR } . ${ TMP_PATCHLEVEL } )
ENDIF ( )
message ( STATUS "Boost version ${Boost_VERSION}" )
if ( ${ Boost_VERSION } VERSION_GREATER_EQUAL 1.70 )
set ( BOOST_LIBRARIES Boost::headers Boost::random Boost::chrono Boost::regex Boost::system Boost::program_options Boost::timer )
if ( Boost_stacktrace_backtrace_FOUND )
set ( BOOST_LIBRARIES ${ BOOST_LIBRARIES } Boost::stacktrace_backtrace )
else ( )
set ( BOOST_LIBRARIES ${ BOOST_LIBRARIES } Boost::stacktrace_basic )
endif ( )
else ( )
SET ( BOOST_LIBRARIES ${ Boost_LIBRARIES } )
endif ( )
SET ( BOOST_ROOT )
SET ( boost_built )
ENDIF ( INTERNAL_BOOST )
################
# BUILD Eigen
################
IF ( INTERNAL_EIGEN )
SET ( EIGEN_URL "https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.bz2" CACHE STRING "URL to download Eigen from" )
mark_as_advanced ( EIGEN_URL )
ExternalProject_Add ( eigen
U R L $ { E I G E N _ U R L }
U R L _ H A S H M D 5 = b 9 e 9 8 a 2 0 0 d 2 4 5 5 f 0 6 d b 9 c 6 6 1 c 5 6 1 0 4 9 6
P R E F I X $ { B U I L D _ P R E F I X } / e i g e n - p r e f i x
C M A K E _ A R G S
- D C M A K E _ I N S T A L L _ P R E F I X = $ { E X T _ I N S T A L L } - D E I G E N _ T E S T _ N O _ O P E N G L = O N
- D C M A K E _ C _ C O M P I L E R = $ { C M A K E _ C _ C O M P I L E R }
- D C M A K E _ C X X _ C O M P I L E R = $ { C M A K E _ C X X _ C O M P I L E R }
# PATCH_COMMAND ${CMAKE_COMMAND}
# -DBUILD_PREFIX=${BUILD_PREFIX}/eigen-prefix
# -DPATCH_FILE=${CMAKE_SOURCE_DIR}/external/patch_eigen
# -DSOURCE_PREFIX=${BUILD_PREFIX}/eigen-prefix/src/eigen
# -P ${CMAKE_SOURCE_DIR}/external/check_and_apply_patch.cmake
)
SET ( EIGEN_INCLUDE_DIRS ${ EXT_INSTALL } /include/eigen3 )
SET ( ares_DEPS ${ ares_DEPS } eigen )
SET ( EIGEN_PATH ${ EXT_INSTALL } )
ELSE ( INTERNAL_EIGEN )
if ( DEFINED EIGEN_PATH )
set ( _eigen_old_pkg_path $ENV{ PKG_CONFIG_PATH } )
set ( ENV{PKG_CONFIG_PATH} ${ EIGEN_PATH } /share/pkgconfig )
endif ( )
pkg_check_modules ( EIGEN NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH REQUIRED eigen3 )
if ( DEFINED EIGEN_PATH )
set ( ENV{PKG_CONFIG_PATH} ${ _eigen_old_pkg_path } )
endif ( )
IF ( EIGEN_FOUND )
IF ( EIGEN_STATIC_INCLUDE_DIRS )
SET ( EIGEN_INCLUDE_DIRS ${ EIGEN_STATIC_INCLUDE_DIRS } )
ENDIF ( )
ELSE ( )
message ( FATAL_ERROR "Eigen has not been found" )
ENDIF ( )
ENDIF ( INTERNAL_EIGEN )
################
# Build PyBind11
################
IF ( BUILD_PYTHON_EXTENSION )
2024-11-16 14:23:00 +01:00
SET ( PYBIND11_URL "https://github.com/pybind/pybind11/archive/v2.11.1.tar.gz" CACHE STRING "URL to download Pybind11 from" )
2023-05-29 10:41:03 +02:00
mark_as_advanced ( PYBIND11_URL )
FetchContent_Declare (
p y b i n d 1 1
U R L $ { P Y B I N D 1 1 _ U R L }
2024-11-16 14:23:00 +01:00
U R L _ H A S H M D 5 = 4 9 e 9 2 f 9 2 2 4 4 0 2 1 9 1 2 a 5 6 9 3 5 9 1 8 c 9 2 7 d 0
2023-05-29 10:41:03 +02:00
)
ENDIF ( )
SET ( R3D_URL "https://github.com/devonmpowell/r3d/archive/b3eef85ae5dc111d0148491772e0820406cfe0ea.zip" CACHE STRING "URL to download R3D from" )
mark_as_advanced ( R3D_URL )
FetchContent_Declare (
r 3 d
U R L $ { R 3 D _ U R L }
U R L _ H A S H M D 5 = 9 e 3 c 4 c 7 3 4 8 8 0 5 5 9 3 5 3 9 4 6 4 a a e 1 4 9 6 4 6 a
)
################
# BUILD HDF5
################
if ( INTERNAL_HDF5 )
SET ( HDF5_URL "https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.7/src/hdf5-1.10.7.tar.gz" CACHE STRING "URL to download HDF5 from" )
mark_as_advanced ( HDF5_URL )
SET ( HDF5_SOURCE_DIR ${ BUILD_PREFIX } /hdf5-prefix/src/hdf5 )
SET ( HDF5_BIN_DIR ${ EXT_INSTALL } )
ExternalProject_Add ( hdf5
P R E F I X $ { B U I L D _ P R E F I X } / h d f 5 - p r e f i x
U R L $ { H D F 5 _ U R L }
U R L _ H A S H M D 5 = 0 0 6 e d 7 8 5 9 4 2 f 4 e d 9 a 6 f 3 1 5 5 6 d 0 e f 8 b a 5
C M A K E _ A R G S
- D C M A K E _ I N S T A L L _ P R E F I X = $ { E X T _ I N S T A L L }
- D C M A K E _ C _ C O M P I L E R = $ { C M A K E _ C _ C O M P I L E R }
- D C M A K E _ C X X _ C O M P I L E R = $ { C M A K E _ C X X _ C O M P I L E R }
- D H D F 5 _ B U I L D _ C P P _ L I B = O N
- D H D F 5 _ B U I L D _ T O O L S = O N
- D H D F 5 _ B U I L D _ H L _ L I B = O N
B U I L D _ B Y P R O D U C T S $ { E X T _ I N S T A L L } / l i b / l i b h d f 5 . a $ { E X T _ I N S T A L L } / l i b / l i b h d f 5 - s t a t i c . a $ { E X T _ I N S T A L L } / l i b / l i b h d f 5 _ c p p . a
)
SET ( hdf5_built hdf5 )
set ( HDF5_LIBRARIES ${ HDF5_BIN_DIR } /lib/libhdf5.a CACHE STRING "HDF5 lib" FORCE )
set ( HDF5_CXX_LIBRARIES ${ HDF5_BIN_DIR } /lib/libhdf5_cpp.a CACHE STRING "HDF5 C++ lib" FORCE )
SET ( HDF5_INCLUDE_DIR ${ HDF5_BIN_DIR } /include CACHE STRING "HDF5 include path" FORCE )
SET ( CONFIGURE_LDFLAGS "${CONFIGURE_LDFLAGS} -L${HDF5_BIN_DIR}/lib" )
SET ( HDF5_ROOTDIR ${ HDF5_BIN_DIR } )
SET ( ares_DEPS ${ ares_DEPS } hdf5 )
mark_as_advanced ( HDF5_LIBRARIES HDF5_CXX_LIBRARIES HDF5_INCLUDE_DIR )
else ( INTERNAL_HDF5 )
mark_as_advanced ( CLEAR HDF5_LIBRARIES HDF5_CXX_LIBRARIES HDF5_INCLUDE_DIR )
find_package ( HDF5 COMPONENTS CXX )
SET ( HDF5_ROOTDIR ${ HDF5_BIN_DIR } )
SET ( HDF5_INCLUDE_DIR ${ HDF5_INCLUDE_DIRS } )
endif ( INTERNAL_HDF5 )
##################
# Build GSL
##################
IF ( INTERNAL_GSL )
SET ( GSL_URL "http://ftpmirror.gnu.org/gsl/gsl-2.3.tar.gz" CACHE STRING "URL to download GSL from " )
mark_as_advanced ( GSL_URL )
SET ( GSL_SOURCE_DIR ${ BUILD_PREFIX } /gsl-prefix/src/gsl )
ExternalProject_Add ( gsl
U R L $ { G S L _ U R L }
P R E F I X $ { B U I L D _ P R E F I X } / g s l - p r e f i x
C O N F I G U R E _ C O M M A N D $ { G S L _ S O U R C E _ D I R } / c o n f i g u r e
- - p r e f i x = $ { E X T _ I N S T A L L } - - d i s a b l e - s h a r e d
- - w i t h - p i c
C P P F L A G S = $ { C O N F I G U R E _ C P P _ F L A G S } C C = $ { C M A K E _ C _ C O M P I L E R } C X X = $ { C M A K E _ C X X _ C O M P I L E R }
B U I L D _ I N _ S O U R C E 1
B U I L D _ B Y P R O D U C T S $ { E X T _ I N S T A L L } / l i b / l i b g s l . a $ { E X T _ I N S T A L L } / l i b / l i b g s l c b l a s . a
)
SET ( GSL_INTERNAL_LIBS ${ EXT_INSTALL } /lib )
SET ( GSL_LIBRARY ${ GSL_INTERNAL_LIBS } /libgsl.a CACHE STRING "GSL internal path" FORCE )
SET ( GSL_CBLAS_LIBRARY ${ GSL_INTERNAL_LIBS } /libgslcblas.a CACHE STRING "GSL internal path" FORCE )
set ( GSL_INCLUDE ${ CMAKE_BINARY_DIR } /ext_install/include CACHE STRING "GSL internal path" FORCE )
SET ( ares_DEPS ${ ares_DEPS } gsl )
mark_as_advanced ( GSL_LIBRARY GSL_INCLUDE GSL_CBLAS_LIBRARY )
ELSE ( INTERNAL_GSL )
mark_as_advanced ( CLEAR GSL_LIBRARY GSL_INCLUDE GSL_CBLAS_LIBRARY )
find_library ( GSL_LIBRARY gsl )
find_library ( GSL_CBLAS_LIBRARY gslcblas )
find_path ( GSL_INCLUDE NAMES gsl/gsl_blas.h )
message ( STATUS "GSL paths: ${GSL_LIBRARY} ${GSL_CBLAS_LIBRARY} ${GSL_INCLUDE}" )
if ( NOT ( GSL_LIBRARY OR GSL_CBLAS_LIBRARY OR GSL_INCLUDE ) )
message ( FATAL_ERROR "GSL has not been found" )
endif ( )
ENDIF ( INTERNAL_GSL )
#############
# Build FFTW
#############
IF ( INTERNAL_FFTW )
SET ( FFTW_URL "http://www.fftw.org/fftw-3.3.8.tar.gz" CACHE STRING "URL to download FFTW from" )
mark_as_advanced ( FFTW_URL )
SET ( EXTRA_FFTW_CONF )
# IF(HAVE_SSE)
# SET(EXTRA_FFTW_CONF ${EXTRA_FFTW_CONF} --enable-sse)
# ENDIF(HAVE_SSE)
# IF(HAVE_SSE2)
# SET(EXTRA_FFTW_CONF ${EXTRA_FFTW_CONF} --enable-sse2)
# ENDIF(HAVE_SSE2)
# IF(HAVE_AVX)
# SET(EXTRA_FFTW_CONF ${EXTRA_FFTW_CONF} --enable-avx)
# ENDIF(HAVE_AVX)
IF ( ENABLE_OPENMP )
SET ( EXTRA_FFTW_CONF ${ EXTRA_FFTW_CONF } --enable-openmp )
SET ( FFTW_LIBS ${ FFTW_LIBS } ${ EXT_INSTALL } /lib/libfftw3_omp.a )
ENDIF ( ENABLE_OPENMP )
IF ( ENABLE_MPI )
SET ( MPI_OPT ${ EXTRA_FFTW_CONF } --enable-mpi MPICC= ${ MPI_C_COMPILER } )
SET ( FFTW_LIBS ${ FFTW_LIBS } ${ EXT_INSTALL } /lib/libfftw3_mpi.a )
ENDIF ( ENABLE_MPI )
SET ( EXTRA_FFTW_CONF ${ EXTRA_FFTW_CONF } "CC=${CMAKE_C_COMPILER}" "CXX=${CMAKE_CXX_COMPILER}" )
IF ( BUILD_PYTHON_EXTENSION )
SET ( EXTRA_FFTW_CONF ${ EXTRA_FFTW_CONF } "--with-pic" )
ENDIF ( )
SET ( FFTW_SOURCE ${ BUILD_PREFIX } /fftw-prefix/src/fftw )
message ( STATUS "Opts: ${EXTRA_FFTW_CONF}" )
ExternalProject_Add ( fftw
U R L $ { F F T W _ U R L }
U R L _ H A S H M D 5 = 8 a a c 8 3 3 c 9 4 3 d 8 e 9 0 d 5 1 b 6 9 7 b 2 7 d 4 3 8 4 d
P R E F I X $ { B U I L D _ P R E F I X } / f f t w - p r e f i x
C O N F I G U R E _ C O M M A N D
$ { F F T W _ S O U R C E } / c o n f i g u r e
- - p r e f i x = $ { E X T _ I N S T A L L }
$ { E X T R A _ F F T W _ C O N F } - - d i s a b l e - s h a r e d $ { M P I _ O P T }
B U I L D _ B Y P R O D U C T S $ { F F T W _ L I B S } $ { E X T _ I N S T A L L } / l i b / l i b f f t w 3 . a
)
SET ( FFTW_INCLUDE_DIR ${ EXT_INSTALL } /include )
SET ( FFTW_OMP_LIBRARIES ${ EXT_INSTALL } /lib/libfftw3_omp.a )
SET ( FFTW_LIBRARIES ${ EXT_INSTALL } /lib/libfftw3.a )
SET ( FFTW_MPI_LIBRARIES ${ EXT_INSTALL } /lib/libfftw3_mpi.a )
SET ( ares_DEPS ${ ares_DEPS } fftw )
ELSE ( INTERNAL_FFTW )
set ( FFTW_OMP_FIND_REQUIRED ${ ENABLE_OPENMP } )
SET ( FFTW_NAMES fftw3 )
set ( FFTW_FIND_REQUIRED YES )
IF ( ENABLE_MPI )
set ( FFTW_MPI_FIND_REQUIRED YES )
ENDIF ( )
IF ( ENABLE_OPENMP )
set ( FFTW_OMP_FIND_REQUIRED YES )
ENDIF ( )
include ( ${ CMAKE_SOURCE_DIR } /cmake/FindFFTW.cmake )
ENDIF ( INTERNAL_FFTW )
IF ( ENABLE_OPENMP )
SET ( FFTW_LIBRARIES ${ FFTW_OMP_LIBRARIES } ${ FFTW_LIBRARIES } )
ENDIF ( ENABLE_OPENMP )
IF ( ENABLE_MPI )
SET ( FFTW_LIBRARIES ${ FFTW_MPI_LIBRARIES } ${ FFTW_LIBRARIES } )
ENDIF ( ENABLE_MPI )
MESSAGE ( STATUS "Used FFTW libraries: ${FFTW_LIBRARIES}" )
SET ( COSMOTOOL_DIR ${ CMAKE_SOURCE_DIR } /external/cosmotool )
#MESSAGE(STATUS "Cosmotool deps is ${ares_DEPS}")
SET ( SPECIAL_PREFIX_PATH ${ CMAKE_PREFIX_PATH } )
list ( INSERT SPECIAL_PREFIX_PATH 0 ${ EXT_INSTALL } )
ExternalProject_Add ( cosmotool
D E P E N D S $ { a r e s _ D E P S }
S O U R C E _ D I R $ { C O S M O T O O L _ D I R }
P R E F I X $ { B U I L D _ P R E F I X } / c o s m o t o o l - p r e f i x
C M A K E _ C A C H E _ A R G S
- D C M A K E _ I N S T A L L _ P R E F I X : S T R I N G = $ { E X T _ I N S T A L L }
- D C M A K E _ P R E F I X _ P A T H : S T R I N G = $ { S P E C I A L _ P R E F I X _ P A T H }
- D E I G E N _ P A T H : S T R I N G = $ { E I G E N _ P A T H }
- D C M A K E _ M O D U L E _ P A T H : S T R I N G = $ { E X T _ I N S T A L L } / s h a r e / c m a k e ; $ { C M A K E _ M O D U L E _ P A T H }
- D C M A K E _ C _ C O M P I L E R : S T R I N G = $ { C M A K E _ C _ C O M P I L E R }
- D C M A K E _ C X X _ C O M P I L E R : S T R I N G = $ { C M A K E _ C X X _ C O M P I L E R }
- D H D F 5 _ D I R : S T R I N G = $ { H D F 5 _ R O O T D I R } / s h a r e / c m a k e
- D H D F 5 _ R O O T D I R : S T R I N G = $ { H D F 5 _ R O O T D I R }
- D N E T C D F _ I N C L U D E _ P A T H : S T R I N G = $ { N E T C D F _ I N C L U D E _ P A T H }
- D N E T C D F C P P _ I N C L U D E _ P A T H : S T R I N G = $ { N E T C D F C P P _ I N C L U D E _ P A T H }
- D G S L _ I N C L U D E _ P A T H : S T R I N G = $ { G S L _ I N C L U D E }
- D G S L _ L I B R A R Y : S T R I N G = $ { G S L _ L I B R A R Y }
- D G S L C B L A S _ L I B R A R Y : S T R I N G = $ { G S L _ C B L A S _ L I B R A R Y }
- D I N T E R N A L _ G S L : B O O L = O F F
- D I N T E R N A L _ E I G E N : B O O L = O F F
- D Y O R I C K _ S U P P O R T : B O O L = O F F
- D B U I L D _ P Y T H O N : B O O L = O F F
- D E N A B L E _ O P E N M P : B O O L = $ { E N A B L E _ O P E N M P }
- D P K G _ C O N F I G _ U S E _ C M A K E _ P R E F I X _ P A T H : B O O L = O N
- D B O O S T _ I N C L U D E D I R : S T R I N G = $ { B o o s t _ I N C L U D E _ D I R S }
- D Z L I B _ L I B R A R Y : S T R I N G = $ { Z L I B _ L I B R A R Y }
" - D C M A K E _ I N S T A L L _ D E F A U L T _ D I R E C T O R Y _ P E R M I S S I O N S : S T R I N G = $ { C M A K E _ I N S T A L L _ D E F A U L T _ D I R E C T O R Y _ P E R M I S S I O N S } "
B U I L D _ B Y P R O D U C T S $ { E X T _ I N S T A L L } / l i b / l i b C o s m o T o o l . a
L I S T _ S E P A R A T O R ;
)
SET ( COSMOTOOL_LIB ${ EXT_INSTALL } /lib/libCosmoTool.a )
set ( COSMOTOOL_INCLUDE ${ EXT_INSTALL } /include )
SET ( ares_DEPS ${ ares_DEPS } cosmotool )
### CLASS
SET ( CLASS_CODE_URL "https://github.com/lesgourg/class_public/archive/refs/tags/v2.9.4.tar.gz" CACHE STRING "URL for CLASS" )
SET ( LIBCLASS_PATH ${ BUILD_PREFIX } /class-code-prefix/src/class_code/libclass.a )
IF ( CMAKE_CXX_COMPILER_ID MATCHES "^Intel$" )
SET ( COMPILER_EXTRA_FLAGS "-fPIC" )
elseif ( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "Darwin" )
else ( )
SET ( COMPILER_EXTRA_FLAGS "-fPIC" )
endif ( )
elseif ( CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" )
elseif ( CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
endif ( )
if ( ENABLE_OPENMP )
SET ( CLASS_OPENMP ${ OpenMP_C_FLAGS } )
else ( )
SET ( CLASS_OPENMP )
endif ( )
ExternalProject_Add ( class_code
P R E F I X $ { B U I L D _ P R E F I X } / c l a s s - c o d e - p r e f i x
U R L $ { C L A S S _ C O D E _ U R L }
U R L _ H A S H S H A 1 = a d 0 c 7 7 3 9 d 2 3 c d d 0 4 2 6 3 f 0 0 3 0 1 2 0 d 1 5 9 f 3 b 4 e 5 b 6 e
C O N F I G U R E _ C O M M A N D e c h o " N o c o n f i g u r e "
B U I L D _ C O M M A N D m a k e C P P F L A G S = $ { C O N F I G U R E _ C P P _ F L A G S } C C = $ { C M A K E _ C _ C O M P I L E R } C X X = $ { C M A K E _ C X X _ C O M P I L E R } " C C F L A G = - D _ _ C L A S S D I R _ _ = \ \ \ " $ { B U I L D _ P R E F I X } / c l a s s - c o d e - p r e f i x / s r c / c l a s s _ c o d e \ \ \ " $ { C O M P I L E R _ E X T R A _ F L A G S } $ { C M A K E _ C _ F L A G S } $ { C M A K E _ C _ F L A G S _ $ { C M A K E _ B U I L D _ T Y P E } } " O P T F L A G = O M P F L A G = $ { C L A S S _ O P E N M P } l i b c l a s s . a
I N S T A L L _ C O M M A N D
$ { C M A K E _ C O M M A N D }
- D C L A S S _ S O U R C E _ I N C L U D E = $ { B U I L D _ P R E F I X } / c l a s s - c o d e - p r e f i x / s r c / c l a s s _ c o d e / i n c l u d e
- D C L A S S _ H E A D E R _ I N S T A L L _ P A T H = $ { E X T _ I N S T A L L } / i n c l u d e / c l a s s _ c o d e
- P $ { C M A K E _ S O U R C E _ D I R } / e x t e r n a l / i n s t a l l _ c l a s s . c m a k e
B U I L D _ I N _ S O U R C E 1
B U I L D _ B Y P R O D U C T S $ { L I B C L A S S _ P A T H }
)
SET ( ares_DEPS ${ ares_DEPS } class_code )