From 43f8214fbb6e627d9a11c35ddb942b4971e0a060 Mon Sep 17 00:00:00 2001 From: Tang-U-b Date: Tue, 29 Aug 2023 22:33:22 +0200 Subject: [PATCH] modify cmake --- ...dening.hpp => inelastic_solid_hardening.h} | 2 +- .../xj_stretching/CMakeLists.txt | 32 +++++++++++++++---- tests/user_examples/xj_stretching/run_test.sh | 2 ++ .../xj_stretching/xj_stretching.cpp | 2 +- 4 files changed, 29 insertions(+), 9 deletions(-) rename tests/user_examples/extra_src/shared/{inelastic_solid_hardening.hpp => inelastic_solid_hardening.h} (99%) create mode 100644 tests/user_examples/xj_stretching/run_test.sh diff --git a/tests/user_examples/extra_src/shared/inelastic_solid_hardening.hpp b/tests/user_examples/extra_src/shared/inelastic_solid_hardening.h similarity index 99% rename from tests/user_examples/extra_src/shared/inelastic_solid_hardening.hpp rename to tests/user_examples/extra_src/shared/inelastic_solid_hardening.h index c5eb49a874..e0c2cda74b 100644 --- a/tests/user_examples/extra_src/shared/inelastic_solid_hardening.hpp +++ b/tests/user_examples/extra_src/shared/inelastic_solid_hardening.h @@ -21,7 +21,7 @@ * * * ------------------------------------------------------------------------- */ /** - * @file inelastic_solid_hardening.hpp + * @file inelastic_solid_hardening.h * @brief These are classes for define properties of elastic solid materials. * These classes are based on isotropic linear elastic solid. * Several more complex materials, including neo-hookean, FENE noe-hookean diff --git a/tests/user_examples/xj_stretching/CMakeLists.txt b/tests/user_examples/xj_stretching/CMakeLists.txt index f9bb76775e..7434f894db 100644 --- a/tests/user_examples/xj_stretching/CMakeLists.txt +++ b/tests/user_examples/xj_stretching/CMakeLists.txt @@ -1,17 +1,35 @@ -STRING(REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # main (top) cmake dir + +set(CMAKE_VERBOSE_MAKEFILE on) + +STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) PROJECT("${CURRENT_FOLDER}") -SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) SET(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin/") +SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) SET(BUILD_INPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/input") SET(BUILD_RELOAD_PATH "${EXECUTABLE_OUTPUT_PATH}/reload") + + + -add_executable(${PROJECT_NAME}) aux_source_directory(. DIR_SRCS) -target_sources(${PROJECT_NAME} PRIVATE ${DIR_SRCS}) +ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) + +target_link_libraries(${PROJECT_NAME} sphinxsys_2d GTest::gtest GTest::gtest_main) target_link_libraries(${PROJECT_NAME} extra_sources_2d) + set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") -add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) + +if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") + add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) + add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +else() + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh + DESTINATION ${EXECUTABLE_OUTPUT_PATH}) + add_test(NAME ${PROJECT_NAME} COMMAND bash ${EXECUTABLE_OUTPUT_PATH}/run_test.sh + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +endif() diff --git a/tests/user_examples/xj_stretching/run_test.sh b/tests/user_examples/xj_stretching/run_test.sh new file mode 100644 index 0000000000..8aaa13ab55 --- /dev/null +++ b/tests/user_examples/xj_stretching/run_test.sh @@ -0,0 +1,2 @@ +./xj_stretching --r=true +./xj_stretching --r=false --i=true diff --git a/tests/user_examples/xj_stretching/xj_stretching.cpp b/tests/user_examples/xj_stretching/xj_stretching.cpp index e5f2595056..7233b7e595 100644 --- a/tests/user_examples/xj_stretching/xj_stretching.cpp +++ b/tests/user_examples/xj_stretching/xj_stretching.cpp @@ -7,7 +7,7 @@ * internal constrained subregion. * * ----------------------------------------------------------------------------*/ #include "sphinxsys.h" -#include "inelastic_solid_hardening.hpp" +#include "inelastic_solid_hardening.h" using namespace SPH; //------------------------------------------------------------------------------