From 3b980fd5eeadd638874dfe03801c4c15926882c6 Mon Sep 17 00:00:00 2001 From: Alexey Sheplyakov Date: Mon, 6 Jan 2020 22:34:09 +0400 Subject: [PATCH] Build example programs to avoid breaking them on API changes --- doc/examples/CMakeLists.txt | 22 ++++++++++++++++++++++ doc/examples/Makefile.am | 27 +++++++++++++++++++++++++++ doc/examples/archive1.cpp | 6 +++++- doc/examples/compile1.cpp | 5 ++++- doc/examples/compile2.cpp | 4 ++++ doc/examples/compile3.cpp | 5 ++++- doc/examples/derivative.cpp | 4 ++++ doc/examples/mystring.cpp | 6 ++++-- 8 files changed, 74 insertions(+), 5 deletions(-) diff --git a/doc/examples/CMakeLists.txt b/doc/examples/CMakeLists.txt index 851c61ce..afdc67d2 100644 --- a/doc/examples/CMakeLists.txt +++ b/doc/examples/CMakeLists.txt @@ -1 +1,23 @@ add_info_file(ginac-examples) + +add_definitions(-DIN_GINAC) +include_directories(${CMAKE_SOURCE_DIR}/ginac ${CMAKE_BUILD_DIR}/ginac) + +add_executable(archive1 archive1.cpp) +target_link_libraries(archive1 ginac ${LIBDL_LIBRARIES}) + +add_executable(compile1 compile1.cpp) +target_link_libraries(compile1 ginac ${LIBDL_LIBRARIES}) + +# XXX: compile2 example uses the Cuba library (http://www.feynarts.de/cuba) +# add_executable(compile2 compile2.cpp) +# target_link_libraries(compile2 ginac ${LIBDL_LIBRARIES}) + +add_executable(compile3 compile3.cpp) +target_link_libraries(compile3 ginac ${LIBDL_LIBRARIES}) + +add_executable(mystring mystring.cpp) +target_link_libraries(mystring ginac ${LIBDL_LIBRARIES}) + +add_executable(derivative derivative.cpp) +target_link_libraries(derivative ginac ${LIBDL_LIBRARIES}) diff --git a/doc/examples/Makefile.am b/doc/examples/Makefile.am index 472a2a16..9c66c731 100644 --- a/doc/examples/Makefile.am +++ b/doc/examples/Makefile.am @@ -17,3 +17,30 @@ all: $(EXFILES) CLEANFILES = $(TXT) $(HTML) EXTRA_DIST = $(EXFILES) CMakeLists.txt + +AM_CPPFLAGS = -I$(srcdir)/../../ginac -I../../ginac -DIN_GINAC + +noinst_PROGRAMS = archive1 \ + compile1 \ + compile3 \ + mystring \ + derivative + +archive1_SOURCES = archive1.cpp +archive1_LDADD = ../../ginac/libginac.la + +compile1_SOURCES = compile1.cpp +compile1_LDADD = ../../ginac/libginac.la + +# compile2 example uses the Cuba library: (http://www.feynarts.de) +# compile2_SOURCES = compile2.cpp +# compile2_LDADD = ../../ginac/libginac.la + +compile3_SOURCES = compile3.cpp +compile3_LDADD = ../../ginac/libginac.la + +mystring_SOURCES = mystring.cpp +mystring_LDADD = ../../ginac/libginac.la + +derivative_SOURCES = derivative.cpp +derivative_LDADD = ../../ginac/libginac.la diff --git a/doc/examples/archive1.cpp b/doc/examples/archive1.cpp index cf55ee5a..611a15dc 100644 --- a/doc/examples/archive1.cpp +++ b/doc/examples/archive1.cpp @@ -3,8 +3,12 @@ */ #include -#include +#ifdef IN_GINAC +#include "ginac.h" +#else +#include +#endif using namespace std; using namespace GiNaC; diff --git a/doc/examples/compile1.cpp b/doc/examples/compile1.cpp index b92dc766..69827251 100644 --- a/doc/examples/compile1.cpp +++ b/doc/examples/compile1.cpp @@ -1,7 +1,10 @@ #include #include +#ifdef IN_GINAC +#include "ginac.h" +#else #include - +#endif using namespace std; using namespace GiNaC; diff --git a/doc/examples/compile2.cpp b/doc/examples/compile2.cpp index 960bbed9..0854e722 100644 --- a/doc/examples/compile2.cpp +++ b/doc/examples/compile2.cpp @@ -1,5 +1,9 @@ #include +#ifdef IN_GINAC +#include "ginac.h" +#else #include +#endif // Yes, we are using CUBA (should be installed on the system!) #include diff --git a/doc/examples/compile3.cpp b/doc/examples/compile3.cpp index b92df53f..c0e5209f 100644 --- a/doc/examples/compile3.cpp +++ b/doc/examples/compile3.cpp @@ -1,7 +1,10 @@ #include #include +#ifdef IN_GINAC +#include "ginac.h" +#else #include - +#endif using namespace std; using namespace GiNaC; diff --git a/doc/examples/derivative.cpp b/doc/examples/derivative.cpp index c1a09b99..3b845c05 100644 --- a/doc/examples/derivative.cpp +++ b/doc/examples/derivative.cpp @@ -5,7 +5,11 @@ #include #include #include +#ifdef IN_GINAC +#include "ginac.h" +#else #include +#endif using namespace std; using namespace GiNaC; diff --git a/doc/examples/mystring.cpp b/doc/examples/mystring.cpp index 640f81eb..655fe825 100644 --- a/doc/examples/mystring.cpp +++ b/doc/examples/mystring.cpp @@ -4,9 +4,11 @@ #include #include #include - +#ifdef IN_GINAC +#include "ginac.h" +#else #include - +#endif using namespace std; using namespace GiNaC; -- 2.44.0