Hello Adriana,
I apologize for late response. The simple fix would be to add source to cmake function dd_build_and_install
, i.e.
### build and install
# function definition for building
function(dd_build_and_install target source)
bfe_add_executable(${target} ${source} PATH/DiffusionClassic.cpp)
target_link_libraries(${target}
users_modules
mofem_finite_elements
mofem_interfaces
mofem_multi_indices
mofem_petsc
mofem_approx
mofem_third_party
${MoFEM_PROJECT_LIBS})
install(TARGETS ${target} DESTINATION ${MODULE_NAME})
endfunction(dd_build_and_install)
Only question what is path, typically, for cpp lib files it is,
src/impl/DiffusionClassic.cpp
Another option is to make library, but I think that above solution is sufficient at this point.
L.
Hi all,Lukasz's answer gives only a part of the solution to your issue.In general, you should not have the main function in the cpp file which has definitions of member functions of some class. The idea of incapsulation is that the definition of the class is separated from a function that creates an object of this class and works with it.You can have a look at a diagram at the beginning of this article: https://makefiletutorial.comWhat follows after in that article is the introduction to makefiles, which could be useful as well.One way of encapsulating your class (h and cpp files) is creating a library, as Lukasz mentioned above. In fact, I think this is the solution that would be most useful for your code. You can look into this tutorial on Cmake, in particular, Step 2 (Adding a library) as it covers a similar case: https://cmake.org/cmake/help/latest/guide/tutorialRegards,Andrei