Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions coin-or/qpOASES/releases/3.2.1/QpOASES_llar.gox
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import "os"
import "slices"

id "coin-or/qpOASES"

fromVer "releases/3.2.1"

// qpOASES exposes a single, package-owned build choice worth translating:
// the Conan recipe's `fPIC` option (default True, dropped on Windows).
// It maps to CMAKE_POSITION_INDEPENDENT_CODE for the static library.
defaults {
"fPIC": "ON",
}

// Position-independent code is meaningless on Windows, which is exactly why
// the Conan recipe deletes the fPIC option there. Reject fPIC=ON on Windows.
filter => {
if slices.contains(target.require["os"], "windows") {
return slices.contains(target.options["fPIC"], "OFF")

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[High] The default Windows matrix is rejected — this contradicts the stated intent and blocks the default Windows build.

defaults sets fPIC: "ON", so a plain Windows build has target.options["fPIC"] == ["ON"]. This branch then returns slices.contains(["ON"], "OFF")false, which rejects the entire effective matrix (a false filter stops before dependency discovery). So llar make on Windows with default options cannot build at all — a consumer must explicitly pass fPIC=OFF.

The comment says this "matches the Conan recipe," but Conan's del self.options.fPIC on Windows removes the option so the build proceeds normally without any fPIC input — it does not require fPIC=OFF. The reference guidance is to use filter only to reject a selection "proved unsupported by the source"; fPIC=ON is not unsupported (CMake simply ignores CMAKE_POSITION_INDEPENDENT_CODE on Windows).

Suggested fix: drop the OS special-case in filter (return true on Windows) and, if desired, gate only the c.defineBool "CMAKE_POSITION_INDEPENDENT_CODE" call on non-Windows — rather than failing the matrix on its own default value.

}
return true
}

onBuild ctx => {
installDir := ctx.outputDir

c := cmake.new(ctx.SourceDir, ctx.SourceDir+"/_build", installDir)
c.buildType "Release"
// Upstream declares cmake_minimum_required(VERSION 2.6); modern CMake
// refuses that compatibility floor without an explicit policy version.
c.define "CMAKE_POLICY_VERSION_MINIMUM", "3.5"

// Match the Conan recipe: build only the library, not the examples.
c.defineBool "QPOASES_BUILD_EXAMPLES", false

// Carry over the fPIC option for the static library.
c.defineBool "CMAKE_POSITION_INDEPENDENT_CODE", slices.contains(target.options["fPIC"], "ON")

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Medium] The fPIC option value isn't validated. On non-Windows the filter accepts any value unconditionally, and this line maps fPIC via slices.contains(target.options["fPIC"], "ON"). If a user passes e.g. fPIC=true, the check is false and the build silently produces a non-PIC library instead of rejecting the invalid request. Consider validating the fPIC value in filter so unsupported spellings are rejected rather than silently reinterpreted.


c.configure
c.build
c.install

// Installed interface: static lib libqpOASES.a in lib/, headers in
// include/ (qpOASES.hpp + the qpOASES/ directory).
ctx.setMetadata "-lqpOASES"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Low] Consumer metadata likely omits paths a consumer needs. setMetadata "-lqpOASES" provides only the link name — a consumer compiling against qpOASES also needs the header include path and library search path (e.g. -I{install}/include -L{install}/lib). Per the metadata guidance, include install-directory paths when consumers need them (LLAR rewrites the prefix to its portable placeholder at install time). Note the onTest below passing does not prove this metadata is complete: it locates the headers/lib via tc.use installDir + find_path/find_library, not via this metadata string. Please confirm a bare consumer using only -lqpOASES can actually compile and link.

}

onTest ctx => {
installDir := ctx.outputDir

// Consumer check derived from the Conan test_package: include the public
// header and construct/solve a QProblem against the installed library.
// Built in an independent tree so onTest also passes on a cache hit,
// where onBuild (and its _build dir) never ran.
testDir := ctx.SourceDir + "/_qpoases_test"
os.mkdirAll(testDir, 0o755)!

consumer := `#include <qpOASES.hpp>

int main()
{
USING_NAMESPACE_QPOASES

// 2 variables, 1 constraint (mirrors the Conan test_package problem).
real_t H[2*2] = { 1.0, 0.0, 0.0, 0.5 };
real_t A[1*2] = { 1.0, 1.0 };
real_t g[2] = { 1.5, 1.0 };
real_t lb[2] = { 0.5, -2.0 };
real_t ub[2] = { 5.0, 2.0 };
real_t lbA[1] = { -1.0 };
real_t ubA[1] = { 2.0 };

QProblem example( 2, 1 );

Options options;
example.setOptions( options );

int_t nWSR = 10;
returnValue rv = example.init( H, g, A, lb, ub, lbA, ubA, nWSR );

return ( rv == SUCCESSFUL_RETURN ) ? 0 : 1;
}
`
os.writeFile(testDir+"/consumer.cpp", []byte(consumer), 0o644)!

cml := `cmake_minimum_required(VERSION 3.5)
project(qpoases_consumer CXX)
add_executable(consumer consumer.cpp)
find_path(QPOASES_INCLUDE_DIR NAMES qpOASES.hpp REQUIRED)
find_library(QPOASES_LIB NAMES qpOASES REQUIRED)
target_include_directories(consumer PRIVATE ${QPOASES_INCLUDE_DIR})
target_link_libraries(consumer PRIVATE ${QPOASES_LIB})
`
os.writeFile(testDir+"/CMakeLists.txt", []byte(cml), 0o644)!

testBuild := testDir + "/_build"
tc := cmake.new(testDir, testBuild, "")
tc.buildType "Release"
tc.define "CMAKE_POLICY_VERSION_MINIMUM", "3.5"
tc.use installDir

tc.configure
tc.build

// Run the freshly built consumer. A non-zero exit surfaces via lastErr.
exec testBuild + "/consumer"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Low] Platform-assuming executable path. exec testBuild + "/consumer" assumes a POSIX executable name; on Windows the artifact is consumer.exe. This is currently masked because the default Windows matrix is rejected by filter, but if that filter issue is fixed to allow Windows, this test path will break. Worth making the consumer path platform-aware or documenting the test as non-Windows only.

if lastErr != nil {
panic lastErr
}
}
4 changes: 4 additions & 0 deletions coin-or/qpOASES/versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"path": "coin-or/qpOASES",
"deps": {}
}
Loading