Skip to content

Commit

Permalink
rev: adapt build system: new opt/qt lib, VTK 9.2+, Qt 5.15
Browse files Browse the repository at this point in the history
CMakeLists.txt
LUMASSConfig.h.in
bmi/CMakeLists.txt
cmake/Modules/FindLUMASSNetCDF.cmake
cmake/Modules/FindLUMASSOTB.cmake
cmake/Modules/FindLUMASSSpatialite.cmake
cmake/Modules/FindLUMASSVTK.cmake
gui/CMakeLists.txt
modellingframework/wrapper/CMakeLists.txt
optimisation/CMakeLists.txt
otbsuppl/filters/CMakeLists.txt
terminalapp/CMakeLists.txt
utils/CMakeLists.txt
utils/NMQt/drivers/sqlite/nmqsql_sqlite.cpp
utils/NMQt/CMakeLists.txt
utils/NMQt/NMSqlTableModel.cpp
utils/NMQt/NMSqlTableModel.h
  • Loading branch information
heralex committed Feb 12, 2024
1 parent f0e3595 commit f8c9799
Show file tree
Hide file tree
Showing 17 changed files with 527 additions and 140 deletions.
89 changes: 53 additions & 36 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
# author: Alexander Herzig
# copyright: Landcare Research New Zealand Ltd

cmake_minimum_required(VERSION 3.14)
cmake_minimum_required(VERSION 3.22)

# CMAKE
#SET(CMAKE_C_COMPILER "/usr/bin/clang-15")
#SET(CMAKE_CXX_COMPILER "/usr/bin/clang++-15")

PROJECT(lumass)

INCLUDE_REGULAR_EXPRESSION("^.*$")
Expand Down Expand Up @@ -30,7 +35,6 @@ SET(LIBRARY_OUTPUT_PATH ${lumass_BINARY_DIR}/lib)
# we're setting some more variables
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
SET(CMAKE_CXX_STANDARD 14)
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

#====================================================================
# MPI
Expand Down Expand Up @@ -156,24 +160,27 @@ endif (testvar_in STREQUAL testvar_target)
find_package(Git)
SET(LUMASS_VERSION_MAJOR 0)
SET(LUMASS_VERSION_MINOR 9)
SET(LUMASS_VERSION_REVISION 70)
SET(LUMASS_VERSION_SUFFIX "-b5")
SET(LUMASS_VERSION_REVISION 71)
SET(LUMASS_VERSION_SUFFIX "-b8")
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
git_date(LUMASS_COMMIT_DATE)


message(STATUS "building LUMASS ${LUMASS_VERSION_MAJOR}.${LUMASS_VERSION_MINOR}.${LUMASS_VERSION_REVISION} (${CMAKE_BUILD_TYPE})"
" - commit ${GIT_SHA1} from ${LUMASS_COMMIT_DATE}")


SET(LUMASS_OPENGA_VERSION "1.0.5")

#====================================================================
# avoid 'missing Threads_FOUND' trouble ...
#====================================================================

set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_WIN32_THREADS_INIT 0)
set(CMAKE_USE_PTHREADS_INIT 1)
set(THREADS_PREFER_PTHREAD_FLAG ON)
#set(CMAKE_THREAD_LIBS_INIT "-lpthread")
#set(CMAKE_HAVE_THREADS_LIBRARY 1)
#set(CMAKE_USE_WIN32_THREADS_INIT 0)
#set(CMAKE_USE_PTHREADS_INIT 1)
#set(THREADS_PREFER_PTHREAD_FLAG ON)

#====================================================================
# QT 5
Expand All @@ -187,7 +194,6 @@ ENDIF()
# message(FATAL_ERROR "LUMASS >= 0.9.60 requires Qt >= 5.7")
#endif ()


#====================================================================
# OpenGL
#====================================================================
Expand Down Expand Up @@ -267,13 +273,14 @@ message(STATUS "OTB_LINK_DIR: ${OTB_LINK_DIR}")
# available; set up specifics later with respect to the
# different executables

#FIND_PACKAGE(LUMASSVTK)
FIND_PACKAGE(LUMASSVTK)

