From e7dbf0f3f9ce19700865947518924a6f1b824a6d Mon Sep 17 00:00:00 2001 From: ahmadamine998 Date: Thu, 28 Jul 2022 14:15:01 -0400 Subject: [PATCH] Now propagates float and long flags to CMake via flags --- src/osqp/codegen/code_generator.py | 2 ++ src/osqp/codegen/files_to_generate/CMakeLists.txt | 4 ++-- src/osqp/codegen/utils.py | 8 ++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/osqp/codegen/code_generator.py b/src/osqp/codegen/code_generator.py index 5f91cf48..685859ae 100644 --- a/src/osqp/codegen/code_generator.py +++ b/src/osqp/codegen/code_generator.py @@ -116,6 +116,8 @@ def codegen(work, target_dir, python_ext_name, project_type, compile_python_ext, 'linsys_solver': work['linsys_solver'], 'scaling': work['scaling'], 'embedded_flag': embedded, + 'float_flag': float_flag, + 'long_flag': long_flag, 'python_ext_name': python_ext_name} # Add cmake args diff --git a/src/osqp/codegen/files_to_generate/CMakeLists.txt b/src/osqp/codegen/files_to_generate/CMakeLists.txt index 4ef05592..e4a3b8d9 100644 --- a/src/osqp/codegen/files_to_generate/CMakeLists.txt +++ b/src/osqp/codegen/files_to_generate/CMakeLists.txt @@ -55,11 +55,11 @@ endif() message(STATUS "Profiling is ${PROFILING}") # Use floats instead of integers -option (DFLOAT "Use float numbers instead of doubles" OFF) +option (DFLOAT "Use float numbers instead of doubles" FLOAT_FLAG) message(STATUS "Floats are ${DFLOAT}") # Use long integers for indexing -option (DLONG "Use long integers (64bit) for indexing" ON) +option (DLONG "Use long integers (64bit) for indexing" LONG_FLAG) if (NOT (CMAKE_SIZEOF_VOID_P EQUAL 8)) message(STATUS "Disabling long integers (64bit) on 32bit machine") set(DLONG OFF) diff --git a/src/osqp/codegen/utils.py b/src/osqp/codegen/utils.py index 27c7900b..39dc4457 100644 --- a/src/osqp/codegen/utils.py +++ b/src/osqp/codegen/utils.py @@ -475,6 +475,8 @@ def render_setuppy(variables, output): """ embedded_flag = variables['embedded_flag'] + float_flag = variables['float_flag'] + long_flag = variables['long_flag'] python_ext_name = variables['python_ext_name'] f = open(os.path.join(files_to_generate_path, 'setup.py')) @@ -482,6 +484,8 @@ def render_setuppy(variables, output): f.close() filedata = filedata.replace("EMBEDDED_FLAG", str(embedded_flag)) + filedata = filedata.replace("FLOAT_FLAG", str(float_flag)) + filedata = filedata.replace("LONG_FLAG", str(long_flag)) filedata = filedata.replace("PYTHON_EXT_NAME", str(python_ext_name)) f = open(output, 'w') @@ -495,12 +499,16 @@ def render_cmakelists(variables, output): """ embedded_flag = variables['embedded_flag'] + float_flag = variables['float_flag'] + long_flag = variables['long_flag'] f = open(os.path.join(files_to_generate_path, 'CMakeLists.txt')) filedata = f.read() f.close() filedata = filedata.replace("EMBEDDED_FLAG", str(embedded_flag)) + filedata = filedata.replace("FLOAT_FLAG", str(float_flag)) + filedata = filedata.replace("LONG_FLAG", str(long_flag)) f = open(output, 'w') f.write(filedata)