122 lines
3.2 KiB
Diff
122 lines
3.2 KiB
Diff
diff -Naur a/CMakeLists.txt b/CMakeLists.txt
|
|
--- a/CMakeLists.txt 1969-12-31 21:00:00.000000000 -0300
|
|
+++ b/CMakeLists.txt 2024-04-16 12:10:12.082969997 -0300
|
|
@@ -0,0 +1,116 @@
|
|
+cmake_minimum_required(VERSION 3.13)
|
|
+
|
|
+# The default build type must be set
|
|
+# right after cmake_minimum_required
|
|
+# to take effect
|
|
+if (NOT DEFINED CMAKE_BUILD_TYPE)
|
|
+ set(CMAKE_BUILD_TYPE "Release")
|
|
+endif()
|
|
+
|
|
+# set the package version
|
|
+if (NOT DEFINED MINPACK_VERSION)
|
|
+ SET(MINPACK_VERSION "1.0.0")
|
|
+endif()
|
|
+
|
|
+project(minpack
|
|
+ VERSION ${MINPACK_VERSION}
|
|
+ LANGUAGES Fortran
|
|
+)
|
|
+
|
|
+# Build shared libraries by default
|
|
+if (NOT DEFINED BUILD_SHARED_LIBS)
|
|
+ set(BUILD_SHARED_LIBS ON)
|
|
+endif()
|
|
+
|
|
+# Also build static libraries by default
|
|
+if (NOT DEFINED BUILD_STATIC_LIBS)
|
|
+ set(BUILD_STATIC_LIBS ON)
|
|
+endif()
|
|
+
|
|
+# assert that at least one kind
|
|
+# of library was requested to build
|
|
+if (NOT (BUILD_SHARED_LIBS OR BUILD_STATIC_LIBS))
|
|
+ message(FATAL_ERROR "You must configure cmake to build either the shared or static library by setting -DBUILD_SHARED_LIBS=ON or -DBUILD_STATIC_LIBS=ON, respectively.")
|
|
+endif()
|
|
+
|
|
+# Fortran source files for minpack
|
|
+set(minpack_source_files
|
|
+ "chkder.f"
|
|
+ "dogleg.f"
|
|
+ "dpmpar.f"
|
|
+ "enorm.f"
|
|
+ "fdjac1.f"
|
|
+ "fdjac2.f"
|
|
+ "hybrd1.f"
|
|
+ "hybrd.f"
|
|
+ "hybrj1.f"
|
|
+ "hybrj.f"
|
|
+ "lmder1.f"
|
|
+ "lmder.f"
|
|
+ "lmdif1.f"
|
|
+ "lmdif.f"
|
|
+ "lmpar.f"
|
|
+ "lmstr1.f"
|
|
+ "lmstr.f"
|
|
+ "qform.f"
|
|
+ "qrfac.f"
|
|
+ "qrsolv.f"
|
|
+ "r1mpyq.f"
|
|
+ "r1updt.f"
|
|
+ "rwupdt.f"
|
|
+)
|
|
+
|
|
+# library name
|
|
+set(minpack_library_name "minpack")
|
|
+
|
|
+# minpack header file
|
|
+set(minpack_header "minpack.h")
|
|
+
|
|
+# minpack pkg-config input file to be transformed
|
|
+set(minpack_pkg_config_in "cmake-${minpack_library_name}.pc.in")
|
|
+
|
|
+# minpack pkg-config destination file
|
|
+set(minpack_pkg_config "${CMAKE_CURRENT_BINARY_DIR}/${minpack_library_name}.pc")
|
|
+
|
|
+# use GNU directories convention
|
|
+include(GNUInstallDirs)
|
|
+
|
|
+# Build the shared library
|
|
+if (BUILD_SHARED_LIBS)
|
|
+ add_library(minpack_shared SHARED "")
|
|
+ target_sources(minpack_shared PRIVATE ${minpack_source_files})
|
|
+ target_compile_definitions(minpack_shared PRIVATE DLL_EXPORT)
|
|
+
|
|
+ set_target_properties(minpack_shared
|
|
+ PROPERTIES
|
|
+ POSITION_INDEPENDENT_CODE ON
|
|
+ OUTPUT_NAME ${minpack_library_name}
|
|
+ )
|
|
+
|
|
+ install(TARGETS minpack_shared
|
|
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
|
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
+ )
|
|
+endif()
|
|
+
|
|
+# Build the static library
|
|
+if (BUILD_STATIC_LIBS)
|
|
+ add_library(minpack_static STATIC "")
|
|
+ target_sources(minpack_static PRIVATE ${minpack_source_files})
|
|
+
|
|
+ set_target_properties(minpack_static
|
|
+ PROPERTIES
|
|
+ OUTPUT_NAME ${minpack_library_name}
|
|
+ )
|
|
+
|
|
+ install(TARGETS minpack_static
|
|
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
|
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
+ )
|
|
+endif()
|
|
+
|
|
+configure_file(${minpack_pkg_config_in} ${minpack_pkg_config} @ONLY)
|
|
+install(FILES ${minpack_pkg_config} DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
|
+install(FILES ${minpack_header} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
|
\ No newline at end of file
|