From f2f401c260eabcfaa9d4b03217a2477b8fe3262b Mon Sep 17 00:00:00 2001 From: Valentin Seitz Date: Sat, 25 May 2024 11:08:34 +0200 Subject: [PATCH 1/2] move tests files a bit --- tests/CMakeLists.txt | 22 +++++++++++++++++++-- tests/{integration => }/c/CMakeLists.txt | 0 tests/{integration => }/c/test-c.c | 0 tests/{integration => }/cpp/TestCppLink.cpp | 0 4 files changed, 20 insertions(+), 2 deletions(-) rename tests/{integration => }/c/CMakeLists.txt (100%) rename tests/{integration => }/c/test-c.c (100%) rename tests/{integration => }/cpp/TestCppLink.cpp (100%) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c1c6d27..253ed3a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,7 +1,25 @@ -add_executable(TestCppLink integration/cpp/TestCppLink.cpp) +add_executable(TestCppLink cpp/TestCppLink.cpp) target_link_libraries(TestCppLink sit) target_include_directories(TestCppLink PRIVATE ${SIT_API_INCLUDES}) + add_test(NAME TestCppLink - COMMAND TestCppLink) \ No newline at end of file + COMMAND TestCppLink) + + + +add_executable(TestFortranLink fortran/TestFortranModule.f90) +target_link_libraries(TestFortranLink sit sit_f) +target_include_directories(TestFortranLink + PRIVATE ${SIT_API_INCLUDES}) + +target_include_directories(TestFortranLink + PRIVATE ${CMAKE_BINARY_DIR}/include) + + + +add_test(NAME TestFortranLink + COMMAND TestFortranLink) + + \ No newline at end of file diff --git a/tests/integration/c/CMakeLists.txt b/tests/c/CMakeLists.txt similarity index 100% rename from tests/integration/c/CMakeLists.txt rename to tests/c/CMakeLists.txt diff --git a/tests/integration/c/test-c.c b/tests/c/test-c.c similarity index 100% rename from tests/integration/c/test-c.c rename to tests/c/test-c.c diff --git a/tests/integration/cpp/TestCppLink.cpp b/tests/cpp/TestCppLink.cpp similarity index 100% rename from tests/integration/cpp/TestCppLink.cpp rename to tests/cpp/TestCppLink.cpp -- GitLab From aa5033576c65b38cf880dd3ab84b8adba05c1e8d Mon Sep 17 00:00:00 2001 From: Valentin Seitz Date: Sat, 25 May 2024 11:08:56 +0200 Subject: [PATCH 2/2] Add fortran functionality --- CMakeLists.txt | 37 ++++++++++++++++++++++++++--- sit.yaml | 11 +++++++++ tests/fortran/TestFortranModule.f90 | 5 ++++ 3 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 sit.yaml create mode 100644 tests/fortran/TestFortranModule.f90 diff --git a/CMakeLists.txt b/CMakeLists.txt index bed5335..fcb4dbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,12 +17,43 @@ set(SIT_API_INCLUDES ${PROJECT_SOURCE_DIR}/include) target_include_directories(sit PRIVATE ${SIT_API_INCLUDES}) -include(GenerateExportHeader) -generate_export_header(sit) +add_subdirectory(src) + +if(EXISTS ${SHROUD_EXECUTABLE}) + execute_process(COMMAND ${SHROUD_EXECUTABLE} + --cmake ${CMAKE_CURRENT_BINARY_DIR}/SetupShroud.cmake + ERROR_VARIABLE SHROUD_cmake_error + OUTPUT_STRIP_TRAILING_WHITESPACE ) + if(${SHROUD_cmake_error}) + message(FATAL_ERROR "Error from Shroud: ${SHROUD_cmake_error}") + endif() + include(${CMAKE_CURRENT_BINARY_DIR}/SetupShroud.cmake) + add_shroud( + YAML_INPUT_FILE sit.yaml + C_FORTRAN_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR} + ) + + set_source_files_properties(wrap${_basename}.cpp PROPERTIES GENERATED TRUE) + set_source_files_properties(wrapf${_basename}.f PROPERTIES GENERATED TRUE) + set(CMAKE_Fortran_FORMAT FREE) + + + + add_library(${_basename}_f STATIC wrapf${_basename}.f wrap${_basename}.cpp ${LIB_SRC}) + + target_include_directories(${_basename}_f PRIVATE ${SIT_API_INCLUDES}) + target_include_directories(${_basename}_f PRIVATE ${LIB_INC}) + + set_target_properties(${_basename}_f PROPERTIES LINKER_LANGUAGE Fortran) + set_target_properties(${_basename}_f PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) + set_target_properties(${_basename}_f PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include) + + add_dependencies(${_basename}_f generate_${_basename}) +endif() + -add_subdirectory(src) enable_testing() diff --git a/sit.yaml b/sit.yaml new file mode 100644 index 0000000..67af98d --- /dev/null +++ b/sit.yaml @@ -0,0 +1,11 @@ +library: sit +namespace: sit +cxx_header: sit.hpp +format: + C_prefix: '' + +declarations: +- decl: void init(const std::string &backend) +- decl: void region_start(const std::string &name) +- decl: void region_stop(const std::string &name) +- decl: void finalize() \ No newline at end of file diff --git a/tests/fortran/TestFortranModule.f90 b/tests/fortran/TestFortranModule.f90 new file mode 100644 index 0000000..9194e19 --- /dev/null +++ b/tests/fortran/TestFortranModule.f90 @@ -0,0 +1,5 @@ +program do_sample + use sit_mod + call init("Default") + call region_start("test") +end program do_sample \ No newline at end of file -- GitLab