Skip to content
Snippets Groups Projects
Unverified Commit e2e37f3a authored by Dmitri Naumov's avatar Dmitri Naumov Committed by GitHub
Browse files

Merge pull request #2827 from bilke/filesystem

Bump compiler and use std::filesystem
parents 2bc0235f 8a8b347c
No related branches found
No related tags found
No related merge requests found
Showing
with 87 additions and 83 deletions
......@@ -17,7 +17,7 @@ target_link_libraries(ApplicationsLib
foreach(process ${ProcessesList})
if(OGS_BUILD_PROCESS_${process})
string(TOUPPER "OGS_BUILD_PROCESS_${process}" EnableProcess)
set_property(SOURCE ProjectData.cpp
set_property(TARGET ApplicationsLib
APPEND
PROPERTY COMPILE_DEFINITIONS ${EnableProcess})
endif()
......
set(BUILD_SHARED_LIBS_SAVED "${BUILD_SHARED_LIBS}")
# Always built Data Explorer statically as there are cyclic dependencies between
# QtDataView and VtkVis
set(BUILD_SHARED_LIBS OFF)
if(MSVC)
add_definitions(-DVTKGUISUPPORTQT_STATIC_DEFINE)
endif()
......@@ -24,5 +19,3 @@ add_subdirectory(DataView)
add_subdirectory(DataView/DiagramView)
add_subdirectory(VtkVis)
include(DataExplorer.cmake)
set(BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS_SAVED}")
......@@ -53,12 +53,6 @@ target_link_libraries(DataExplorer
${VTK_LIBRARIES}
)
if(OGS_USE_NETCDF)
add_subdirectory(NetCdfDialog)
target_link_libraries(DataExplorer NetCdfDialogLib)
endif()
if(NOT APPLE AND OGS_USE_CONAN)
if(UNIX)
target_link_libraries(DataExplorer Qt5::X11Extras)
......
......@@ -121,7 +121,7 @@ if(GEOTIFF_FOUND)
include_directories(${GEOTIFF_INCLUDE_DIRS})
endif() # GEOTIFF_FOUND
ogs_add_library(QtDataView ${SOURCES} ${HEADERS} ${UIS})
ogs_add_library(QtDataView STATIC ${SOURCES} ${HEADERS} ${UIS})
target_link_libraries(QtDataView
PUBLIC GeoLib
......
ogs_add_library(NetCdfDialogLib NetCdfConfigureDialog.cpp NetCdfConfigureDialog.h)
target_link_libraries(NetCdfDialogLib
PUBLIC Qt5::Widgets
${NETCDF_LIBRARIES_CXX}
${NETCDF_LIBRARIES_C}
${HDF5_HL_LIBRARIES}
${HDF5_LIBRARIES}
PRIVATE MathLib)
if(OGS_USE_CONAN AND MSVC)
target_link_libraries(NetCdfDialogLib PUBLIC ${CONAN_LIBS})
endif()
set_property(TARGET NetCdfDialogLib PROPERTY FOLDER "DataExplorer")
# Workaround for system installed VTK (tested on arch)
if(NOT OGS_USE_CONAN)
target_include_directories(NetCdfDialogLib SYSTEM
PUBLIC ${NETCDF_INCLUDES_C}
PUBLIC ${NETCDF_INCLUDES_CXX})
endif()
add_autogen_include(NetCdfDialogLib)
......@@ -98,12 +98,21 @@ set(HEADERS
VtkVisPointSetItem.h
VtkVisTabWidget.h)
set(UIS
MeshFromRaster.ui VisPrefs.ui VisualizationWidgetBase.ui
VtkAddFilterDialogBase.ui VtkVisTabWidgetBase.ui)
if(OGS_USE_NETCDF)
set(SOURCES ${SOURCES} NetCdfConfigureDialog.h NetCdfConfigureDialog.cpp)
set(UIS ${UIS} NetCdfConfigure.ui)
endif()
# Visual Studio folder
source_group("Filter Header Files" REGULAR_EXPRESSION "[.]*Filter.h")
source_group("Filter Source Files" REGULAR_EXPRESSION "[.]*Filter.cpp")
source_group("Source Header Files" REGULAR_EXPRESSION "[.]*Source.h")
source_group("Source Source Files" REGULAR_EXPRESSION "[.]*Source.cpp")
file(GLOB_RECURSE UIS CONFIGURE_DEPENDS *.ui)
source_group("UI Files" FILES ${UIS})
set(SOURCE_DIR_REL ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
......@@ -119,11 +128,11 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${GUI_SOURCE_DIR_REL}/DataView
${GUI_SOURCE_DIR_REL}/VtkModules/Qt)
ogs_add_library(VtkVis ${SOURCES} ${HEADERS} ${UIS})
ogs_add_library(VtkVis STATIC ${SOURCES} ${HEADERS} ${UIS})
if(GEOTIFF_FOUND)
include_directories(${GEOTIFF_INCLUDE_DIRS})
target_link_libraries(VtkVis INTERFACE ${GEOTIFF_LIBRARIES})
target_link_libraries(VtkVis PUBLIC ${GEOTIFF_LIBRARIES})
endif() # GEOTIFF_FOUND
target_link_libraries(VtkVis
......@@ -136,7 +145,20 @@ target_link_libraries(VtkVis
PRIVATE MathLib ApplicationsFileIO Qt5::Gui logog)
if(OGS_USE_NETCDF)
target_link_libraries(VtkVis PRIVATE NetCdfDialogLib)
target_link_libraries(VtkVis
PUBLIC ${NETCDF_LIBRARIES_CXX}
${NETCDF_LIBRARIES_C}
${HDF5_HL_LIBRARIES}
${HDF5_LIBRARIES})
if(OGS_USE_CONAN AND MSVC)
target_link_libraries(VtkVis PUBLIC ${CONAN_LIBS})
endif()
# Workaround for system installed VTK (tested on arch)
if(NOT OGS_USE_CONAN)
target_include_directories(VtkVis SYSTEM
PUBLIC ${NETCDF_INCLUDES_C}
PUBLIC ${NETCDF_INCLUDES_CXX})
endif()
endif()
set_property(TARGET VtkVis PROPERTY FOLDER "DataExplorer")
......
......@@ -24,7 +24,7 @@
#include "VtkGeoImageSource.h"
#include "VtkRaster.h"
#ifdef OGS_USE_NETCDF
#include "NetCdfDialog/NetCdfConfigureDialog.h"
#include "NetCdfConfigureDialog.h"
#endif // OGS_USE_NETCDF
#include <QFileDialog>
......
......@@ -77,7 +77,7 @@
#include "MeshElementRemovalDialog.h"
#include "MeshQualitySelectionDialog.h"
#ifdef OGS_USE_NETCDF
#include "NetCdfDialog/NetCdfConfigureDialog.h"
#include "NetCdfConfigureDialog.h"
#endif // OGS_USE_NETCDF
#include "SHPImportDialog.h"
#include "SetNameDialog.h"
......
......@@ -30,7 +30,7 @@ target_link_libraries(ApplicationsFileIO
GeoLib
MathLib
logog
PRIVATE MeshLib GitInfoLib)
PRIVATE MeshLib GitInfoLib std::filesystem)
if(OGS_BUILD_GUI)
# Needed for the XmlPrjInterface, which links the DE/Base/OGSError.h.
......
......@@ -15,10 +15,13 @@
#include <logog/include/logog.hpp>
#include "createSurface.h"
#include "filesystem.h"
#include "Applications/FileIO/Gmsh/GMSHInterface.h"
#include "Applications/FileIO/Gmsh/GmshReader.h"
#include "BaseLib/StringTools.h"
#include "GeoLib/GEOObjects.h"
#include "GeoLib/Point.h"
#include "GeoLib/Polygon.h"
......@@ -77,20 +80,18 @@ bool createSurface(GeoLib::Polyline const& ply,
0.0, 0, geo_names, false, false);
gmsh_io.setPrecision(std::numeric_limits<double>::digits10);
char file_base_name_c[L_tmpnam];
if (! std::tmpnam(file_base_name_c))
{
OGS_FATAL("Could not create unique file name.");
}
std::string const file_base_name(file_base_name_c);
gmsh_io.writeToFile(file_base_name + ".geo");
std::string gmsh_command =
gmsh_binary + " -2 -algo meshadapt \"" + file_base_name + ".geo\"";
gmsh_command += " -o \"" + file_base_name + ".msh\"";
// write to random file in temp directory
auto geo_file = fs::temp_directory_path() /= BaseLib::randomString(32);
auto msh_file = fs::temp_directory_path() /= BaseLib::randomString(32);
gmsh_io.writeToFile(geo_file.string());
// Newer gmsh versions write a newer file format for meshes per default. At
// the moment we can't read this new format. This is a switch for gmsh to
// write the 'old' file format.
gmsh_command += " -format msh22";
std::string gmsh_command =
gmsh_binary + " -2 -algo meshadapt -format msh22 -o "
+ msh_file.string() + " " + geo_file.string();
int const gmsh_return_value = std::system(gmsh_command.c_str());
if (gmsh_return_value != 0)
{
......@@ -98,18 +99,14 @@ bool createSurface(GeoLib::Polyline const& ply,
gmsh_return_value);
}
auto surface_mesh =
FileIO::GMSH::readGMSHMesh("\"" + file_base_name + ".msh\"");
FileIO::GMSH::readGMSHMesh(msh_file.string());
if (!surface_mesh)
{
WARN("The surface mesh could not be created.");
return false;
}
if (std::remove((file_base_name + ".geo").c_str()) !=0)
WARN("Could not remove temporary file '%s'.",
(file_base_name + ".geo").c_str());
if (std::remove((file_base_name + ".msh").c_str()) !=0)
WARN("Could not remove temporary file '%s'.",
(file_base_name + ".msh").c_str());
if (!(fs::remove(geo_file) && fs::remove(msh_file)))
WARN("Could not remove temporary files in createSurface.");
// convert the surface mesh into a geometric surface
if (!MeshLib::convertMeshToGeo(*surface_mesh, geometries,
......
......@@ -15,13 +15,14 @@
#include "StringTools.h"
#include <algorithm>
#include <boost/algorithm/string/replace.hpp>
#include <cctype>
#include <chrono>
#include <cstdarg>
#include <cstdio>
#include <iomanip>
#include <logog/include/logog.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <random>
namespace BaseLib
{
......@@ -104,4 +105,24 @@ std::string format(const char* format_str, ... )
return std::string(buffer.data());
}
std::string randomString(std::size_t const length)
{
static constexpr char charset[] =
"0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
static const auto seed = static_cast<std::mt19937::result_type>(
std::chrono::system_clock::now().time_since_epoch().count());
static std::mt19937 generator{seed};
static std::uniform_int_distribution<unsigned short> distribution(
0, sizeof(charset) - 2);
std::string s(length, 0);
std::generate_n(
begin(s), length, [&]() { return charset[distribution(generator)]; });
return s;
}
} // end namespace BaseLib
......@@ -83,4 +83,7 @@ std::string const& tostring(std::string const& value);
//! returns printf-like formatted string
std::string format(const char* format_string, ... );
//! Returns a random string of the given length containing just a-z,A-Z,0-9
std::string randomString(std::size_t length);
} // end namespace BaseLib
// Provides namespace fs for std::filesystem
#include <@CXX_FILESYSTEM_HEADER@>
namespace fs = @CXX_FILESYSTEM_NAMESPACE@;
# ---- OGS-6 Project ----
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.14)
# Set CMake policies
cmake_policy(SET CMP0054 NEW)
cmake_policy(SET CMP0071 NEW)
cmake_policy(SET CMP0074 NEW)
if(${CMAKE_VERSION} VERSION_GREATER 3.14)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.15)
cmake_policy(SET CMP0092 NEW)
endif()
if(MSVC AND NOT ${CMAKE_GENERATOR} STREQUAL Ninja)
# Force 64-bit VS compiler
set(CMAKE_GENERATOR_TOOLSET host=x64)
endif()
project(OGS-6)
include(scripts/cmake/CMakeSetup.cmake)
......
......@@ -18,6 +18,5 @@ namespace TestInfoLib
namespace TestInfo
{
const std::string data_path("@Data_SOURCE_DIR@");
const std::string tests_tmp_path("@PROJECT_BINARY_DIR@/Tests/");
}
}
......@@ -22,6 +22,5 @@ namespace TestInfoLib
namespace TestInfo
{
extern TESTINFOLIB_EXPORT const std::string data_path;
extern TESTINFOLIB_EXPORT const std::string tests_tmp_path;
} // namespace
} // namespace
......@@ -20,6 +20,7 @@ pipeline {
booleanParam(name: 'eve_parallel', defaultValue: true)
booleanParam(name: 'win', defaultValue: true)
booleanParam(name: 'mac', defaultValue: true)
booleanParam(name: 'mac_gui', defaultValue: true)
booleanParam(name: 'clang_analyzer', defaultValue: true)
booleanParam(name: 'master_jobs', defaultValue: true)
}
......@@ -287,6 +288,7 @@ pipeline {
'-DOGS_USE_CONAN=OFF ' +
'-DOGS_BUILD_UTILS=ON ' +
'-DBUILD_SHARED_LIBS=ON ' +
'-DOGS_CPU_ARCHITECTURE=sandybridge ' +
'-DCMAKE_INSTALL_PREFIX=/global/apps/ogs/head/standard ' +
'-DOGS_MODULEFILE=/global/apps/modulefiles/ogs/head/standard '
env = 'eve/cli.sh'
......@@ -342,6 +344,7 @@ pipeline {
'-DOGS_USE_CONAN=OFF ' +
'-DOGS_USE_PETSC=ON ' +
'-DBUILD_SHARED_LIBS=ON ' +
'-DOGS_CPU_ARCHITECTURE=sandybridge ' +
'-DCMAKE_INSTALL_PREFIX=/global/apps/ogs/head/petsc ' +
'-DOGS_MODULEFILE=/global/apps/modulefiles/ogs/head/petsc '
env = 'eve/petsc.sh'
......@@ -388,8 +391,8 @@ pipeline {
}
agent {label 'win && conan' }
environment {
MSVC_NUMBER = '15'
MSVC_VERSION = '2017'
MSVC_NUMBER = '16'
MSVC_VERSION = '2019'
OMP_NUM_THREADS = '1'
CC = 'clcache'
CXX = 'clcache'
......@@ -461,7 +464,7 @@ pipeline {
'-DOGS_CPU_ARCHITECTURE=core2 ' +
'-DOGS_BUILD_UTILS=ON ' +
'-DOGS_CONAN_BUILD=missing ' +
'-DCMAKE_OSX_DEPLOYMENT_TARGET="10.14" '
'-DCMAKE_OSX_DEPLOYMENT_TARGET="10.15" '
}
build {
target="package"
......@@ -492,8 +495,7 @@ pipeline {
stage('Mac-Gui') {
when {
beforeAgent true
// expression { return params.mac && (stage_required.build || stage_required.full) }
expression { return false }
expression { return params.mac_gui && (stage_required.build || stage_required.full) }
}
agent { label "mac"}
environment {
......@@ -508,8 +510,8 @@ pipeline {
'-DOGS_CPU_ARCHITECTURE=core2 ' +
'-DOGS_BUILD_UTILS=ON ' +
'-DOGS_BUILD_GUI=ON ' +
'-DOGS_CONAN_BUILD=missing ' +
'-DCMAKE_OSX_DEPLOYMENT_TARGET="10.14" ' +
'-DOGS_USE_CONAN=OFF ' +
'-DCMAKE_OSX_DEPLOYMENT_TARGET="10.15" ' +
'-DOGS_USE_NETCDF=ON '
}
build {
......@@ -558,7 +560,7 @@ pipeline {
cmakeOptions =
"-DBUILD_SHARED_LIBS=${build_shared} " +
'-DBUILD_TESTING=OFF ' +
'-DCMAKE_CXX_CLANG_TIDY=clang-tidy-8 '
'-DCMAKE_CXX_CLANG_TIDY=clang-tidy-9 '
}
build { log = 'build.log' }
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment