diff --git a/CMakeLists.txt b/CMakeLists.txt index bed53353872bb9603379e1d63b8bff2deaf6bb5a..fcb4dbde7a79348679b8701c7986c38e78ad4954 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 0000000000000000000000000000000000000000..67af98d3cc25c49b3ccee2d69962facc464d9be7 --- /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/CMakeLists.txt b/tests/CMakeLists.txt index c1c6d27f346a25cf89ae5ca1bd9ae8a06c9b6193..253ed3aba97a688845a45e1da412b6698fba4e16 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 diff --git a/tests/fortran/TestFortranModule.f90 b/tests/fortran/TestFortranModule.f90 new file mode 100644 index 0000000000000000000000000000000000000000..9194e19adf5c3774dc97f82c34721ebdadb82b70 --- /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