From 05061cec99b6f435de374ba5e9da7344843070f3 Mon Sep 17 00:00:00 2001 From: Lars Bilke <lars.bilke@ufz.de> Date: Thu, 11 Mar 2021 15:47:13 +0100 Subject: [PATCH] Make cmake-lint happy, part 1. --- .cmake-format.yaml | 4 +++ Applications/CMakeLists.txt | 4 +-- .../DataExplorer/VtkVis/CMakeLists.txt | 2 +- Applications/Utils/MeshEdit/CMakeLists.txt | 6 ++-- Applications/Utils/Tests.cmake | 3 +- CMakeLists.txt | 22 +++++------- Documentation/README.txt.in | 2 +- ProcessLib/ComponentTransport/Tests.cmake | 1 - ProcessLib/HT/Tests.cmake | 2 -- ProcessLib/HeatTransportBHE/Tests.cmake | 1 - ProcessLib/LiquidFlow/Tests.cmake | 1 - ProcessLib/RichardsMechanics/Tests.cmake | 2 -- ProcessLib/ThermoMechanics/Tests.cmake | 1 - Tests/CMakeLists.txt | 2 +- scripts/cmake/CMakeSetup.cmake | 13 +++---- scripts/cmake/ConanSetup.cmake | 2 +- scripts/cmake/Find.cmake | 1 + scripts/cmake/Functions.cmake | 20 ++++++----- scripts/cmake/ProcessesSetup.cmake | 14 ++++---- scripts/cmake/ProjectSetup.cmake | 19 ++++++----- scripts/cmake/packaging/Pack.cmake | 3 +- scripts/cmake/packaging/PackagingLinux.cmake | 2 +- scripts/cmake/test/AddTest.cmake | 3 +- scripts/cmake/test/AddTestTester.cmake | 34 +++++++++---------- scripts/cmake/test/AddTestWrapper.cmake | 4 +-- scripts/cmake/test/MeshTest.cmake | 3 +- scripts/cmake/test/OgsTest.cmake | 1 + 27 files changed, 79 insertions(+), 93 deletions(-) diff --git a/.cmake-format.yaml b/.cmake-format.yaml index 0c4294e388e..f99527b3ada 100644 --- a/.cmake-format.yaml +++ b/.cmake-format.yaml @@ -3,6 +3,10 @@ format: max_subgroups_hwrap: 3 dangle_parens: true command_case: "unchanged" +lint: + disabled_codes: + - "C0301" + - "C0113" parse: additional_commands: diff --git a/Applications/CMakeLists.txt b/Applications/CMakeLists.txt index c731e6e48d8..5c5757c3b11 100644 --- a/Applications/CMakeLists.txt +++ b/Applications/CMakeLists.txt @@ -2,11 +2,11 @@ add_subdirectory(ApplicationsLib) add_subdirectory(DataHolderLib) add_subdirectory(FileIO) -if(OGS_BUILD_UTILS AND NOT IS_SUBPROJECT) +if(OGS_BUILD_UTILS AND NOT _IS_SUBPROJECT) add_subdirectory(Utils) elseif(OGS_BUILD_GUI) add_subdirectory(Utils/OGSFileConverter) -endif() # OGS_BUILD_UTILS AND NOT IS_SUBPROJECT +endif() # OGS_BUILD_UTILS AND NOT _IS_SUBPROJECT if(OGS_BUILD_GUI) add_subdirectory(DataExplorer) diff --git a/Applications/DataExplorer/VtkVis/CMakeLists.txt b/Applications/DataExplorer/VtkVis/CMakeLists.txt index 9d631187492..7d7d42ad4d5 100644 --- a/Applications/DataExplorer/VtkVis/CMakeLists.txt +++ b/Applications/DataExplorer/VtkVis/CMakeLists.txt @@ -154,7 +154,7 @@ if(OGS_USE_NETCDF) if(NOT OGS_USE_CONAN) target_include_directories(VtkVis SYSTEM PUBLIC ${NETCDF_INCLUDES_C} - PUBLIC ${NETCDF_INCLUDES_CXX}) + ${NETCDF_INCLUDES_CXX}) endif() endif() diff --git a/Applications/Utils/MeshEdit/CMakeLists.txt b/Applications/Utils/MeshEdit/CMakeLists.txt index 8155924cf64..ae507cab6c9 100644 --- a/Applications/Utils/MeshEdit/CMakeLists.txt +++ b/Applications/Utils/MeshEdit/CMakeLists.txt @@ -35,9 +35,9 @@ if(OGS_BUILD_GUI) install(TARGETS RemoveGhostData RUNTIME DESTINATION bin) endif() -foreach(TOOL ${TOOLS}) - add_executable(${TOOL} ${TOOL}.cpp) - target_link_libraries(${TOOL} GitInfoLib MeshLib tclap) +foreach(tool ${TOOLS}) + add_executable(${tool} ${tool}.cpp) + target_link_libraries(${tool} GitInfoLib MeshLib tclap) endforeach() set_target_properties(${TOOLS} PROPERTIES FOLDER Utilities) install(TARGETS ${TOOLS} RUNTIME DESTINATION bin) diff --git a/Applications/Utils/Tests.cmake b/Applications/Utils/Tests.cmake index cb08f5a929c..83b49f66236 100644 --- a/Applications/Utils/Tests.cmake +++ b/Applications/Utils/Tests.cmake @@ -484,13 +484,12 @@ if(TARGET VerticalSliceFromLayers AND GMSH) endif() - if(TARGET GMSH2OGS AND SNAKEMAKE AND NOT OGS_USE_MPI) add_test(NAME snakemake_GMSH2OGS_ExtractBoundary COMMAND ${SNAKEMAKE} --cores all --configfile ${PROJECT_BINARY_DIR}/buildinfo.yaml -s ${CMAKE_CURRENT_SOURCE_DIR}/GMSH2OGS_ExtractBoundary.smk - ) + ) add_dependencies(ctest GMSH2OGS) endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index 6172d66c6ac..eef1d141722 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,18 +49,12 @@ if(NOT WIN32 AND OGS_BUILD_SWMM) endif() # Third-party libraries, names come from Conan package names -set(OGS_LIBS - vtk - qt - petsc - tfel - CACHE INTERNAL "") -foreach(LIB ${OGS_LIBS}) - set(OGS_LIB_${LIB} +foreach(lib vtk qt petsc tfel) + set(OGS_LIB_${lib} "Default" CACHE STRING "Which ${LIB} library should be used?") - set_property(CACHE OGS_LIB_${LIB} PROPERTY STRINGS "Default" "System") -endforeach(LIB) + set_property(CACHE OGS_LIB_${lib} PROPERTY STRINGS "Default" "System") +endforeach() if(OGS_USE_PETSC) set(OGS_USE_MPI ON CACHE BOOL "Use MPI" FORCE) @@ -84,7 +78,7 @@ include(CCacheSetup) include(CLCacheSetup) include(DocumentationSetup) include(test/Test) -if(OGS_COVERAGE AND NOT IS_SUBPROJECT) +if(OGS_COVERAGE AND NOT _IS_SUBPROJECT) include(Coverage) endif() include(CppCheck) @@ -168,10 +162,10 @@ option(OGS_ENABLE_ELEMENT_CUBOID option(OGS_ENABLE_ELEMENT_PRISM "Build FEM elements for prisms." ON) option(OGS_ENABLE_ELEMENT_PYRAMID "Build FEM elements for pyramids." ON) if(NOT OGS_MAX_ELEMENT_DIM MATCHES "^[0-3]$") - message(FATAL_ERROR "OGS_MAX_ELEMENT_DIM must be an integer between 0 and 3.") + message(FATAL_ERROR "OGS_MAX_ELEMENT_DIM must be an integer between 0 and 3.") endif() if(NOT OGS_MAX_ELEMENT_ORDER MATCHES "^[0-9]$") - message(FATAL_ERROR "OGS_MAX_ELEMENT_ORDER must be an integer.") + message(FATAL_ERROR "OGS_MAX_ELEMENT_ORDER must be an integer.") endif() option(OGS_CHECK_HEADER_COMPILATION "Check header for standalone compilation." @@ -240,7 +234,7 @@ if(OGS_BUILD_CLI OR OGS_BUILD_UTILS OR OGS_BUILD_TESTING) add_subdirectory(MaterialLib) add_subdirectory(ProcessLib) endif() -if(OGS_BUILD_TESTING AND NOT IS_SUBPROJECT) +if(OGS_BUILD_TESTING AND NOT _IS_SUBPROJECT) add_subdirectory(Tests) endif() diff --git a/Documentation/README.txt.in b/Documentation/README.txt.in index 51e7b59760c..839ff9383f0 100644 --- a/Documentation/README.txt.in +++ b/Documentation/README.txt.in @@ -3,4 +3,4 @@ OGS binary package usage Start the appropriate executable in the *bin*-folder. -@README_PLATFORM_INSTRUCTIONS@ +@_README_PLATFORM_INSTRUCTIONS@ diff --git a/ProcessLib/ComponentTransport/Tests.cmake b/ProcessLib/ComponentTransport/Tests.cmake index 4b67ec1bd8b..feea8077888 100644 --- a/ProcessLib/ComponentTransport/Tests.cmake +++ b/ProcessLib/ComponentTransport/Tests.cmake @@ -883,7 +883,6 @@ AddTest( VIS out_ogs5_H_ts_1_t_10000000.000000.vtu ) - AddTest( NAME 1D_ComponentTransport_VariableDependentBoundary PATH Parabolic/ComponentTransport/VariableNeumannBoundary diff --git a/ProcessLib/HT/Tests.cmake b/ProcessLib/HT/Tests.cmake index a1d14b54c0b..7f37d9d4409 100644 --- a/ProcessLib/HT/Tests.cmake +++ b/ProcessLib/HT/Tests.cmake @@ -60,7 +60,6 @@ AddTest( VIS IsothermalFluidFlow_ts_1_t_1.000000.vtu ) - AddTest( NAME HT_SimpleSynthetics_PressureParabolicTemperatureParabolic PATH Parabolic/HT/SimpleSynthetics @@ -276,7 +275,6 @@ AddTest( VIS IsothermalFluidFlowWithGravityStaggered_ts_1_t_1.000000.vtu ) - AddTest( NAME HT_SimpleSynthetics_PressureParabolicTemperatureParabolicStaggered PATH Parabolic/HT/SimpleSynthetics diff --git a/ProcessLib/HeatTransportBHE/Tests.cmake b/ProcessLib/HeatTransportBHE/Tests.cmake index c8a760ecfa5..1014e8a7cab 100644 --- a/ProcessLib/HeatTransportBHE/Tests.cmake +++ b/ProcessLib/HeatTransportBHE/Tests.cmake @@ -1,7 +1,6 @@ AddTest( NAME HeatTransportBHE_1U_3D_beier_sandbox PATH Parabolic/T/3D_Beier_sandbox - RUNTIME 15 EXECUTABLE ogs EXECUTABLE_ARGS beier_sandbox.prj WRAPPER time diff --git a/ProcessLib/LiquidFlow/Tests.cmake b/ProcessLib/LiquidFlow/Tests.cmake index a354ea7ce8a..9f3da7165b6 100644 --- a/ProcessLib/LiquidFlow/Tests.cmake +++ b/ProcessLib/LiquidFlow/Tests.cmake @@ -27,7 +27,6 @@ if (NOT OGS_USE_MPI) OgsTest(PROJECTFILE Parabolic/LiquidFlow/DrainageExcavation/drainage_LiquidFlow.prj) endif() - AddTest( NAME LiquidFlow_GravityDriven PATH Parabolic/LiquidFlow/GravityDriven diff --git a/ProcessLib/RichardsMechanics/Tests.cmake b/ProcessLib/RichardsMechanics/Tests.cmake index 71cfbb056d5..9d9e36b35a4 100644 --- a/ProcessLib/RichardsMechanics/Tests.cmake +++ b/ProcessLib/RichardsMechanics/Tests.cmake @@ -23,8 +23,6 @@ if (NOT OGS_USE_MPI) OgsTest(PROJECTFILE RichardsMechanics/LiakopoulosHM/liakopoulos_QN.prj RUNTIME 50) endif() - - AddTest( NAME RichardsMechanics_square_1e2_confined_compression_restart PATH RichardsMechanics diff --git a/ProcessLib/ThermoMechanics/Tests.cmake b/ProcessLib/ThermoMechanics/Tests.cmake index 3dc844d40f6..14909bd0372 100644 --- a/ProcessLib/ThermoMechanics/Tests.cmake +++ b/ProcessLib/ThermoMechanics/Tests.cmake @@ -139,7 +139,6 @@ AddTest( WRAPPER time TESTER vtkdiff REQUIREMENTS NOT (OGS_USE_LIS OR OGS_USE_MPI) - RUNTIME 17 DIFF_DATA tm1_3Dsquare_ts_1_t_1.000000.vtu tm1_3Dsquare_ts_1_t_1.000000.vtu temperature temperature 1e-11 0.0 tm1_3Dsquare_ts_1_t_1.000000.vtu tm1_3Dsquare_ts_1_t_1.000000.vtu displacement displacement 1e-10 0.0 diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 5dc0d9b76b4..7dc25988a37 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -99,7 +99,7 @@ endif() # cmake-format: off # Add make-target tests which runs the testrunner -if(IS_CI AND NOT OGS_COVERAGE) +if(DEFINED ENV{CI} AND NOT OGS_COVERAGE) set(OGS_CI_TESTRUNNER_REPEAT 3 CACHE STRING "The number of testrunner repeats for the tests target") set(TESTRUNNER_ADDITIONAL_ARGUMENTS ${TESTRUNNER_ADDITIONAL_ARGUMENTS} diff --git a/scripts/cmake/CMakeSetup.cmake b/scripts/cmake/CMakeSetup.cmake index 0d13896d857..e84f88e1fc4 100644 --- a/scripts/cmake/CMakeSetup.cmake +++ b/scripts/cmake/CMakeSetup.cmake @@ -1,9 +1,9 @@ # Disallow in-source builds as the git project cluttered with generated files # probably confuses people. source/build* is still allowed! if("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}") - message(FATAL_ERROR "In-source builds are not allowed!\n" - "Make sure to remove CMakeCache.txt and CMakeFiles/ " - "from the source directory!") + message(FATAL_ERROR "In-source builds are not allowed!\n" + "Make sure to remove CMakeCache.txt and CMakeFiles/ " + "from the source directory!") endif() # Set additional CMake modules path @@ -33,7 +33,7 @@ set(NUM_PROCESSORS ${NUM_PROCESSORS} CACHE STRING "Processor count") # Check if this project is included in another if(NOT PROJECT_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) - set(IS_SUBPROJECT ON CACHE INTERNAL "" FORCE) + set(_IS_SUBPROJECT ON CACHE INTERNAL "" FORCE) set(OGS_BUILD_CLI OFF CACHE BOOL "" FORCE) endif() @@ -48,11 +48,6 @@ endif() # Get the hostname site_name(HOSTNAME) -# Check if we are running under CI -if(DEFINED ENV{JENKINS_URL} OR DEFINED ENV{CI}) - set(IS_CI ON CACHE INTERNAL "") -endif() - if(BUILD_SHARED_LIBS) # When static libraries are used in some shared libraries it is required # that also the static libraries have position independent code. diff --git a/scripts/cmake/ConanSetup.cmake b/scripts/cmake/ConanSetup.cmake index 9b97ed7b29c..65b619bf2ca 100644 --- a/scripts/cmake/ConanSetup.cmake +++ b/scripts/cmake/ConanSetup.cmake @@ -129,7 +129,7 @@ file(TIMESTAMP ${PROJECT_BINARY_DIR}/conan_install_timestamp.txt file_timestamp string(TIMESTAMP timestamp "%Y.%m.%d") # Run conan install update only once a day -if("${file_timestamp}" VERSION_LESS ${timestamp} OR IS_CI) +if("${file_timestamp}" VERSION_LESS ${timestamp} OR DEFINED ENV{CI}) file(WRITE ${PROJECT_BINARY_DIR}/conan_install_timestamp.txt "${timestamp}\n") set(CONAN_UPDATE UPDATE) set(CONAN_COMMAND ${CONAN_CMD} CACHE INTERNAL "") # Speed up conan_add_remote diff --git a/scripts/cmake/Find.cmake b/scripts/cmake/Find.cmake index 1a2e1f2ba0a..fad0363838c 100644 --- a/scripts/cmake/Find.cmake +++ b/scripts/cmake/Find.cmake @@ -89,6 +89,7 @@ if(OGS_USE_MFRONT) add_definitions(-DHAVE_PTHREADS) endif() if(OGS_USE_CONAN) + # cmake-lint: disable=C0103 set(TFELHOME ${CONAN_TFEL_ROOT} CACHE INTERNAL "") endif() endif() diff --git a/scripts/cmake/Functions.cmake b/scripts/cmake/Functions.cmake index d2bd612b225..019e9c6d46c 100644 --- a/scripts/cmake/Functions.cmake +++ b/scripts/cmake/Functions.cmake @@ -1,12 +1,12 @@ # Returns the current subdirectory in the sources directory. -macro(GET_CURRENT_SOURCE_SUBDIRECTORY CURRENT_SOURCE_SUBDIRECTORY) +macro(GET_CURRENT_SOURCE_SUBDIRECTORY current_source_subdirectory) string(REGEX REPLACE ".*/([^/]*)" "\\1" REGEX_RESULT "${CMAKE_CURRENT_SOURCE_DIR}" ) - set(${CURRENT_SOURCE_SUBDIRECTORY} ${REGEX_RESULT}) + set(${current_source_subdirectory} ${REGEX_RESULT}) endmacro() -# Returns a list of source files (*.h and *.cpp) in SOURCE_FILES and creates a Visual +# Returns a list of source files (*.h and *.cpp) in source_files and creates a Visual # Studio folder. A (relative) subdirectory can be passed as second parameter (optional). -macro(GET_SOURCE_FILES SOURCE_FILES) +macro(GET_SOURCE_FILES source_files) if(${ARGC} EQUAL 2) set(DIR "${ARGV1}") else() @@ -18,8 +18,8 @@ macro(GET_SOURCE_FILES SOURCE_FILES) file(GLOB GET_SOURCE_FILES_TEMPLATES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS ${DIR}/*.tpp) file(GLOB GET_SOURCE_FILES_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS ${DIR}/*.cpp) - set(${SOURCE_FILES} ${GET_SOURCE_FILES_HEADERS} ${GET_SOURCE_FILES_TEMPLATES} ${GET_SOURCE_FILES_SOURCES}) - list(LENGTH ${SOURCE_FILES} NUM_FILES) + set(${source_files} ${GET_SOURCE_FILES_HEADERS} ${GET_SOURCE_FILES_TEMPLATES} ${GET_SOURCE_FILES_SOURCES}) + list(LENGTH ${source_files} NUM_FILES) if(${NUM_FILES} EQUAL 0) message(FATAL_ERROR "No source files found in ${DIR}") endif() @@ -40,9 +40,9 @@ macro(GET_SOURCE_FILES SOURCE_FILES) endmacro() -# Appends a list of source files (*.h and *.cpp) to SOURCE_FILES and creates a Visual +# Appends a list of source files (*.h and *.cpp) to source_files and creates a Visual # Studio folder. A (relative) subdirectory can be passed as second parameter (optional). -macro(APPEND_SOURCE_FILES SOURCE_FILES) +macro(APPEND_SOURCE_FILES source_files) if(${ARGC} EQUAL 2) set(DIR "${ARGV1}") else() @@ -50,7 +50,7 @@ macro(APPEND_SOURCE_FILES SOURCE_FILES) endif() GET_SOURCE_FILES(TMP_SOURCES "${DIR}") - set(${SOURCE_FILES} ${${SOURCE_FILES}} ${TMP_SOURCES}) + set(${source_files} ${${source_files}} ${TMP_SOURCES}) endmacro() # Creates one ctest for each googletest found in source files passed as arguments @@ -79,6 +79,7 @@ function(add_autogen_include target) endif() endfunction() +# Replacement for add_library() for ogs targets function(ogs_add_library targetName) add_library(${targetName} ${ARGN}) target_compile_options(${targetName} PRIVATE @@ -104,6 +105,7 @@ function(ogs_add_library targetName) endif() endfunction() +# Parses current directory into a list function(current_dir_as_list baseDir outList) file(RELATIVE_PATH REL_DIR ${PROJECT_SOURCE_DIR}/${baseDir} ${CMAKE_CURRENT_LIST_DIR}) string(REPLACE "/" ";" DIR_LIST ${REL_DIR}) diff --git a/scripts/cmake/ProcessesSetup.cmake b/scripts/cmake/ProcessesSetup.cmake index 86d103a3301..9d3d015e401 100644 --- a/scripts/cmake/ProcessesSetup.cmake +++ b/scripts/cmake/ProcessesSetup.cmake @@ -1,6 +1,6 @@ # A list of processes to be build. Also used in the ProcessLib to select # processes to be build. -set(ProcessesList +set(processes_list ComponentTransport HT HeatConduction @@ -25,7 +25,7 @@ set(ProcessesList TwoPhaseFlowWithPrho) # Add a cmake option for each process. -foreach(process ${ProcessesList}) +foreach(process ${processes_list}) option(OGS_BUILD_PROCESS_${process} "Build the ${process} process." ON) endforeach() @@ -33,7 +33,7 @@ set(OGS_BUILD_PROCESSES "" CACHE STRING "Semicolon-separated list of processes to build") if(NOT OGS_BUILD_CLI) - set(OGS_BUILD_PROCESSES OFF "" CACHE INTERNAL "") + set(OGS_BUILD_PROCESSES OFF "" CACHE STRING "" FORCE) message(STATUS "ATTENTION: OGS_BUILD_CLI=OFF -> OGS_BUILD_PROCESSES is set to OFF too.\n" " If cli is switched on again, remember to switch processes back to on \n" " too with -DOGS_BUILD_PROCESSES=\"\"!") @@ -41,19 +41,19 @@ endif() if(NOT "${OGS_BUILD_PROCESSES}" STREQUAL "") if(${OGS_BUILD_PROCESSES}) foreach(process ${OGS_BUILD_PROCESSES}) - if(NOT "${process}" IN_LIST ProcessesList) + if(NOT "${process}" IN_LIST processes_list) message( FATAL_ERROR "${process} given in OGS_BUILD_PROCESSES is " - "not a valid process name! Valid names are ${ProcessesList}" - ) + "not a valid process name! Valid names are ${processes_list}" + ) endif() endforeach() message(STATUS "Enabled processes:") else() message(STATUS "All processes disabled.") endif() - foreach(process ${ProcessesList}) + foreach(process ${processes_list}) if("${process}" IN_LIST OGS_BUILD_PROCESSES) set(OGS_BUILD_PROCESS_${process} ON CACHE BOOL "" FORCE) message(STATUS " ${process}") diff --git a/scripts/cmake/ProjectSetup.cmake b/scripts/cmake/ProjectSetup.cmake index b45f501574c..49e93cae39c 100644 --- a/scripts/cmake/ProjectSetup.cmake +++ b/scripts/cmake/ProjectSetup.cmake @@ -3,14 +3,15 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR} set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) if(OGS_USE_CONAN AND MSVC) - foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) - string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) - endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES) + foreach(outputconfig ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER ${outputconfig} outputconfig) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${outputconfig} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${outputconfig} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${outputconfig} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) + endforeach() endif() +# cmake-lint: disable=C0103 set(Data_SOURCE_DIR ${PROJECT_SOURCE_DIR}/Tests/Data CACHE INTERNAL "") set(Data_BINARY_DIR ${PROJECT_BINARY_DIR}/Tests/Data CACHE INTERNAL "") @@ -21,13 +22,13 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) # RPATH setup if(APPLE) - set(basePoint @loader_path) + set(BASEPOINT @loader_path) else() - set(basePoint $ORIGIN) + set(BASEPOINT $ORIGIN) endif() file(RELATIVE_PATH relDir ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR} ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR} ) -set(CMAKE_INSTALL_RPATH ${basePoint} ${basePoint}/${relDir}) +set(CMAKE_INSTALL_RPATH ${BASEPOINT} ${BASEPOINT}/${relDir}) set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) diff --git a/scripts/cmake/packaging/Pack.cmake b/scripts/cmake/packaging/Pack.cmake index 729350aef06..b9d4a04659e 100644 --- a/scripts/cmake/packaging/Pack.cmake +++ b/scripts/cmake/packaging/Pack.cmake @@ -1,4 +1,4 @@ -if(IS_SUBPROJECT) +if(_IS_SUBPROJECT) include (CPack) return() endif() @@ -76,7 +76,6 @@ if(OGS_USE_PYTHON) endif() endif() - configure_file(Documentation/README.txt.in ${PROJECT_BINARY_DIR}/README.txt) install(FILES ${PROJECT_BINARY_DIR}/README.txt DESTINATION .) diff --git a/scripts/cmake/packaging/PackagingLinux.cmake b/scripts/cmake/packaging/PackagingLinux.cmake index c4434906174..d5c4ecf17d4 100644 --- a/scripts/cmake/packaging/PackagingLinux.cmake +++ b/scripts/cmake/packaging/PackagingLinux.cmake @@ -26,7 +26,7 @@ else() endif() endif() -set(README_PLATFORM_INSTRUCTIONS +set(_README_PLATFORM_INSTRUCTIONS "When running the Data Explorer make sure to set the LD_LIBRARY_PATH path to the bin-folder. E.g.: LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./ ./DataExplorer" CACHE INTERNAL "" ) diff --git a/scripts/cmake/test/AddTest.cmake b/scripts/cmake/test/AddTest.cmake index 3535241b249..5cfe96d33ea 100644 --- a/scripts/cmake/test/AddTest.cmake +++ b/scripts/cmake/test/AddTest.cmake @@ -50,7 +50,7 @@ # Can be given multiple times; the point coordinates in the gml files are # compared using the given absolute and relative tolerances. # ~~~ - +# cmake-lint: disable=C0103 function (AddTest) # parse arguments @@ -59,7 +59,6 @@ function (AddTest) set(multiValueArgs EXECUTABLE_ARGS DATA DIFF_DATA WRAPPER_ARGS REQUIREMENTS PYTHON_PACKAGES VIS) cmake_parse_arguments(AddTest "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - set(AddTest_SOURCE_PATH "${Data_SOURCE_DIR}/${AddTest_PATH}") set(AddTest_BINARY_PATH "${Data_BINARY_DIR}/${AddTest_PATH}") file(MAKE_DIRECTORY ${AddTest_BINARY_PATH}) diff --git a/scripts/cmake/test/AddTestTester.cmake b/scripts/cmake/test/AddTestTester.cmake index 7b9ff26d2f0..0771cc66dc1 100644 --- a/scripts/cmake/test/AddTestTester.cmake +++ b/scripts/cmake/test/AddTestTester.cmake @@ -1,9 +1,9 @@ # Run vtk.js converter if(VIS_FILES AND VTKJS_CONVERTER) execute_process(COMMAND cmake -E make_directory ${VTKJS_OUTPUT_PATH}) - foreach(FILE ${VIS_FILES}) + foreach(file ${VIS_FILES}) execute_process( - COMMAND ${VTKJS_CONVERTER} -e -i ${BINARY_PATH}/${FILE} -o ${VTKJS_OUTPUT_PATH} + COMMAND ${VTKJS_CONVERTER} -e -i ${BINARY_PATH}/${file} -o ${VTKJS_OUTPUT_PATH} ) endforeach() endif() @@ -16,30 +16,30 @@ else() set(TERMINAL_CMD bash -c) endif() set(TEST_FAILED FALSE) -foreach(CMD ${TESTER_COMMAND}) +foreach(cmd ${TESTER_COMMAND}) if(GLOB_MODE) - separate_arguments(CMD) - list(GET CMD 0 GLOB) - list(GET CMD 1 NAME_A) - list(GET CMD 2 NAME_B) - list(GET CMD 3 ABS_TOL) - list(GET CMD 4 REL_TOL) + separate_arguments(cmd NATIVE_COMMAND) + list(GET cmd 0 GLOB) + list(GET cmd 1 NAME_A) + list(GET cmd 2 NAME_B) + list(GET cmd 3 ABS_TOL) + list(GET cmd 4 REL_TOL) file(GLOB FILES RELATIVE ${SOURCE_PATH} ${GLOB}) - list(LENGTH FILES length) - message(STATUS "Glob expression '${GLOB}' (${NAME_A}) found ${length} files.") - if(${length} EQUAL 0) + list(LENGTH FILES LENGTH) + message(STATUS "Glob expression '${GLOB}' (${NAME_A}) found ${LENGTH} files.") + if(${LENGTH} EQUAL 0) message(FATAL_ERROR "DIFF_DATA glob expression '${GLOB}' " "did not match any files!") endif() - foreach(FILE ${FILES}) + foreach(file ${FILES}) if("$ENV{HOSTNAME}" MATCHES "frontend.*") - string(REPLACE "gpfs1" "../.." FILE ${FILE}) + string(REPLACE "gpfs1" "../.." file ${file}) endif() if("$ENV{HOSTNAME}" MATCHES "frontend.*") - string(REPLACE "gpfs0" "../.." FILE ${FILE}) + string(REPLACE "gpfs0" "../.." file ${file}) endif() execute_process( - COMMAND ${SELECTED_DIFF_TOOL_PATH} ${SOURCE_PATH}/${FILE} ${BINARY_PATH}/${FILE} -a ${NAME_A} -b ${NAME_B} --abs ${ABS_TOL} --rel ${REL_TOL} + COMMAND ${SELECTED_DIFF_TOOL_PATH} ${SOURCE_PATH}/${file} ${BINARY_PATH}/${file} -a ${NAME_A} -b ${NAME_B} --abs ${ABS_TOL} --rel ${REL_TOL} WORKING_DIRECTORY ${SOURCE_PATH} RESULT_VARIABLE EXIT_CODE OUTPUT_VARIABLE OUTPUT @@ -53,7 +53,7 @@ foreach(CMD ${TESTER_COMMAND}) endforeach() else() execute_process( - COMMAND ${TERMINAL_CMD} "${CMD}" + COMMAND ${TERMINAL_CMD} "${cmd}" WORKING_DIRECTORY ${SOURCE_PATH} RESULT_VARIABLE EXIT_CODE OUTPUT_VARIABLE OUTPUT diff --git a/scripts/cmake/test/AddTestWrapper.cmake b/scripts/cmake/test/AddTestWrapper.cmake index c8d801d698c..3d06833ab07 100644 --- a/scripts/cmake/test/AddTestWrapper.cmake +++ b/scripts/cmake/test/AddTestWrapper.cmake @@ -1,7 +1,7 @@ # IMPORTANT: multiple arguments in one variables have to be in list notation (;) # and have to be quoted when passed "-DEXECUTABLE_ARGS=${AddTest_EXECUTABLE_ARGS}" -foreach(FILE ${FILES_TO_DELETE}) - file(REMOVE ${BINARY_PATH}/${FILE}) +foreach(file ${FILES_TO_DELETE}) + file(REMOVE ${BINARY_PATH}/${file}) endforeach() string(REPLACE ";" " " CMD_STRING "cd ${WORKING_DIRECTORY} && ${WRAPPER_COMMAND} " diff --git a/scripts/cmake/test/MeshTest.cmake b/scripts/cmake/test/MeshTest.cmake index d18380cd78a..7a81eda1190 100644 --- a/scripts/cmake/test/MeshTest.cmake +++ b/scripts/cmake/test/MeshTest.cmake @@ -17,7 +17,7 @@ # values should be taken from envinf1 serial job # ) # ~~~ - +# cmake-lint: disable=C0103 function (MeshTest) if(NOT OGS_BUILD_TESTING) return() @@ -28,7 +28,6 @@ function (MeshTest) set(multiValueArgs EXECUTABLE_ARGS DATA DIFF_DATA WRAPPER_ARGS REQUIREMENTS) cmake_parse_arguments(MeshTest "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - set(MeshTest_SOURCE_PATH "${Data_SOURCE_DIR}/${MeshTest_PATH}") set(MeshTest_BINARY_PATH "${Data_BINARY_DIR}/${MeshTest_PATH}") file(MAKE_DIRECTORY ${MeshTest_BINARY_PATH}) diff --git a/scripts/cmake/test/OgsTest.cmake b/scripts/cmake/test/OgsTest.cmake index efc854e1698..9b44e38c9b6 100644 --- a/scripts/cmake/test/OgsTest.cmake +++ b/scripts/cmake/test/OgsTest.cmake @@ -1,3 +1,4 @@ +# cmake-lint: disable=C0103 function (OgsTest) if(NOT OGS_BUILD_CLI OR NOT OGS_BUILD_TESTING) -- GitLab