From f079f68ececc4286ca58e9ebacdbfd7a3ab03370 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Fri, 6 Sep 2024 16:10:14 -0400 Subject: [PATCH] complete user cmake example --- doc/{user_CMakeLists.cmake => CMakeLists.txt} | 5 +++-- doc/mylibrary.cpp | 9 +++++++++ doc/mylibrary.h | 4 ++++ doc/myprogram.cpp | 10 ++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) rename doc/{user_CMakeLists.cmake => CMakeLists.txt} (90%) create mode 100644 doc/mylibrary.cpp create mode 100644 doc/mylibrary.h create mode 100644 doc/myprogram.cpp diff --git a/doc/user_CMakeLists.cmake b/doc/CMakeLists.txt similarity index 90% rename from doc/user_CMakeLists.cmake rename to doc/CMakeLists.txt index a83281340..c218c4632 100644 --- a/doc/user_CMakeLists.cmake +++ b/doc/CMakeLists.txt @@ -31,8 +31,9 @@ else() endif() #this is just example code, do your own thing -add_executable(mylibrary mylibrary.cpp) +add_library(mylibrary mylibrary.cpp) add_executable(myprogram myprogram.cpp) +target_include_directories(myprogram PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) #for any targets that use PUMI, just use this command #to it to include the right directories and link to all @@ -40,4 +41,4 @@ add_executable(myprogram myprogram.cpp) #we recommend PUBLIC if the target is a library and #PRIVATE if the target is an executable target_link_libraries(mylibrary PUBLIC SCOREC::core) -target_link_libraries(myprogram PRIVATE SCOREC::core) +target_link_libraries(myprogram PRIVATE mylibrary) diff --git a/doc/mylibrary.cpp b/doc/mylibrary.cpp new file mode 100644 index 000000000..e20dbf63a --- /dev/null +++ b/doc/mylibrary.cpp @@ -0,0 +1,9 @@ +#include +#include +#include +#include +void makeMesh() { + gmi_register_mesh(); + apf::Mesh2* m = apf::makeMdsBox(1,1,1,1,1,1,0); + apf::destroyMesh(m); +} diff --git a/doc/mylibrary.h b/doc/mylibrary.h new file mode 100644 index 000000000..655125a61 --- /dev/null +++ b/doc/mylibrary.h @@ -0,0 +1,4 @@ +#ifndef MYLIBRARY_H +#define MYLIBRARH_H +void makeMesh(); +#endif diff --git a/doc/myprogram.cpp b/doc/myprogram.cpp new file mode 100644 index 000000000..1049a50b3 --- /dev/null +++ b/doc/myprogram.cpp @@ -0,0 +1,10 @@ +#include +#include "mylibrary.h" +int main(int argc, char** argv) { + MPI_Init(&argc,&argv); + PCU_Comm_Init(); + makeMesh(); + PCU_Comm_Free(); + MPI_Finalize(); + return 0; +}