Changeset: c8662d5e2493 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c8662d5e2493 Added Files: ctest/cmake/detect-netcdf.cmake ctest/cmake/test_detect_netcdf.c.in Modified Files: CMakeLists.txt README.md cmake/Modules/FindNetCDF.cmake cmake/monetdb-findpackages.cmake cmake/monetdb-functions.cmake cmake/os_release_info.cmake ctest/cmake/CMakeLists.txt sql/backends/monet5/vaults/netcdf/CMakeLists.txt Branch: mbedded Log Message:
cleanup cmake code and add test diffs (245 lines): diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -184,6 +184,7 @@ set(HAVE_PROJ ${PROJ_FOUND}) set(HAVE_SNAPPY ${SNAPPY_FOUND}) set(HAVE_UUID ${HAVE_UUID_GENERATE}) set(HAVE_VALGRIND ${VALGRIND_FOUND}) +set(HAVE_NETCDF ${NETCDF_FOUND}) set(SOCKET_LIBRARIES "") if (WIN32) diff --git a/README.md b/README.md --- a/README.md +++ b/README.md @@ -19,15 +19,16 @@ PATH settings: None ROle of clients?? How to install ## Testing -For testing, you likely don't want to install in the default location, so you need to add the installation prefix parameter to the cmake command. - -But you do not need any configuration to run mtest (on Linux). Just run the command: +For testing, you likely don't want to install in the default location, so you need to add the installation prefix parameter to the cmake command. But you do not need any configuration to run mtest (on Linux). Just run the command: ``` cmake --build . --target mtest ``` ## Configuration options + +The way options interact with building of the MonetDB source has fundamentally changed from the way this was done using the autotools buildsystem. Now almost all options are on by default. And these options mostly control library detection. In the old system, it was possible to build a subset of the codebase. For example, you could choose not to build the sql part. Now the every part of the code is build, as long as the dependent libraries are detected. And by default, the system would try to detect all dependent libraries. If your system does not have a required library, that section of the code will not be build. Only if you want to prevent the build of a certain section, you could use the option to prevent that a dependency is detected. + Evidently there are several options to control as illustrated in $SOURCE/cmake/monetdb-options.cmake The important once to choose from are -DCMAKE\_BUILD\_TYPE, which takes the value Release or Debug. @@ -38,7 +39,6 @@ are being checked. Other relevant properties are also -DASSERT=ON and DSTRICT=ON, used in combination with a Debug build, e.g. - ``` CONFIGURE_OPTIONS="-DCMAKE_BUILD_TYPE=Debug -DASSERT=ON -DSTRICT=ON" mkdir build @@ -48,7 +48,6 @@ cmake --build . cmake --build . --target install ``` - Explain the role of cmake --build . --target mtest In particular how to call it from anywhere in the tree diff --git a/cmake/Modules/FindNetCDF.cmake b/cmake/Modules/FindNetCDF.cmake --- a/cmake/Modules/FindNetCDF.cmake +++ b/cmake/Modules/FindNetCDF.cmake @@ -12,7 +12,8 @@ find_path(NETCDF_INCLUDE_DIR NAMES netcd # Look for the library. find_library(NETCDF_LIBRARIES NAMES netcdf) -# Handle the QUIETLY and REQUIRED arguments and set NETCDF_FOUND to TRUE if all listed variables are TRUE. +# Handle the QUIETLY and REQUIRED arguments and set NETCDF_FOUND +# to TRUE if all listed variables are TRUE. include(FindPackageHandleStandardArgs) find_package_handle_standard_args(NetCDF DEFAULT_MSG NETCDF_LIBRARIES NETCDF_INCLUDE_DIR) @@ -28,6 +29,14 @@ endif() mark_as_advanced(NETCDF_INCLUDE_DIR NETCDF_LIBRARIES NETCDF_VERSION) if(NETCDF_FOUND) + set(NETCDF_MINIMUM_VERSION "4.2") + if(NETCDF_VERSION VERSION_LESS "${NETCDF_MINIMUM_VERSION}") + message(STATUS "netcdf library found, but the version is too old: ${NETCDF_VERSION} < ${NETCDF_MINIMUM_VERSION}") + set(NETCDF_FOUND FALSE) + endif() + endif() + +if(NETCDF_FOUND) add_library(NetCDF::NetCDF UNKNOWN IMPORTED) set_target_properties(NetCDF::NetCDF PROPERTIES @@ -37,4 +46,3 @@ if(NETCDF_FOUND) IMPORTED_LINK_INTERFACE_LANGUAGES "C" IMPORTED_LOCATION "${NETCDF_LIBRARIES}") endif() - diff --git a/cmake/monetdb-findpackages.cmake b/cmake/monetdb-findpackages.cmake --- a/cmake/monetdb-findpackages.cmake +++ b/cmake/monetdb-findpackages.cmake @@ -111,20 +111,6 @@ endif() if(NETCDF) find_package(NetCDF) - if(NETCDF_FOUND) - set(NETCDF_MINIMUM_VERSION "4.2") - if(NETCDF_VERSION VERSION_LESS "${NETCDF_MINIMUM_VERSION}") - if(${WITH_NETCDF} STREQUAL "YES") - message(FATAL_ERROR "netcdf library found, but the version is too old: ${NETCDF_VERSION} < ${NETCDF_MINIMUM_VERSION}") - else() - message(STATUS "netcdf library found, but the version is too old: ${NETCDF_VERSION} < ${NETCDF_MINIMUM_VERSION}") - endif() - else() - set(HAVE_NETCDF "${NETCDF_FOUND}") - endif() - #else() - #message(FATAL_ERROR "netcdf library required for NetCDF support") - endif() endif() find_package(KVM) diff --git a/cmake/monetdb-functions.cmake b/cmake/monetdb-functions.cmake --- a/cmake/monetdb-functions.cmake +++ b/cmake/monetdb-functions.cmake @@ -130,5 +130,6 @@ function(monetdb_cmake_summary) message(STATUS "Cfitsio library: ${CFITSIO_FOUND}") message(STATUS "Kvm library: ${KVM_FOUND}") message(STATUS "Pcre library: ${PCRE_FOUND}") + message(STATUS "Netcdf library: ${NETCDF_FOUND}") message("-----------------------------------------") endfunction() diff --git a/cmake/os_release_info.cmake b/cmake/os_release_info.cmake --- a/cmake/os_release_info.cmake +++ b/cmake/os_release_info.cmake @@ -155,11 +155,11 @@ function(get_os_release_info _vn_id _vn_ string(REGEX REPLACE "^\"(.*)\"$" "\\1" _var_id "${_var_id}") string(REGEX REPLACE "^\"(.*)\"$" "\\1" _var_version_id "${_var_version_id}") - if(NOT "${_vn_id}" STREQUAL "") + if(NOT ${_vn_id} STREQUAL "") set(${_vn_id} "${_var_id}" PARENT_SCOPE) endif() - if(NOT "${_vn_version_id}" STREQUAL "") + if(NOT ${_vn_version_id} STREQUAL "") set(${_vn_version_id} "${_var_version_id}" PARENT_SCOPE) endif() diff --git a/ctest/cmake/CMakeLists.txt b/ctest/cmake/CMakeLists.txt --- a/ctest/cmake/CMakeLists.txt +++ b/ctest/cmake/CMakeLists.txt @@ -111,3 +111,4 @@ target_link_libraries(test_detect_proj monetdb_config_header) add_test(testDetectProj test_detect_proj) +include(${CMAKE_CURRENT_SOURCE_DIR}/detect-netcdf.cmake) diff --git a/ctest/cmake/detect-netcdf.cmake b/ctest/cmake/detect-netcdf.cmake new file mode 100644 --- /dev/null +++ b/ctest/cmake/detect-netcdf.cmake @@ -0,0 +1,62 @@ +include(os_release_info) + +if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + get_os_release_info(LINUX_DISTRO LINUX_DISTRO_VERSION) +endif() + +if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + get_os_release_info(LINUX_DISTRO LINUX_DISTRO_VERSION) +endif() + +if (${LINUX_DISTRO} STREQUAL "debian") + if(${LINUX_DISTRO_VERSION} STREQUAL "9") + set(DETECT "1") + set(UNDETECT "0") + endif() + if(${LINUX_DISTRO_VERSION} STREQUAL "10") + set(DETECT "1") + set(UNDETECT "0") + endif() +elseif (${LINUX_DISTRO} STREQUAL "ubuntu") + if(${LINUX_DISTRO_VERSION} STREQUAL "18") + set(DETECT "1") + set(UNDETECT "0") + endif() + if(${LINUX_DISTRO_VERSION} STREQUAL "19") + set(DETECT "1") + set(UNDETECT "0") + endif() + if(${LINUX_DISTRO_VERSION} STREQUAL "20") + set(DETECT "1") + set(UNDETECT "0") + endif() +elseif(${LINUX_DISTRO} STREQUAL "fedora") + if(${LINUX_DISTRO_VERSION} STREQUAL "30") + set(DETECT "0") + set(UNDETECT "1") + endif() + if(${LINUX_DISTRO_VERSION} STREQUAL "31") + set(DETECT "0") + set(UNDETECT "1") + endif() + if(${LINUX_DISTRO_VERSION} STREQUAL "32") + set(DETECT "0") + set(UNDETECT "1") + endif() +else() + message(ERROR "Linux distro: ${LINUX_DISTRO} not known") + message(ERROR "Linux distro version: ${LINUX_DISTRO_VERSION} not known") +endif() + +configure_file(test_detect_netcdf.c.in + ${CMAKE_CURRENT_BINARY_DIR}/test_detect_netcdf.c + @ONLY) + +add_executable(test_detect_netcdf) +target_sources(test_detect_netcdf + PRIVATE + ${CMAKE_CURRENT_BINARY_DIR}/test_detect_netcdf.c) +target_link_libraries(test_detect_netcdf + PRIVATE + monetdb_config_header) +add_test(testDetectNetcdf test_detect_netcdf) diff --git a/ctest/cmake/test_detect_netcdf.c.in b/ctest/cmake/test_detect_netcdf.c.in new file mode 100644 --- /dev/null +++ b/ctest/cmake/test_detect_netcdf.c.in @@ -0,0 +1,19 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. + */ + +#include "monetdb_config.h" + +int +main(void) +{ +#ifdef HAVE_NETCDF + return @DETECT@; +#else + return @UNDETECT@; +#endif +} diff --git a/sql/backends/monet5/vaults/netcdf/CMakeLists.txt b/sql/backends/monet5/vaults/netcdf/CMakeLists.txt --- a/sql/backends/monet5/vaults/netcdf/CMakeLists.txt +++ b/sql/backends/monet5/vaults/netcdf/CMakeLists.txt @@ -6,7 +6,7 @@ # Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. #]] -if(HAVE_NETCDF) +if(NETCDF_FOUND) # the netcdf library is also called netcdf, so cmake gets confused. # Give it another name add_library(netcdff MODULE) _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list