diff --git a/.cmake/TargetX11.cmake b/.cmake/TargetX11.cmake index f997883..805ae0d 100644 --- a/.cmake/TargetX11.cmake +++ b/.cmake/TargetX11.cmake @@ -5,6 +5,9 @@ set(components find_package(X11 COMPONENTS ${components}) +# The X11::{component} targets only exist for CMake ≥ 3.14, +# so we create them here for backwards compatibility. + if(X11_FOUND) # make X11 look like a regular find_package component @@ -13,11 +16,9 @@ if(X11_FOUND) list(APPEND components X11) foreach(component ${components}) - message("${component} include = ${X11_${component}_INCLUDE_PATH}") - if(X11_${component}_FOUND) - if(NOT TARGET X11::${component}) - add_library(X11::${component} IMPORTED INTERFACE) - endif() + if(X11_${component}_FOUND AND + NOT TARGET X11::${component}) + add_library(X11::${component} IMPORTED INTERFACE) target_link_libraries(X11::${component} INTERFACE ${X11_${component}_LIB}) target_include_directories(X11::${component} SYSTEM diff --git a/.cmake/isce2_buildflags.cmake b/.cmake/isce2_buildflags.cmake index 447f0c0..a5b28b4 100644 --- a/.cmake/isce2_buildflags.cmake +++ b/.cmake/isce2_buildflags.cmake @@ -14,13 +14,15 @@ set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED y) set(CMAKE_CXX_EXTENSIONS n) -# TODO (fix RPATHs) -# We have to hack our RPATHs a bit for these shared libraries to be -# loaded by others on the install-side. Maybe these libraries should -# be combined and/or installed to a common ISCE2 lib directory. -# Is there a semantic way to propagate their RPATHs -# without using these global variables? +include(GNUInstallDirs) + +# add automatically determined parts of the RPATH, which point to directories +# outside of the build tree, to the install RPATH set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON) -list(APPEND CMAKE_INSTALL_RPATH - ${CMAKE_INSTALL_PREFIX}/${ISCE2_PKG}/components/isceobj/Util - ) + +# the RPATH to be used when installing, but only if it's not a system directory +set(abs_libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) +list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES ${abs_libdir} isSystemDir) +if("${isSystemDir}" STREQUAL "-1") + list(APPEND CMAKE_INSTALL_RPATH ${abs_libdir}) +endif() diff --git a/.cmake/isce2_helpers.cmake b/.cmake/isce2_helpers.cmake index f147569..8e67efa 100644 --- a/.cmake/isce2_helpers.cmake +++ b/.cmake/isce2_helpers.cmake @@ -50,22 +50,16 @@ endfunction() # Note that it first checks if a provided file is a target, # and if so, installs it as a TARGET instead. Make sure your # filenames and target names don't have any overlap! - function(InstallSameDir) -mark_as_advanced(isce2_bin_base) foreach(name ${ARGN}) if(TARGET ${name}) set(installtype TARGETS) else() set(installtype FILES) endif() - file(RELATIVE_PATH path ${isce2_bin_dir} ${CMAKE_CURRENT_BINARY_DIR}) + file(RELATIVE_PATH path ${isce2_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}) install(${installtype} ${name} DESTINATION ${ISCE2_PKG}/${path} ) endforeach() endfunction() -# We use this instead of CMAKE_BINARY_DIR to handle -# cases where isce2 is added as a subdirectory -set(isce2_bin_dir ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH - "ISCE2 root build directory") diff --git a/CMakeLists.txt b/CMakeLists.txt index 3292dc4..c526ec4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,15 +2,19 @@ cmake_minimum_required(VERSION 3.12 FATAL_ERROR) project(isce2 LANGUAGES C CXX Fortran) +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/.cmake) + include(CheckLanguage) check_language(CUDA) if(CMAKE_CUDA_COMPILER) + set(CMAKE_CUDA_STANDARD 11) + set(CMAKE_CUDA_STANDARD_REQUIRED TRUE) enable_language(CUDA) + find_package(CUDAToolkit) # TODO added in cmake 3.17 - copy this module endif() -list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/.cmake) - -find_package(Python 3.5 REQUIRED COMPONENTS Interpreter Development) +find_package(Python 3.5 REQUIRED COMPONENTS Interpreter Development + OPTIONAL_COMPONENTS NumPy) find_package(FFTW REQUIRED) find_package(Motif) find_package(OpenMP REQUIRED COMPONENTS C CXX Fortran) diff --git a/README.md b/README.md index b14851e..961b0ba 100644 --- a/README.md +++ b/README.md @@ -33,8 +33,10 @@ TERRASARX, and UAVSAR. - [Note On 'python3' Exectuable Convention](#python3-convention) - [License required for dependencies to enable some workflows in ISCE](#license-required-for-dependencies-to-enable-some-workflows-in-isce) 2. [Building ISCE](#building-isce) - - [Configuration control: SCONS\_CONFIG\_DIR and SConfigISCE](#configuration-control) - - [Install ISCE](#install-isce) + - [SCons](#scons-recommended) + - [Configuration control: SCONS\_CONFIG\_DIR and SConfigISCE](#configuration-control) + - [Install ISCE](#install-isce) + - [CMake](#cmake-experimental) - [Setup Your Environment](#setup-your-environment) 3. [Running ISCE](#running-isce) - [Running ISCE from the command line](#running-isce-from-the-command-line) @@ -192,7 +194,9 @@ the older data with the same workflows available in this open source release. ## Building ISCE -### Configuration control +### SCons (recommended) + +#### Configuration control Scons requires that configuration information be present in a directory specified by the environment variable SCONS\_CONFIG\_DIR. First, create a @@ -252,7 +256,7 @@ and the install files. Also, in the following the capitalization of 'isce' as lower case does matter. This is the case-sensitive package name that Python code uses for importing isce. -### Install ISCE +#### Install ISCE cd isce scons install @@ -273,7 +277,7 @@ This will build the necessary components and install them into the location specified in the configuration file as PRJ\_SCONS\_INSTALL. -#### Note about compiling ISCE after an unsuccessful build. +##### Note about compiling ISCE after an unsuccessful build. When building ISCE, scons will check the list of header files and libraries that ISCE requires. Scons will cache the results of this dependency checking. So, @@ -290,6 +294,47 @@ directory containing the SConstruct file): and then try "scons install" again. +### CMake (experimental) +Make sure you have the following prerequisites: +* CMake ≥ 3.12 +* GCC ≥ 4.8 (with C++11 support) +* Python ≥ 3.5 +* Cython +* FFTW 3 +* GDAL + +```sh +git clone https://github.com/isce-framework/isce2 +cd isce2 +mkdir build +cd build +cmake .. -DCMAKE_INSTALL_PREFIX=/my/isce/install/location +make install +``` + +#### Additional cmake configuration options + +CMake uses `CMAKE_PREFIX_PATH` as a global prefix for finding packages, +which can come in handy when using e.g. Anaconda: + +```sh +cmake [...] -DCMAKE_PREFIX_PATH=$CONDA_PREFIX +``` + +On macOS, cmake will also look for systemwide "frameworks", +which is usually not what you want when using Conda or Macports. + +```sh +cmake [...] -DCMAKE_FIND_FRAMEWORK=NEVER +``` + +For packagers, the `PYTHON_MODULE_DIR` can be used to specify ISCE2's +package installation location relative to the installation prefix + +```sh +cmake [...] -DPYTHON_MODULE_DIR=lib/python3.8m/site-packages +``` + ### Setup Your Environment Once everything is installed, you will need to set the following environment diff --git a/components/isceobj/Sensor/CMakeLists.txt b/components/isceobj/Sensor/CMakeLists.txt index 45d14b1..41850f0 100644 --- a/components/isceobj/Sensor/CMakeLists.txt +++ b/components/isceobj/Sensor/CMakeLists.txt @@ -2,7 +2,14 @@ add_subdirectory(db) add_subdirectory(TOPS) add_subdirectory(MultiMode) +add_library(asa_im_decode src/asa_im_decode/asa_im_decode.c) +set_target_properties(asa_im_decode PROPERTIES + PREFIX "" + OUTPUT_NAME envisat + SUFFIX .so) + set(installfiles + asa_im_decode alos __init__.py ALOS.py diff --git a/components/isceobj/Util/CMakeLists.txt b/components/isceobj/Util/CMakeLists.txt index b44a6f0..1975968 100644 --- a/components/isceobj/Util/CMakeLists.txt +++ b/components/isceobj/Util/CMakeLists.txt @@ -81,15 +81,9 @@ add_library(utilLib SHARED target_include_directories(utilLib PUBLIC include ) -target_link_libraries(utilLib PUBLIC +target_link_libraries(utilLib PRIVATE FFTW::Float ) -# TODO (fortran module include) -# This seems to be needed to use this library's modules, -# but is there a more idiomatic way to do this? -target_include_directories(utilLib INTERFACE - ${CMAKE_CURRENT_BINARY_DIR} - ) add_library(combinedLib SHARED Library/geometry/src/geometryModule.F @@ -120,17 +114,24 @@ target_include_directories(combinedlibmodule PUBLIC target_link_libraries(combinedlibmodule PUBLIC combinedLib ) -# TODO (fortran module include) -# This seems to be needed to use this library's modules, -# but is there a more idiomatic way to do this? + +# Set up fortran module paths +set(mdir ${CMAKE_CURRENT_BINARY_DIR}/utillib_fortran_modules) +set_property(TARGET utilLib PROPERTY Fortran_MODULE_DIRECTORY ${mdir}) +target_include_directories(utilLib INTERFACE + $<$:${mdir}> + ) +set(mdir ${CMAKE_CURRENT_BINARY_DIR}/combinelib_fortran_modules) +set_property(TARGET combinedLib PROPERTY Fortran_MODULE_DIRECTORY ${mdir}) target_include_directories(combinedLib INTERFACE - ${CMAKE_CURRENT_BINARY_DIR} + $<$:${mdir}> ) install(TARGETS utilLib combinedLib - LIBRARY DESTINATION lib) + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ) InstallSameDir( combinedlibmodule diff --git a/components/stdproc/stdproc/CMakeLists.txt b/components/stdproc/stdproc/CMakeLists.txt index c40da12..42795b9 100644 --- a/components/stdproc/stdproc/CMakeLists.txt +++ b/components/stdproc/stdproc/CMakeLists.txt @@ -8,15 +8,14 @@ add_library(formslcLib SHARED formslcLib/src/io.c ) set_property(TARGET formslcLib PROPERTY POSITION_INDEPENDENT_CODE ON) -target_include_directories(formslcLib PRIVATE formslcLib/include) target_link_libraries(formslcLib PUBLIC utilLib ) -# TODO (fortran module include) -# This seems to be needed to use this library's modules, -# but is there a more idiomatic way to do this? + +set(mdir ${CMAKE_CURRENT_BINARY_DIR}/formslc_fortran_modules) +set_property(TARGET formslcLib PROPERTY Fortran_MODULE_DIRECTORY ${mdir}) target_include_directories(formslcLib INTERFACE - ${CMAKE_CURRENT_BINARY_DIR} + $<$:${mdir}> ) add_subdirectory(correct) diff --git a/components/zerodop/CMakeLists.txt b/components/zerodop/CMakeLists.txt index f311321..afd838f 100644 --- a/components/zerodop/CMakeLists.txt +++ b/components/zerodop/CMakeLists.txt @@ -3,7 +3,13 @@ add_subdirectory(geozero) add_subdirectory(topozero) if(CMAKE_CUDA_COMPILER) - # add_subdirectory(GPUampcor) TODO cublas_device removed from CUDA ≥ 10 + + # cublas_device removed from CUDA ≥ 10 + if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA" AND + CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 10) + add_subdirectory(GPUampcor) + endif() + add_subdirectory(GPUgeo2rdr) endif() diff --git a/components/zerodop/GPUampcor/CMakeLists.txt b/components/zerodop/GPUampcor/CMakeLists.txt index 302b182..42d6f62 100644 --- a/components/zerodop/GPUampcor/CMakeLists.txt +++ b/components/zerodop/GPUampcor/CMakeLists.txt @@ -1,3 +1,9 @@ +if(NOT TARGET CUDA::cublas) + return() +endif() + +return() # TODO get cublas_device working or remove usage of it + cython_add_module(GPUampcor GPUampcor.pyx cuda/GPUamp.cu @@ -9,6 +15,11 @@ target_include_directories(GPUampcor PUBLIC include ) target_link_libraries(GPUampcor PRIVATE - cublas + CUDA::cublas DataAccessor_static + FFTW::Float + ) +InstallSameDir( + GPUampcor + __init__.py ) diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 4b8ba1e..e1c8031 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -5,7 +5,7 @@ add_subdirectory(frameUtils) #add_subdirectory(unwUtils) add_subdirectory(downsample_unwrapper) -#add_subdirectory(PyCuAmpcor) +add_subdirectory(PyCuAmpcor) add_subdirectory(splitSpectrum) add_subdirectory(alos2filter) add_subdirectory(alos2proc) diff --git a/contrib/PyCuAmpcor/CMakeLists.txt b/contrib/PyCuAmpcor/CMakeLists.txt new file mode 100644 index 0000000..f6414e1 --- /dev/null +++ b/contrib/PyCuAmpcor/CMakeLists.txt @@ -0,0 +1,46 @@ +# Early exit if prereqs not available +if(NOT TARGET GDAL::GDAL +OR NOT TARGET Python::NumPy +OR NOT TARGET CUDA::cublas +OR NOT TARGET CUDA::cufft + ) + return() +endif() + +set(CMAKE_CUDA_STANDARD 11) +set(CMAKE_CUDA_STANDARD_REQUIRED TRUE) + +cython_add_module(PyCuAmpcor + src/PyCuAmpcor.pyx + src/GDALImage.cu + src/SConscript + src/SlcImage.cu + src/cuAmpcorChunk.cu + src/cuAmpcorController.cu + src/cuAmpcorParameter.cu + src/cuArrays.cu + src/cuArraysCopy.cu + src/cuArraysPadding.cu + src/cuCorrFrequency.cu + src/cuCorrNormalization.cu + src/cuCorrTimeDomain.cu + src/cuDeramp.cu + src/cuEstimateStats.cu + src/cuOffset.cu + src/cuOverSampler.cu + src/cuSincOverSampler.cu + ) +target_include_directories(PyCuAmpcor PRIVATE + src + ) +target_link_libraries(PyCuAmpcor PRIVATE + CUDA::cufft + CUDA::cublas + GDAL::GDAL + Python::NumPy + ) + +InstallSameDir( + __init__.py + PyCuAmpcor + ) diff --git a/contrib/demUtils/CMakeLists.txt b/contrib/demUtils/CMakeLists.txt index bc1ea64..de5e950 100644 --- a/contrib/demUtils/CMakeLists.txt +++ b/contrib/demUtils/CMakeLists.txt @@ -17,8 +17,31 @@ Python_add_library(demStitch MODULE demstitcher/bindings/demStitch.c ) +Python_add_library(upsampledem MODULE + upsampledem/bindings/upsampledemmodule.cpp + upsampledem/src/upsampledem.f + upsampledem/src/upsampledemSetState.f + upsampledem/src/upsampledemState.f + ) +target_include_directories(upsampledem PRIVATE + upsampledem/include + ) +target_link_libraries(upsampledem PRIVATE + utilLib + ) + +Python_add_library(watermask MODULE + watermask/bindings/watermaskmodule.cpp + watermask/src/watermask.cpp + ) +target_include_directories(watermask PRIVATE + watermask/include + ) + InstallSameDir( demStitch + upsampledem + watermask correct_geoid_i2_srtm __init__.py correct_geoid_i2_srtm/Correct_geoid_i2_srtm.py @@ -27,6 +50,5 @@ InstallSameDir( demstitcher/DemStitcherV3.py swbdstitcher/SWBDStitcher.py upsampledem/UpsampleDem.py - watermask/test/mask.py watermask/WaterMask.py ) diff --git a/contrib/issi/components/ISSI/CMakeLists.txt b/contrib/issi/components/ISSI/CMakeLists.txt index 10f2fa1..98d429c 100644 --- a/contrib/issi/components/ISSI/CMakeLists.txt +++ b/contrib/issi/components/ISSI/CMakeLists.txt @@ -8,12 +8,19 @@ add_library(issi SHARED src/polcal.c src/tecToPhase.c ) +set_target_properties(issi PROPERTIES + PREFIX "" + OUTPUT_NAME issi + SUFFIX .so) target_include_directories(issi PUBLIC include) -add_subdirectory(src) - InstallSameDir( issi __init__.py FR.py ) + +file(RELATIVE_PATH relpath ${isce2_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}) +install(DIRECTORY src/igrf_data + DESTINATION ${ISCE2_PKG}/${relpath} + ) diff --git a/contrib/issi/components/ISSI/src/CMakeLists.txt b/contrib/issi/components/ISSI/src/CMakeLists.txt deleted file mode 100644 index 61f2d84..0000000 --- a/contrib/issi/components/ISSI/src/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(igrf_data) diff --git a/contrib/issi/components/ISSI/src/igrf_data/CMakeLists.txt b/contrib/issi/components/ISSI/src/igrf_data/CMakeLists.txt deleted file mode 100644 index 714613b..0000000 --- a/contrib/issi/components/ISSI/src/igrf_data/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -InstallSameDir( - dgrf00.dat - dgrf45.dat - dgrf50.dat - dgrf55.dat - dgrf60.dat - dgrf65.dat - dgrf70.dat - dgrf75.dat - dgrf80.dat - dgrf85.dat - dgrf90.dat - dgrf95.dat - igrf05.dat - igrf05full.dat - igrf05s.dat - igrf10.dat - ) diff --git a/library/isceLib/CMakeLists.txt b/library/isceLib/CMakeLists.txt index 2e735a4..2bae12f 100644 --- a/library/isceLib/CMakeLists.txt +++ b/library/isceLib/CMakeLists.txt @@ -1,4 +1,5 @@ -Python_add_library(isceLib MODULE +cython_add_module(isceLib + pyx/isceLib.pyx src/Ellipsoid.cpp src/LinAlg.cpp src/Orbit.cpp