if(NOT LUMASS_VTK_DIR)
if(NOT VTK_DIR)
set(LUMASS_VTK_DIR "LUMASS_VTK_DIR NOT FOUND" CACHE STRING "VTK directory (to vtk-config.cmake)")
message(FATAL_ERROR "Couldn't find VTK!")
else()
message(STATUS "LUMASS_VTK_DIR set to '${LUMASS_VTK_DIR}'")
set(LUMASS_VTK_DIR ${VTK_DIR} CACHE STRING "VTK directory (to vtk-config.cmake)")
message(STATUS "LUMASS_VTK_DIR set to ${LUMASS_VTK_DIR}")
find_package(VTK REQUIRED PATHS ${LUMASS_VTK_DIR} NO_DEFAULT_PATH)
#include("${LUMASS_VTK_DIR}/vtk-config.cmake"})

Expand Down Expand Up @@ -337,7 +344,7 @@ message(STATUS "lp_solve library: ${LPSOLVE_LIBRARY}")
#====================================================================

# just define the current version included in the source tree
set(NM_SQLite_VERSION "3.31.1")
set(NM_SQLite_VERSION "3.42.0")

#find_package(Sqlite3)
#if(NOT SQLITE3_FOUND)
Expand All @@ -353,6 +360,7 @@ if(NOT SPATIALITE_FOUND)
message(FATAL_ERROR "Please install Spatialite prior to installing LUMASS!")
endif()

message(STATUS "Spatialite version: ${SPATIALITE_VERSION}")
message(STATUS "Spatialite include dir: ${SPATIALITE_INCLUDE_DIR}")
message(STATUS "Spatialite library dir: ${SPATIALITE_LIBLIB_DIR}")
message(STATUS "Spatialite library: ${SPATIALITE_LIB}")
Expand Down Expand Up @@ -388,18 +396,26 @@ if (WIN32)
SET(LUMASS_NCXX4_VERSION "4.3.1")

else()

find_package(LUMASSNetCDF)

if(NOT NC_CONFIG_PATH)
set(NC_CONFIG_PATH "" CACHE STRING "Please specify the path to the netcdf nc-config file." )
message(FATAL_ERROR "Couldn't find netcdf configuration info!")
else()
set(NC_CONFIG_PATH ${NC_CONFIG_PATH} CACHE STRING "Path to the netcdf nc-config file." )
endif()

if (NOT NCXX4_CONFIG_PATH)
set(NCXX4_CONFIG_PATH "" CACHE STRING "Please specify the path to the netcdf-cxx4 ncxx4-config file.")

if(NOT NC_CONFIG_PATH OR NOT NCXX4_CONFIG_PATH)
message(FATAL_ERROR "Please specify the path to the nc-config (NC_CONFIG_PATH) and ncxx4-config (NCXX4_CONFIG_PATH) files.")
endif()
else()
set(NCXX4_CONFIG_PATH ${NCXX4_CONFIG_PATH} CACHE STRING "Path to the ncxx4-config file.")
endif()

find_package(LUMASSNetCDF)
SET(LUMASS_NETCDF_VERSION ${NETCDF_VERSION})
SET(LUMASS_NCXX4_VERSION ${NCXX4_VERSTION})
SET(LUMASS_NETCDF_VERSION ${NETCDF_VERSION})
SET(LUMASS_NCXX4_VERSION ${NCXX4_VERSION})

find_package(HDF5 COMPONENTS C HL REQUIRED)
find_package(HDF5 COMPONENTS C HL REQUIRED)

endif()

Expand Down Expand Up @@ -490,20 +506,19 @@ endif(PYTHONSUPPORT)
#====================================================================
# ask for YAML library and header dir
#====================================================================

find_package(yaml-cpp
HINTS
/usr/lib/x86_64-linux-gnu/cmake/yaml-cpp/yaml-cpp-config.cmake
c:/opt/yaml-cpp/yaml-cpp-config.cmake
PATHS
/usr/lib/x86_64-linux-gnu/cmake
/usr/lib/cmake
find_package(yaml-cpp
HINTS
/usr/lib/x86_64-linux-gnu/cmake/yaml-cpp/yaml-cpp-cdonfig.cmake
c:/opt/yaml-cpp/yaml-cpp-config.cmake
PATHS
/usr/lib/x86_64-linux-gnu/cmake
/usr/lib/cmake
c:/opt/yaml-cpp
)
)

