Skip to content

Commit

Permalink
complete user cmake example
Browse files Browse the repository at this point in the history
  • Loading branch information
cwsmith committed Sep 6, 2024
1 parent c5ab193 commit f079f68
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
5 changes: 3 additions & 2 deletions doc/user_CMakeLists.cmake → doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ 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
#the scorec libraries automatically.
#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)
9 changes: 9 additions & 0 deletions doc/mylibrary.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <gmi_mesh.h>
#include <apfBox.h>
#include <apfMesh2.h>
#include <apf.h>
void makeMesh() {
gmi_register_mesh();
apf::Mesh2* m = apf::makeMdsBox(1,1,1,1,1,1,0);
apf::destroyMesh(m);
}
4 changes: 4 additions & 0 deletions doc/mylibrary.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#ifndef MYLIBRARY_H
#define MYLIBRARH_H
void makeMesh();
#endif
10 changes: 10 additions & 0 deletions doc/myprogram.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <PCU.h>
#include "mylibrary.h"
int main(int argc, char** argv) {
MPI_Init(&argc,&argv);
PCU_Comm_Init();
makeMesh();
PCU_Comm_Free();
MPI_Finalize();
return 0;
}

0 comments on commit f079f68

Please sign in to comment.