Skip to content

Commit e942172

Browse files
Build - Vendor the CMinpack dependency.
This embeds the CMinpack code directly into mmSolverLibs, and makes it part of the library. mmSolver uses and should always use the cminpack_wrapper.h, so there's no need to change any of the mmSolver code.
1 parent 0952355 commit e942172

45 files changed

Lines changed: 13615 additions & 102 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/thirdparty/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
# Building third-party projects.
2020
#
2121

22+
add_subdirectory(cminpack)
2223
add_subdirectory(eigen)
2324
add_subdirectory(openMVG)
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Copyright (C) 2025 David Cattermole.
2+
#
3+
# This file is part of mmSolver.
4+
#
5+
# mmSolver is free software: you can redistribute it and/or modify it
6+
# under the terms of the GNU Lesser General Public License as
7+
# published by the Free Software Foundation, either version 3 of the
8+
# License, or (at your option) any later version.
9+
#
10+
# mmSolver is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU Lesser General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU Lesser General Public License
16+
# along with mmSolver. If not, see <https://www.gnu.org/licenses/>.
17+
# ---------------------------------------------------------------------
18+
#
19+
# CMake build for vendored CMinpack (version 1.3.8)
20+
#
21+
# This is a simplified build of CMinpack, configured for use with mmSolver.
22+
# It only builds the double precision version needed by mmSolver.
23+
#
24+
25+
set(CMINPACK_VERSION "1.3.8")
26+
set(CMINPACK_SOVERSION "1")
27+
28+
# Define the source files for CMinpack
29+
set(CMINPACK_SOURCE_FILES
30+
# Headers
31+
cminpack.h
32+
cminpackP.h
33+
minpack.h
34+
35+
# Double precision C source files
36+
chkder.c
37+
covar.c
38+
covar1.c
39+
dogleg.c
40+
dpmpar.c
41+
enorm.c
42+
fdjac1.c
43+
fdjac2.c
44+
hybrd.c
45+
hybrd1.c
46+
hybrj.c
47+
hybrj1.c
48+
lmder.c
49+
lmder1.c
50+
lmdif.c
51+
lmdif1.c
52+
lmpar.c
53+
lmstr.c
54+
lmstr1.c
55+
qform.c
56+
qrfac.c
57+
qrsolv.c
58+
r1mpyq.c
59+
r1updt.c
60+
rwupdt.c
61+
)
62+
63+
# Create the cminpack static library
64+
add_library(cminpack_s STATIC ${CMINPACK_SOURCE_FILES})
65+
66+
# Set library properties
67+
set_target_properties(cminpack_s PROPERTIES
68+
VERSION ${CMINPACK_VERSION}
69+
SOVERSION ${CMINPACK_SOVERSION}
70+
)
71+
72+
# Configure include directories
73+
target_include_directories(cminpack_s PUBLIC
74+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
75+
$<INSTALL_INTERFACE:include/cminpack-1>
76+
)
77+
78+
# Configure compile definitions
79+
target_compile_definitions(cminpack_s PUBLIC
80+
CMINPACK_PRECISION=d # Double precision
81+
)
82+
83+
# Windows-specific configuration
84+
if(WIN32)
85+
target_compile_definitions(cminpack_s PUBLIC
86+
CMINPACK_NO_DLL
87+
)
88+
endif()
89+
90+
# Set position independent code if needed
91+
if(CMAKE_POSITION_INDEPENDENT_CODE)
92+
set_target_properties(cminpack_s PROPERTIES
93+
POSITION_INDEPENDENT_CODE ON
94+
)
95+
endif()
96+
97+
# Create an alias to match the expected target name
98+
add_library(cminpack::cminpack ALIAS cminpack_s)
99+
100+
# Install headers
101+
install(FILES
102+
cminpack.h
103+
minpack.h
104+
DESTINATION include/cminpack-1
105+
)
106+
107+
# Install the library as part of mmsolverlibs
108+
include(MMCommonUtils)
109+
mm_common_install_target_library("mmsolverlibs_cpp" cminpack_s)
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
Minpack Copyright Notice (1999) University of Chicago. All rights reserved
2+
3+
Redistribution and use in source and binary forms, with or
4+
without modification, are permitted provided that the
5+
following conditions are met:
6+
7+
1. Redistributions of source code must retain the above
8+
copyright notice, this list of conditions and the following
9+
disclaimer.
10+
11+
2. Redistributions in binary form must reproduce the above
12+
copyright notice, this list of conditions and the following
13+
disclaimer in the documentation and/or other materials
14+
provided with the distribution.
15+
16+
3. The end-user documentation included with the
17+
redistribution, if any, must include the following
18+
acknowledgment:
19+
20+
"This product includes software developed by the
21+
University of Chicago, as Operator of Argonne National
22+
Laboratory.
23+
24+
Alternately, this acknowledgment may appear in the software
25+
itself, if and wherever such third-party acknowledgments
26+
normally appear.
27+
28+
4. WARRANTY DISCLAIMER. THE SOFTWARE IS SUPPLIED "AS IS"
29+
WITHOUT WARRANTY OF ANY KIND. THE COPYRIGHT HOLDER, THE
30+
UNITED STATES, THE UNITED STATES DEPARTMENT OF ENERGY, AND
31+
THEIR EMPLOYEES: (1) DISCLAIM ANY WARRANTIES, EXPRESS OR
32+
IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES
33+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE
34+
OR NON-INFRINGEMENT, (2) DO NOT ASSUME ANY LEGAL LIABILITY
35+
OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR
36+
USEFULNESS OF THE SOFTWARE, (3) DO NOT REPRESENT THAT USE OF
37+
THE SOFTWARE WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS, (4)
38+
DO NOT WARRANT THAT THE SOFTWARE WILL FUNCTION
39+
UNINTERRUPTED, THAT IT IS ERROR-FREE OR THAT ANY ERRORS WILL
40+
BE CORRECTED.
41+
42+
5. LIMITATION OF LIABILITY. IN NO EVENT WILL THE COPYRIGHT
43+
HOLDER, THE UNITED STATES, THE UNITED STATES DEPARTMENT OF
44+
ENERGY, OR THEIR EMPLOYEES: BE LIABLE FOR ANY INDIRECT,
45+
INCIDENTAL, CONSEQUENTIAL, SPECIAL OR PUNITIVE DAMAGES OF
46+
ANY KIND OR NATURE, INCLUDING BUT NOT LIMITED TO LOSS OF
47+
PROFITS OR LOSS OF DATA, FOR ANY REASON WHATSOEVER, WHETHER
48+
SUCH LIABILITY IS ASSERTED ON THE BASIS OF CONTRACT, TORT
49+
(INCLUDING NEGLIGENCE OR STRICT LIABILITY), OR OTHERWISE,
50+
EVEN IF ANY OF SAID PARTIES HAS BEEN WARNED OF THE
51+
POSSIBILITY OF SUCH LOSS OR DAMAGES.
52+
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# CMinpack - C/C++ Minpack
2+
3+
CMinpack provides nonlinear equation solving and nonlinear least squares
4+
optimization algorithms and is required for building mmSolver. CMinpack
5+
is used as a fallback solver when Ceres Solver is not available or for
6+
specific legacy solver algorithms.
7+
8+
This directory contains a copy of the complete CMinpack source code
9+
plus CMake build scripts that have been written for mmSolver.
10+
11+
The goal of this vendoring was to eliminate the need to download and
12+
build external dependencies during the mmSolver build process, ensuring
13+
a consistent and reproducible build environment.
14+
15+
Another goal was to reduce build complexity and ensure that mmSolver
16+
can be built offline without internet connectivity.
17+
18+
## Source Repository
19+
20+
This project was copied from the following location:
21+
22+
**Page:** https://github.com/devernay/cminpack
23+
**Documentation:** http://devernay.github.io/cminpack
24+
**Git URL:** https://github.com/devernay/cminpack.git
25+
**Git Tag:** v1.3.8
26+
**Git Commit:** cb7c3f6 (prepare for 1.3.8 release)
27+
28+
## Copied Files
29+
30+
The following files have been copied without modification:
31+
32+
```
33+
cminpack/CopyrightMINPACK.txt
34+
cminpack/README.md
35+
cminpack/cminpack.h
36+
cminpack/cminpackP.h
37+
cminpack/minpack.h
38+
cminpack/chkder.c
39+
cminpack/covar.c
40+
cminpack/covar1.c
41+
cminpack/dogleg.c
42+
cminpack/dpmpar.c
43+
cminpack/enorm.c
44+
cminpack/fdjac1.c
45+
cminpack/fdjac2.c
46+
cminpack/hybrd.c
47+
cminpack/hybrd1.c
48+
cminpack/hybrj.c
49+
cminpack/hybrj1.c
50+
cminpack/lmder.c
51+
cminpack/lmder1.c
52+
cminpack/lmdif.c
53+
cminpack/lmdif1.c
54+
cminpack/lmpar.c
55+
cminpack/lmstr.c
56+
cminpack/lmstr1.c
57+
cminpack/qform.c
58+
cminpack/qrfac.c
59+
cminpack/qrsolv.c
60+
cminpack/r1mpyq.c
61+
cminpack/r1updt.c
62+
cminpack/rwupdt.c
63+
```
64+
65+
## Build Configuration
66+
67+
This vendored version is configured to:
68+
69+
- Build only the double precision version (CMINPACK_PRECISION=d)
70+
- Create a static library (cminpack_s)
71+
- Disable BLAS/LAPACK dependencies for simplicity
72+
- Use position-independent code when required
73+
- Support Windows and Linux builds
74+
- Provide the expected cminpack::cminpack target alias
75+
76+
## Notes
77+
78+
- The original CMinpack supports single, double, and extended precision variants
79+
- This vendored version only builds the double precision variant needed by mmSolver
80+
- The underscore variants (e.g., chkder_.c) are not included as they are FORTRAN-style interfaces
81+
- Examples, tests, and documentation from the original repository are not included
82+
- The vendored version is designed to integrate seamlessly with mmSolver's build system
83+
84+
## License
85+
86+
CMinpack is distributed under a BSD-like license. See `CopyrightMINPACK.txt` for full license text.
87+
88+
## Authors
89+
90+
- Original FORTRAN MINPACK: Jorge Moré, Burt Garbow, Ken Hillstrom (Argonne National Laboratory)
91+
- C/C++ port: Manolis Lourakis (2002)
92+
- Maintenance and improvements: Frédéric Devernay
93+
- mmSolver integration: David Cattermole

0 commit comments

Comments
 (0)