if (NOT YAML_CPP_CMAKE_DIR)
set(YAML_CPP_CMAKE_DIR "YAML_CPP_CMAKE_DIR-NOTFOUND" CACHE STRING "Please specify the path of yaml-cpp-config.cmake" )
message(FATAL_ERROR "Please specify the path of yaml-cpp-config.cmake!" )
set(YAML_CPP_CMAKE_DIR "YAML_CPP_CMAKE_DIR-NOTFOUND" CACHE STRING "Please specify the path of yaml-cpp-config.cmake" )
message(FATAL_ERROR "Please specify the path of yaml-cpp-config.cmake!" )
else()
include(${YAML_CPP_CMAKE_DIR}/yaml-cpp-config-version.cmake)
SET(LUMASS_yaml_version "${PACKAGE_VERSION}")
Expand Down Expand Up @@ -532,6 +547,7 @@ ENDIF()
#endif()
#find_package(yaml-cpp)
#include(/opt/yaml-debug/install/share/cmake/yaml-cpp/yaml-cpp-config.cmake)
message(STATUS "YAML_CPP_VERSION=${LUMASS_yaml_version}")
message(STATUS "YAML_CPP_INCLUDE_DIR=${YAML_CPP_INCLUDE_DIR}")
message(STATUS "YAML_CPP_LIBRARIES=${YAML_CPP_LIBRARIES}")

Expand Down Expand Up @@ -617,11 +633,12 @@ SET(MFW_WRAPPER_NAMES
NMJSKernelFilterWrapper
NMExternalExecWrapper
NMSQLiteProcessorWrapper
NMUniqueCombinationFilterWrapper
#NMUniqueCombinationFilterWrapper
NMStreamingROIImageFilterWrapper
NMImage2DToCubeSliceFilterWrapper
NMCubeSliceToImage2DFilterWrapper
NMImage2TableFilterWrapper
NMTable2NetCDFFilterWrapper
)

