From 2f14d416c1ae8bc646ff82c3a2f0faa4905ef504 Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Wed, 31 May 2023 17:48:44 -0600 Subject: [PATCH 1/4] cmake: build example as part of tests --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e6d9562..2f2c7d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,6 +62,7 @@ if (LIBECPINT_BUILD_TESTS) include(external/ImportGTest.cmake) enable_testing() add_subdirectory(tests) + add_subdirectory(example) endif() option(LIBECPINT_BUILD_DOCS "Enables Libecpint documentation." ON) From b24f78ab6a4e68e3dc6a77bf74be4e613f38f862 Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Wed, 31 May 2023 17:58:34 -0600 Subject: [PATCH 2/4] cmake: fix linking of example --- example/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 1d77253..8cfc21d 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -6,7 +6,7 @@ project( LibecpintExample LANGUAGES CXX) add_executable(example example.cpp) -target_link_libraries(example PRIVATE ecpint Faddeeva pugixml) +target_link_libraries(example PRIVATE ecpint) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/iodine.bas DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/hydrogen.bas From 4def2b24c429dd63f72fc9d25da2d38dc9355647 Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Wed, 31 May 2023 18:17:32 -0600 Subject: [PATCH 3/4] cmake: export HAS_PUGIXML into target --- example/CMakeLists.txt | 1 + src/CMakeLists.txt | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 8cfc21d..1c94dfe 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -6,6 +6,7 @@ project( LibecpintExample LANGUAGES CXX) add_executable(example example.cpp) +find_package(ecpint) target_link_libraries(example PRIVATE ecpint) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/iodine.bas DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4da25e3..33c49d6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -87,6 +87,10 @@ endif() # ========= install(TARGETS ecpint EXPORT ecpintTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}) +if (LIBECPINT_USE_PUGIXML) + # used in api.h + target_compile_definitions(ecpint PUBLIC HAS_PUGIXML) +endif() include(CMakePackageConfigHelpers) # Version file write_basic_package_version_file( From ef5d7748651c80355b885569d89c6abf0806225d Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Wed, 31 May 2023 23:19:21 -0600 Subject: [PATCH 4/4] cmake: add example as a test --- example/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 1c94dfe..e00f4a7 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -6,10 +6,12 @@ project( LibecpintExample LANGUAGES CXX) add_executable(example example.cpp) -find_package(ecpint) target_link_libraries(example PRIVATE ecpint) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/iodine.bas DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/hydrogen.bas DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +add_test(NAME example + COMMAND example + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})