From d4b989745719a08324df2fed00e7bd98b522452b Mon Sep 17 00:00:00 2001 From: Jonathan Frey Date: Tue, 26 Mar 2024 14:46:46 +0100 Subject: [PATCH 1/3] free memory in C examples --- examples/c/c_dense_example.c | 4 ++++ examples/c/c_sparse_example.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/examples/c/c_dense_example.c b/examples/c/c_dense_example.c index 05c500d..2843c99 100644 --- a/examples/c/c_dense_example.c +++ b/examples/c/c_dense_example.c @@ -53,5 +53,9 @@ int main() printf("status = %d\n", status); printf("x = %f %f\n", work->result->x[0], work->result->x[1]); + piqp_cleanup(work); + free(settings); + free(data); + return 0; } diff --git a/examples/c/c_sparse_example.c b/examples/c/c_sparse_example.c index cd0eeb7..d066bd3 100644 --- a/examples/c/c_sparse_example.c +++ b/examples/c/c_sparse_example.c @@ -62,5 +62,9 @@ int main() printf("status = %d\n", status); printf("x = %f %f\n", work->result->x[0], work->result->x[1]); + piqp_cleanup(work); + free(settings); + free(data); + return 0; } From 060829dc25ded55417db8a335334a8c3cc253152 Mon Sep 17 00:00:00 2001 From: Jonathan Frey Date: Tue, 26 Mar 2024 14:50:48 +0100 Subject: [PATCH 2/3] add BUILD_EXAMPLES in Cmake --- CMakeLists.txt | 5 +++++ examples/CMakeLists.txt | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 22b6ac0..d26977d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,7 @@ option(BUILD_MATLAB_INTERFACE "Build Matlab interface" OFF) #### Tests/Benchmarks options #### option(BUILD_TESTS "Build tests" ON) +option(BUILD_EXAMPLES "Build examples" ON) option(BUILD_MAROS_MESZAROS_TEST "Build maros meszaros tests" OFF) option(BUILD_BENCHMARKS "Build benchmarks" OFF) @@ -200,6 +201,10 @@ if (BUILD_BENCHMARKS) add_subdirectory(benchmarks) endif() +if (BUILD_EXAMPLES) + add_subdirectory(examples) +endif() + install( DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 8939c0b..c15acf9 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -11,7 +11,7 @@ project(piqp_examples) set(CMAKE_CXX_STANDARD 14) -find_package(piqp REQUIRED) +# find_package(piqp REQUIRED) add_subdirectory(c) add_subdirectory(cpp) From 62c0e1dfdacc72c46f2eb9053da4e1854fdb83e5 Mon Sep 17 00:00:00 2001 From: Roland Schwan Date: Wed, 27 Mar 2024 10:36:37 +0100 Subject: [PATCH 3/3] fix ci --- examples/CMakeLists.txt | 4 +++- interfaces/matlab/make_piqp.m | 3 ++- setup.py | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index c15acf9..7c81eea 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -13,5 +13,7 @@ set(CMAKE_CXX_STANDARD 14) # find_package(piqp REQUIRED) -add_subdirectory(c) +if (BUILD_C_INTERFACE) + add_subdirectory(c) +endif() add_subdirectory(cpp) diff --git a/interfaces/matlab/make_piqp.m b/interfaces/matlab/make_piqp.m index 343f7cd..c083bd2 100644 --- a/interfaces/matlab/make_piqp.m +++ b/interfaces/matlab/make_piqp.m @@ -63,6 +63,7 @@ function make_piqp(varargin) '-DBUILD_C_INTERFACE=OFF ' ... '-DBUILD_MATLAB_INTERFACE=ON ' ... '-DBUILD_TESTS=OFF ' ... + '-DBUILD_EXAMPLES=OFF ' ... '-DBUILD_BENCHMARKS=OFF']; % Add specific generators for windows linux or mac @@ -138,7 +139,7 @@ function make_piqp(varargin) % Setup directory and copy files pkg_name = sprintf('piqp-matlab-%s64', platform); - if exist(pkg_name, 'dir') + if exist(fullfile(piqp_matlab_dir, pkg_name), 'dir') rmdir(pkg_name, 's'); end mkdir(pkg_name); diff --git a/setup.py b/setup.py index 5dc5d8f..ecbdd47 100644 --- a/setup.py +++ b/setup.py @@ -59,6 +59,7 @@ def build_extension(self, ext: CMakeExtension) -> None: f"-DBUILD_PYTHON_INTERFACE=ON", f"-DBUILD_C_INTERFACE=OFF", f"-DBUILD_TESTS=OFF", + f"-DBUILD_EXAMPLES=OFF", f"-DBUILD_BENCHMARKS=OFF", f"-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=true" ]