From 20d18b4422e705afe20f36f083e6984a265e20bf Mon Sep 17 00:00:00 2001 From: Lars Bilke <lars.bilke@ufz.de> Date: Thu, 27 May 2021 12:17:41 +0200 Subject: [PATCH] [cmake] Return early in tools CMakeLists, avoids indentation. --- .../Utils/FileConverter/CMakeLists.txt | 78 ++++++------- Applications/Utils/MeshEdit/CMakeLists.txt | 104 +++++++++--------- .../Utils/MeshGeoTools/CMakeLists.txt | 52 ++++----- .../Utils/ModelPreparation/CMakeLists.txt | 22 ++-- .../PartitionMesh/CMakeLists.txt | 32 +++--- .../Utils/PostProcessing/CMakeLists.txt | 30 ++--- .../Utils/SimpleMeshCreation/CMakeLists.txt | 22 ++-- 7 files changed, 177 insertions(+), 163 deletions(-) diff --git a/Applications/Utils/FileConverter/CMakeLists.txt b/Applications/Utils/FileConverter/CMakeLists.txt index d6b3c6467cf..e5823db69ff 100644 --- a/Applications/Utils/FileConverter/CMakeLists.txt +++ b/Applications/Utils/FileConverter/CMakeLists.txt @@ -1,45 +1,47 @@ -if(NOT OGS_USE_MPI) - set(TOOLS - convertGEO - generateMatPropsFromMatID - GMSH2OGS - OGS2VTK - VTK2OGS - VTK2TIN - TIN2VTK - TecPlotTools - GocadSGridReader - GocadTSurfaceReader - Mesh2Raster - ) +if(OGS_USE_MPI) + return() +endif() - if(OGS_USE_NETCDF) - list(APPEND TOOLS NetCdfConverter) - endif() +set(TOOLS + convertGEO + generateMatPropsFromMatID + GMSH2OGS + OGS2VTK + VTK2OGS + VTK2TIN + TIN2VTK + TecPlotTools + GocadSGridReader + GocadTSurfaceReader + Mesh2Raster +) - if(OGS_BUILD_GUI) - list(APPEND TOOLS ConvertSHPToGLI FEFLOW2OGS Mesh2Shape) - endif() +if(OGS_USE_NETCDF) + list(APPEND TOOLS NetCdfConverter) +endif() - foreach(tool ${TOOLS}) - ogs_add_executable(${tool} ${tool}.cpp) - target_link_libraries( - ${tool} ApplicationsFileIO GitInfoLib MeshLib MeshGeoToolsLib tclap - ) - endforeach() - install(TARGETS ${TOOLS} RUNTIME DESTINATION bin) +if(OGS_BUILD_GUI) + list(APPEND TOOLS ConvertSHPToGLI FEFLOW2OGS Mesh2Shape) +endif() - if(TARGET ConvertSHPToGLI) - target_link_libraries(ConvertSHPToGLI GeoLib Qt5::Xml) - endif() +foreach(tool ${TOOLS}) + ogs_add_executable(${tool} ${tool}.cpp) + target_link_libraries( + ${tool} ApplicationsFileIO GitInfoLib MeshLib MeshGeoToolsLib tclap + ) +endforeach() +install(TARGETS ${TOOLS} RUNTIME DESTINATION bin) - if(TARGET NetCdfConverter) - target_link_libraries( - NetCdfConverter ${NETCDF_LIBRARIES_CXX} ${NETCDF_LIBRARIES_C} - ${HDF5_HL_LIBRARIES} ${HDF5_LIBRARIES} - ) - if(OGS_USE_CONAN AND MSVC) - target_link_libraries(NetCdfConverter ${CONAN_LIBS}) - endif() +if(TARGET ConvertSHPToGLI) + target_link_libraries(ConvertSHPToGLI GeoLib Qt5::Xml) +endif() + +if(TARGET NetCdfConverter) + target_link_libraries( + NetCdfConverter ${NETCDF_LIBRARIES_CXX} ${NETCDF_LIBRARIES_C} + ${HDF5_HL_LIBRARIES} ${HDF5_LIBRARIES} + ) + if(OGS_USE_CONAN AND MSVC) + target_link_libraries(NetCdfConverter ${CONAN_LIBS}) endif() endif() diff --git a/Applications/Utils/MeshEdit/CMakeLists.txt b/Applications/Utils/MeshEdit/CMakeLists.txt index e5da277d0d8..54a64aaac77 100644 --- a/Applications/Utils/MeshEdit/CMakeLists.txt +++ b/Applications/Utils/MeshEdit/CMakeLists.txt @@ -1,56 +1,58 @@ -if(NOT OGS_USE_MPI) - set(TOOLS - AddElementQuality - AddFaultToVoxelGrid - AddLayer - appendLinesAlongPolyline - checkMesh - convertToLinearMesh - CreateBoundaryConditionsAlongPolylines - createLayeredMeshFromRasters - createQuadraticMesh - editMaterialID - ExtractBoundary - ExtractMaterials - ExtractSurface - Layers2Grid - MapGeometryToMeshSurface - MoveMesh - moveMeshNodes - NodeReordering - queryMesh - removeMeshElements - ResetPropertiesInPolygonalRegion - reviseMesh - swapNodeCoordinateAxes - Vtu2Grid - ) - - if(OGS_BUILD_GUI) - ogs_add_executable( - RemoveGhostData RemoveGhostData.cpp - ${PROJECT_SOURCE_DIR}/ThirdParty/paraview/vtkCleanUnstructuredGrid.cpp - ) - target_include_directories( - RemoveGhostData PRIVATE ${PROJECT_SOURCE_DIR}/ThirdParty/paraview - ) - target_link_libraries(RemoveGhostData GitInfoLib MeshLib tclap) - install(TARGETS RemoveGhostData RUNTIME DESTINATION bin) - endif() +if(OGS_USE_MPI) + return() +endif() - foreach(tool ${TOOLS}) - ogs_add_executable(${tool} ${tool}.cpp) - target_link_libraries(${tool} GitInfoLib MeshLib tclap) - endforeach() - install(TARGETS ${TOOLS} RUNTIME DESTINATION bin) +set(TOOLS + AddElementQuality + AddFaultToVoxelGrid + AddLayer + appendLinesAlongPolyline + checkMesh + convertToLinearMesh + CreateBoundaryConditionsAlongPolylines + createLayeredMeshFromRasters + createQuadraticMesh + editMaterialID + ExtractBoundary + ExtractMaterials + ExtractSurface + Layers2Grid + MapGeometryToMeshSurface + MoveMesh + moveMeshNodes + NodeReordering + queryMesh + removeMeshElements + ResetPropertiesInPolygonalRegion + reviseMesh + swapNodeCoordinateAxes + Vtu2Grid +) - target_link_libraries( - appendLinesAlongPolyline MeshGeoToolsLib ApplicationsFileIO +if(OGS_BUILD_GUI) + ogs_add_executable( + RemoveGhostData RemoveGhostData.cpp + ${PROJECT_SOURCE_DIR}/ThirdParty/paraview/vtkCleanUnstructuredGrid.cpp ) - target_link_libraries( - CreateBoundaryConditionsAlongPolylines MeshGeoToolsLib ApplicationsFileIO + target_include_directories( + RemoveGhostData PRIVATE ${PROJECT_SOURCE_DIR}/ThirdParty/paraview ) - target_link_libraries(createLayeredMeshFromRasters ApplicationsFileIO) - target_link_libraries(MapGeometryToMeshSurface MeshGeoToolsLib) - target_link_libraries(ResetPropertiesInPolygonalRegion ApplicationsFileIO) + target_link_libraries(RemoveGhostData GitInfoLib MeshLib tclap) + install(TARGETS RemoveGhostData RUNTIME DESTINATION bin) endif() + +foreach(tool ${TOOLS}) + ogs_add_executable(${tool} ${tool}.cpp) + target_link_libraries(${tool} GitInfoLib MeshLib tclap) +endforeach() +install(TARGETS ${TOOLS} RUNTIME DESTINATION bin) + +target_link_libraries( + appendLinesAlongPolyline MeshGeoToolsLib ApplicationsFileIO +) +target_link_libraries( + CreateBoundaryConditionsAlongPolylines MeshGeoToolsLib ApplicationsFileIO +) +target_link_libraries(createLayeredMeshFromRasters ApplicationsFileIO) +target_link_libraries(MapGeometryToMeshSurface MeshGeoToolsLib) +target_link_libraries(ResetPropertiesInPolygonalRegion ApplicationsFileIO) diff --git a/Applications/Utils/MeshGeoTools/CMakeLists.txt b/Applications/Utils/MeshGeoTools/CMakeLists.txt index 2248e9f004c..99eff7baa94 100644 --- a/Applications/Utils/MeshGeoTools/CMakeLists.txt +++ b/Applications/Utils/MeshGeoTools/CMakeLists.txt @@ -1,30 +1,32 @@ -if(NOT OGS_USE_MPI) - set(TOOLS - AssignRasterDataToMesh - computeSurfaceNodeIDsInPolygonalRegion - constructMeshesFromGeometry - createIntermediateRasters - identifySubdomains - IntegrateBoreholesIntoMesh - Raster2Mesh - ) +if(OGS_USE_MPI) + return() +endif() - if(OGS_BUILD_GUI) - # Utility requires that GUI is build because it uses Qt-based functionality - # Also requires gmsh at runtime - list(APPEND TOOLS VerticalSliceFromLayers) - endif() +set(TOOLS + AssignRasterDataToMesh + computeSurfaceNodeIDsInPolygonalRegion + constructMeshesFromGeometry + createIntermediateRasters + identifySubdomains + IntegrateBoreholesIntoMesh + Raster2Mesh +) - foreach(tool ${TOOLS}) - ogs_add_executable(${tool} ${tool}.cpp) - target_link_libraries( - ${tool} ApplicationsFileIO GitInfoLib MeshLib MeshGeoToolsLib tclap - ) - endforeach() +if(OGS_BUILD_GUI) + # Utility requires that GUI is build because it uses Qt-based functionality + # Also requires gmsh at runtime + list(APPEND TOOLS VerticalSliceFromLayers) +endif() - if(TARGET VerticalSliceFromLayers) - target_link_libraries(VerticalSliceFromLayers Qt5::Xml Qt5::XmlPatterns) - endif() +foreach(tool ${TOOLS}) + ogs_add_executable(${tool} ${tool}.cpp) + target_link_libraries( + ${tool} ApplicationsFileIO GitInfoLib MeshLib MeshGeoToolsLib tclap + ) +endforeach() - install(TARGETS ${TOOLS} RUNTIME DESTINATION bin) +if(TARGET VerticalSliceFromLayers) + target_link_libraries(VerticalSliceFromLayers Qt5::Xml Qt5::XmlPatterns) endif() + +install(TARGETS ${TOOLS} RUNTIME DESTINATION bin) diff --git a/Applications/Utils/ModelPreparation/CMakeLists.txt b/Applications/Utils/ModelPreparation/CMakeLists.txt index dfd9b2f6f9e..3ab33a1d0ab 100644 --- a/Applications/Utils/ModelPreparation/CMakeLists.txt +++ b/Applications/Utils/ModelPreparation/CMakeLists.txt @@ -1,12 +1,14 @@ -if(NOT OGS_USE_MPI) - set(TOOLS ComputeNodeAreasFromSurfaceMesh convertVtkDataArrayToVtkDataArray - createNeumannBc scaleProperty - ) - foreach(tool ${TOOLS}) - ogs_add_executable(${tool} ${tool}.cpp) - target_link_libraries(${tool} GitInfoLib MeshLib tclap) - endforeach() - install(TARGETS ${TOOLS} RUNTIME DESTINATION bin) +add_subdirectory(PartitionMesh) + +if(OGS_USE_MPI) + return() endif() -add_subdirectory(PartitionMesh) +set(TOOLS ComputeNodeAreasFromSurfaceMesh convertVtkDataArrayToVtkDataArray + createNeumannBc scaleProperty +) +foreach(tool ${TOOLS}) + ogs_add_executable(${tool} ${tool}.cpp) + target_link_libraries(${tool} GitInfoLib MeshLib tclap) +endforeach() +install(TARGETS ${TOOLS} RUNTIME DESTINATION bin) diff --git a/Applications/Utils/ModelPreparation/PartitionMesh/CMakeLists.txt b/Applications/Utils/ModelPreparation/PartitionMesh/CMakeLists.txt index 7d2208f745d..3e3565c0e8e 100644 --- a/Applications/Utils/ModelPreparation/PartitionMesh/CMakeLists.txt +++ b/Applications/Utils/ModelPreparation/PartitionMesh/CMakeLists.txt @@ -1,16 +1,18 @@ -if(NOT OGS_USE_MPI) - CPMAddPackage( - NAME metis - GITHUB_REPOSITORY scibuilder/metis - GIT_TAG 982842a5ace9b3da2b2800817eb9e5fd3b42966b - DOWNLOAD_ONLY YES - ) - include(${PROJECT_SOURCE_DIR}/scripts/cmake/MetisSetup.cmake) - - ogs_add_executable( - partmesh PartitionMesh.cpp Metis.cpp NodeWiseMeshPartitioner.cpp - ) - target_link_libraries(partmesh GitInfoLib MeshLib tclap) - add_dependencies(partmesh mpmetis) - install(TARGETS partmesh RUNTIME DESTINATION bin) +if(OGS_USE_MPI) + return() endif() + +CPMAddPackage( + NAME metis + GITHUB_REPOSITORY scibuilder/metis + GIT_TAG 982842a5ace9b3da2b2800817eb9e5fd3b42966b + DOWNLOAD_ONLY YES +) +include(${PROJECT_SOURCE_DIR}/scripts/cmake/MetisSetup.cmake) + +ogs_add_executable( + partmesh PartitionMesh.cpp Metis.cpp NodeWiseMeshPartitioner.cpp +) +target_link_libraries(partmesh GitInfoLib MeshLib tclap) +add_dependencies(partmesh mpmetis) +install(TARGETS partmesh RUNTIME DESTINATION bin) diff --git a/Applications/Utils/PostProcessing/CMakeLists.txt b/Applications/Utils/PostProcessing/CMakeLists.txt index 705c220b769..e8aa1a36cbb 100644 --- a/Applications/Utils/PostProcessing/CMakeLists.txt +++ b/Applications/Utils/PostProcessing/CMakeLists.txt @@ -1,16 +1,18 @@ -if(NOT OGS_USE_MPI) - if(OGS_BUILD_PROCESS_LIE) - ogs_add_executable(postLIE postLIE.cpp) - target_link_libraries(postLIE GitInfoLib LIECommon tclap) - install(TARGETS postLIE RUNTIME DESTINATION bin) - endif() +if(OGS_USE_MPI) + return() +endif() + +if(OGS_BUILD_PROCESS_LIE) + ogs_add_executable(postLIE postLIE.cpp) + target_link_libraries(postLIE GitInfoLib LIECommon tclap) + install(TARGETS postLIE RUNTIME DESTINATION bin) +endif() - if(OGS_BUILD_GUI) - ogs_add_executable(Raster2PointCloud Raster2PointCloud.cpp) - target_link_libraries( - Raster2PointCloud ApplicationsFileIO BaseLib GitInfoLib tclap - VtkVisFilter - ) - install(TARGETS Raster2PointCloud RUNTIME DESTINATION bin) - endif() +if(OGS_BUILD_GUI) + ogs_add_executable(Raster2PointCloud Raster2PointCloud.cpp) + target_link_libraries( + Raster2PointCloud ApplicationsFileIO BaseLib GitInfoLib tclap + VtkVisFilter + ) + install(TARGETS Raster2PointCloud RUNTIME DESTINATION bin) endif() diff --git a/Applications/Utils/SimpleMeshCreation/CMakeLists.txt b/Applications/Utils/SimpleMeshCreation/CMakeLists.txt index c8361cc8bc7..9b0b9fd3475 100644 --- a/Applications/Utils/SimpleMeshCreation/CMakeLists.txt +++ b/Applications/Utils/SimpleMeshCreation/CMakeLists.txt @@ -1,12 +1,14 @@ -if(NOT OGS_USE_MPI) - set(TOOLS generateStructuredMesh) - if(OGS_BUILD_GUI) - list(APPEND TOOLS createMeshElemPropertiesFromASCRaster) - endif() +if(OGS_USE_MPI) + return() +endif() - foreach(tool ${TOOLS}) - ogs_add_executable(${tool} ${tool}.cpp) - target_link_libraries(${tool} ApplicationsFileIO GitInfoLib MeshLib tclap) - endforeach() - install(TARGETS ${TOOLS} RUNTIME DESTINATION bin) +set(TOOLS generateStructuredMesh) +if(OGS_BUILD_GUI) + list(APPEND TOOLS createMeshElemPropertiesFromASCRaster) endif() + +foreach(tool ${TOOLS}) + ogs_add_executable(${tool} ${tool}.cpp) + target_link_libraries(${tool} ApplicationsFileIO GitInfoLib MeshLib tclap) +endforeach() +install(TARGETS ${TOOLS} RUNTIME DESTINATION bin) -- GitLab