SET(OTB_LINK_LIBS
Expand All @@ -643,8 +660,9 @@ SET(OTB_LINK_LIBS
ADD_SUBDIRECTORY(shared ${lumass_BINARY_DIR}/shared)
ADD_SUBDIRECTORY(utils ${lumass_BINARY_DIR}/utils)
ADD_SUBDIRECTORY(otbsuppl ${lumass_BINARY_DIR}/otbsuppl)
ADD_SUBDIRECTORY(modellingframework/core ${lumass_BINARY_DIR}/modellingframework/core)
ADD_SUBDIRECTORY(optimisation ${lumass_BINARY_DIR}/optimisation)
ADD_SUBDIRECTORY(modellingframework ${lumass_BINARY_DIR}/modellingframework)
ADD_SUBDIRECTORY(modellingframework/wrapper ${lumass_BINARY_DIR}/modellingframework/wrapper)
ADD_SUBDIRECTORY(gui ${lumass_BINARY_DIR}/gui)
ADD_SUBDIRECTORY(terminalapp ${lumass_BINARY_DIR}/terminalapp)
ADD_SUBDIRECTORY(bmi ${lumass_BINARY_DIR}/bmi)
Expand All @@ -656,7 +674,6 @@ ADD_SUBDIRECTORY(bmi ${lumass_BINARY_DIR}/bmi)

IF (UNIX AND NOT APPLE)

#set(CPACK_PACKAGE_NAME "lumass")
set(CPACK_PACKAGE_NAME "lumass")
set(CPACK_PACKAGE_VERSION "${LUMASS_VERSION_MAJOR}.${LUMASS_VERSION_MINOR}.${LUMASS_VERSION_REVISION}-0ubuntu1")
set(CPACK_PACKAGE_VENDOR "Manaaki Whenua - Landcare Research")
Expand Down
14 changes: 9 additions & 5 deletions LUMASSConfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@
#define LUMASS_BUILD_TYPE "@CMAKE_BUILD_TYPE@"

// underpinning libraries
#define LUMASS_QT_VERSION "@QT5_VERSION_STRING@"
#define LUMASS_OTB_VERSION "@LUMASS_OTB_VERSION@"
#define LUMASS_ITK_VERSION "@LUMASS_ITK_VERSION@"
#define LUMASS_GDAL_VERSION "@GDAL_VERSION@"
#define LUMASS_VTK_VERSION "@VTK_VERSION_STRING@"
#define LUMASS_SQLITE_VERSION "@NM_SQLite_VERSION@"
#define LUMASS_ITK_VERSION "@LUMASS_ITK_VERSION@"
#define LUMASS_NETCDF_VERSION "@LUMASS_NETCDF_VERSION@"
#define LUMASS_NCXX4_VERSION "@LUMASS_NCXX4_VERSION@"
#define LUMASS_OTB_VERSION "@LUMASS_OTB_VERSION@"
#define LUMASS_PYBIND11_VERSION "@LUMASS_pybind11_version@"
#define LUMASS_QT_VERSION "@QT5_VERSION_STRING@"
#define LUMASS_SPATIALITE_VERSION "@SPATIALITE_VERSION@"
#define LUMASS_SQLITE_VERSION "@NM_SQLite_VERSION@"
#define LUMASS_VTK_VERSION "@VTK_VERSION_STRING@"
#define LUMASS_YAML_VERSION "@LUMASS_yaml_version@"
#define LUMASS_OPENGA_VERSION "@LUMASS_OPENGA_VERSION@"


const char _lumass_commit_hash[] = LUMASS_COMMIT_HASH;
Expand All @@ -54,7 +56,9 @@
const char _lumass_gdal_version[] = LUMASS_GDAL_VERSION;
const char _lumass_vtk_version[] = LUMASS_VTK_VERSION;
const char _lumass_sqlite_version[] = LUMASS_SQLITE_VERSION;
const char _lumass_spatialite_version[] = LUMASS_SPATIALITE_VERSION;
const char _lumass_netcdf_version[] = LUMASS_NETCDF_VERSION;
const char _lumass_ncxx4_version[] = LUMASS_NCXX4_VERSION;
const char _lumass_pybind11_version[] = LUMASS_PYBIND11_VERSION;
const char _lumass_yaml_version[] = LUMASS_YAML_VERSION;
const char _lumass_openGA_version[] = LUMASS_OPENGA_VERSION;
8 changes: 5 additions & 3 deletions bmi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ LINK_DIRECTORIES(
${QT5_LINK_DIRS}
${OTB_LIBRARY_DIRS}
${LIBRARY_OUTPUT_PATH}
${opt_BINARY_DIR}
${bmi_BINARY_DIR}
#${muparser_BINARY_DIR}
${RASDAMAN_LIBRARIES_DIR}
Expand All @@ -92,7 +93,7 @@ file(GLOB BMI_HEADER
)

file(GLOB BMI_SRC
${opt_SOURCE_DIR}/*.cpp
#${opt_SOURCE_DIR}/*.cpp
${bmi_SOURCE_DIR}/lumassbmi.cpp
${bmi_SOURCE_DIR}/NMLumassEngine.cpp
${NMVtk_SOURCE_DIR}/NMvtkDelimitedTextWriter.cxx
Expand All @@ -116,6 +117,7 @@ SET(BMI_LINKLIBS
curl xml2
${MPI_CXX_LIBRARIES}
${HDF5_hdf5_LIBRARY_RELEASE} ${HDF5_hdf5_hl_LIBRARY_RELEASE}
NMMosra
NMModFrameCore
${MFW_WRAPPER_NAMES}
${LUMASS_BMI_VTK_LIBRARIES}
Expand Down Expand Up @@ -192,9 +194,9 @@ SET(LUMASS_INSTALL_DIR ${CMAKE_INSTALL_PREFIX})

# -------------------------------------------
# INSTALL LIBRARY
SET(BMI_INSTALL_TARGETS LumassPythonBMI)
SET(BMI_INSTALL_TARGETS LumassBMI)
if (PYTHONSUPPORT)
list(APPEND LumassPythonBMI)
list(APPEND BMI_INSTALL_TARGETS LumassPythonBMI)
endif()

#install(FILES ${BMI_HEADER} DESTINATION include)
Expand Down
69 changes: 36 additions & 33 deletions cmake/Modules/FindLUMASSNetCDF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,29 @@
# - no warranty whatsoever for this being even remotely useful in whichever shape or form!

# find parallel netcdf nc-config
# find_path(NC_CONFIG_PATH NAMES nc-config
# HINTS
# /opt/netcdf-4.7.3/install/bin
# /opt/netcdf-4.8.1/install/bin
# /opt/netcdf-c-4.8.1/install/bin
# /opt/netcdf-bin/install/bin
# PATHS
# /opt/netcdf-4.7.3
# /opt/netcdf-bin
# /opt/netcdf-4.8.1
# /opt/netcdf-c-4.8.1
# /usr/local
# /usr
# PATH_SUFFIXES
# install/bin
# bin
# DOC "Path to the netcdf-cxx4 config script 'ncxx4-config'"
# )
find_path(NC_CONFIG_PATH NAMES nc-config
HINTS
$ENV{HOME}/garage/build/netcdf-c-4.9.2/install/bin
/opt/netcdf-4.7.3/install/bin
/opt/netcdf-4.8.1/install/bin
/opt/netcdf-c-4.8.1/install/bin
/opt/netcdf-bin/install/bin
PATHS
$ENV{HOME}/garage/build/netcdf-c-4.9.2
/opt/netcdf-4.7.3
/opt/netcdf-bin
/opt/netcdf-4.8.1
/opt/netcdf-c-4.8.1
/usr/local
/usr
PATH_SUFFIXES
install/bin
bin
DOC "Path to the netcdf-c config script 'nc-config'"
)

#set(NC_CONFIG_PATH ${NC_CONFIG_PATH} CACHE STRING "Please specify the path to the netcdf nc-config file." )


execute_process(COMMAND ${NC_CONFIG_PATH}/nc-config --version OUTPUT_VARIABLE NETCDF_VERSION_TEXT OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${NC_CONFIG_PATH}/nc-config --includedir OUTPUT_VARIABLE NETCDF_INCLUDE_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${NC_CONFIG_PATH}/nc-config --libdir OUTPUT_VARIABLE NETCDF_LIB_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
Expand Down Expand Up @@ -55,20 +56,22 @@ endif()
#message(STATUS "NetCDF library: ${NETCDF_LIBRARY}")

# find also netcdf-cxx4
#find_path(NCXX4_CONFIG_PATH ncxx4-config
# HINTS
# /opt/ncxx4-dbg/install/bin
# /opt/netcdf-cxx4/install/bin
# PATHS
# /opt/ncxx4-dbg
# /opt/netcdf-cxx4
# /usr/local
# /usr
# PATH_SUFFIXES
# bin
# install/bin
# DOC "Path to the netcdf-cxx4 config script 'ncxx4-config'"
#)
find_path(NCXX4_CONFIG_PATH ncxx4-config
HINTS
$ENV{HOME}/garage/build/netcdf-cxx-4.3.1/install/bin
/opt/ncxx4-dbg/install/bin
/opt/netcdf-cxx4/install/bin
PATHS
$ENV{HOME}/garage/build/netcdf-cxx-4.3.1
/opt/ncxx4-dbg
/opt/netcdf-cxx4
/usr/local
/usr
PATH_SUFFIXES
bin
install/bin
DOC "Path to the netcdf-cxx4 config script 'ncxx4-config'"
)

#message(STATUS "NCXX4_CONFIG_PATH: ${NCXX4_CONFIG_PATH}")

Expand Down
1 change: 1 addition & 0 deletions cmake/Modules/FindLUMASSOTB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ IF(NOT OTB_DIR)
/opt/OTB-8.1-bin/install/lib/cmake
/usr/lib/cmake
/usr/lib/x86_64-linux-gnu
/home/users/herziga/garage/build/OTB-8.1.2/install/lib/cmake
C:/build/OTB-debug
C:/opt/OTB-debug
C:/build/OTB-reldebinfo
Expand Down
Loading

0 comments on commit f8c9799

Please sign in to comment.