|
From: <kin...@us...> - 2025-09-12 07:51:40
|
Revision: 7417
http://sourceforge.net/p/teem/code/7417
Author: kindlmann
Date: 2025-09-12 07:51:39 +0000 (Fri, 12 Sep 2025)
Log Message:
-----------
more consistency tweaks (and adding ability to require dependency version)
Modified Paths:
--------------
teem/trunk/CMake/FindFFTW3-v2.cmake
teem/trunk/CMake/FindLEVMAR-v2.cmake
teem/trunk/CMakeLists-v2.txt
Modified: teem/trunk/CMake/FindFFTW3-v2.cmake
===================================================================
--- teem/trunk/CMake/FindFFTW3-v2.cmake 2025-09-12 06:07:42 UTC (rev 7416)
+++ teem/trunk/CMake/FindFFTW3-v2.cmake 2025-09-12 07:51:39 UTC (rev 7417)
@@ -23,26 +23,26 @@
set(_dep "FFTW3")
# Option to enable extra debug output from this module
-option(Teem_${_dep}_DEBUG "Print detailed debug about finding ${_dep}" OFF)
+option(Teem_DEBUG_${_dep} "Print detailed debug about finding ${_dep}" OFF)
-# Helper macros to print only when Teem_${_dep}_DEBUG is enabled
+# Helper macros to print only when Teem_DEBUG_${_dep} is enabled
macro(_status msg)
- if(Teem_${_dep}_DEBUG)
+ if(Teem_DEBUG_${_dep})
message(STATUS "[Find${_dep}] ${msg}")
endif()
endmacro()
macro(_check_start msg)
- if(Teem_${_dep}_DEBUG)
+ if(Teem_DEBUG_${_dep})
message(CHECK_START "[Find${_dep}] ${msg}")
endif()
endmacro()
macro(_check_fail msg)
- if(Teem_${_dep}_DEBUG)
+ if(Teem_DEBUG_${_dep})
message(CHECK_FAIL "${msg}")
endif()
endmacro()
macro(_check_pass msg)
- if(Teem_${_dep}_DEBUG)
+ if(Teem_DEBUG_${_dep})
message(CHECK_PASS "${msg}")
endif()
endmacro()
@@ -89,7 +89,7 @@
# HEY no INTERFACE_LINK_LIBRARIES ?
)
endif()
- _check_pass("Found: ${_dep}_INCLUDE_DIR=${${_dep}_INCLUDE_DIR} ${_dep}_LIBRARY=${${_dep}_LIBRARY}")
+ _check_pass("Found:\n ${_dep}_INCLUDE_DIR=${${_dep}_INCLUDE_DIR}\n ${_dep}_LIBRARY=${${_dep}_LIBRARY}")
else()
_check_fail("Not found")
endif()
Modified: teem/trunk/CMake/FindLEVMAR-v2.cmake
===================================================================
--- teem/trunk/CMake/FindLEVMAR-v2.cmake 2025-09-12 06:07:42 UTC (rev 7416)
+++ teem/trunk/CMake/FindLEVMAR-v2.cmake 2025-09-12 07:51:39 UTC (rev 7417)
@@ -3,14 +3,6 @@
# Copyright (C) 2025 University of Chicago
# See ../LICENSE.txt for licensing terms
-# TODO:
-# how is cmake detecting of this levmar also needs lapack and blas?
-# how does find_package(LAPACK/BLAS QUIET) work? is that CMake built-in?
-# check hints to find_path and find_library
-# make sure we're getting the right version of levmar
-# BUILD_SHARED_LIBS with liblevmar.a: [ 96%] Linking C shared library libteem.dylib
-# ld: warning: ignoring duplicate libraries: '-ldl', '-lm', '/Users/gk/src/levmar-2.6/liblevmar.a'
-
# This module defines:
# LEVMAR_FOUND - True if both header and library were found
# LEVMAR_INCLUDE_DIR - Directory containing levmar.h
@@ -26,26 +18,26 @@
set(_dep "LEVMAR")
# Option to enable extra debug output from this module
-option(Teem_${_dep}_DEBUG "Print detailed debug about finding ${_dep}" OFF)
+option(Teem_DEBUG_${_dep} "Print detailed debug about finding ${_dep}" OFF)
-# Helper macros to print only when Teem_${_dep}_DEBUG is enabled
+# Helper macros to print only when Teem_DEBUG_${_dep} is enabled
macro(_status msg)
- if(Teem_${_dep}_DEBUG)
+ if(Teem_DEBUG_${_dep})
message(STATUS "[Find${_dep}] ${msg}")
endif()
endmacro()
macro(_check_start msg)
- if(Teem_${_dep}_DEBUG)
+ if(Teem_DEBUG_${_dep})
message(CHECK_START "[Find${_dep}] ${msg}")
endif()
endmacro()
macro(_check_fail msg)
- if(Teem_${_dep}_DEBUG)
+ if(Teem_DEBUG_${_dep})
message(CHECK_FAIL "${msg}")
endif()
endmacro()
macro(_check_pass msg)
- if(Teem_${_dep}_DEBUG)
+ if(Teem_DEBUG_${_dep})
message(CHECK_PASS "${msg}")
endif()
endmacro()
@@ -55,33 +47,62 @@
find_path(LEVMAR_INCLUDE_DIR
NAMES levmar.h
HINTS
- ${CMAKE_INSTALL_PREFIX}/include
- /usr/include
- /usr/local/include
+ $ENV{LEVMAR_DIR}
+ ${CMAKE_INSTALL_PREFIX}
+ /usr
+ /usr/local
PATH_SUFFIXES
include
- levmar
+ include/levmar
DOC "Directory containing levmar.h"
)
_status("find_path result: LEVMAR_INCLUDE_DIR='${LEVMAR_INCLUDE_DIR}'")
+# Learn the levmar version number from levmar.h. Versions 2.4 and prior didn't have a
+# levmar.h; they had lm.h, so failing to find levmar.h is one brute-force way to enforce
+# that we're looking at a version >= 2.5. Version 2.5 has:
+# #define LM_VERSION "2.5 (December 2009)"
+# and Version 2.6 has:
+# #define LM_VERSION "2.6 (November 2011)"
+# To learn the version from levmar.h:
+if(LEVMAR_INCLUDE_DIR AND EXISTS "${LEVMAR_INCLUDE_DIR}/levmar.h")
+ file(READ "${LEVMAR_INCLUDE_DIR}/levmar.h" _levmar_header)
+
+ # Match e.g.: #define LM_VERSION "2.6 (November 2011)"
+ # https://cmake.org/cmake/help/latest/command/string.html
+ # sets CMAKE_MATCH_<N> for the N'th parethesized subexpression
+ string(REGEX MATCH "#define[ \t]+LM_VERSION[ \t]+\"([0-9]+\\.[0-9]+)" _match "${_levmar_header}")
+
+ if(CMAKE_MATCH_1)
+ set(LEVMAR_VERSION "${CMAKE_MATCH_1}")
+ _status("From levmar.h parsed version: ${LEVMAR_VERSION}")
+ endif()
+endif()
+
# Try to find full path to liblevmar library file
find_library(LEVMAR_LIBRARY
NAMES levmar
HINTS
- ${CMAKE_INSTALL_PREFIX}/lib
- /usr/lib
- /usr/local/lib
+ $ENV{LEVMAR_DIR}
+ ${CMAKE_INSTALL_PREFIX}
+ /usr
+ /usr/local
PATH_SUFFIXES
lib
+ lib64
DOC "Full path to the liblevmar.\{a\|so\|dylib\|lib\} file"
)
_status("find_library result: LEVMAR_LIBRARY='${LEVMAR_LIBRARY}'")
-# If we found the library but levmar depends on LAPACK and BLAS, try to find them.
-# Levmar's docs advise having LAPACK/BLAS available to use the full feature set.
-# (This is optional — we don't fail if LAPACK isn't present.)
-if(LEVMAR_LIBRARY) # HEY is this conditional useful?
+# If we found the library but levmar *may* depend in turn on LAPACK and BLAS (more levmar
+# functions are available that way), so we try to find them using their built-in CMake
+# modules. It's not that CMake can detect now whether the levmar found indeed depends on
+# LAPACK and BLAS; we just try to find them if we did find levmar. And we don't if
+# LAPACK or BLAS are not found, but if they are required for this levmar, then we may
+# have linker error later.
+if(LEVMAR_LIBRARY)
+ _status("Looking for LAPACK & BLAS (may trigger Threads find)")
+ # if we didn't find LEVMAR, no point in looking for LAPACK, BLAS
find_package(LAPACK QUIET)
if(LAPACK_FOUND)
_status("LAPACK found: ${LAPACK_LIBRARIES}")
@@ -103,6 +124,8 @@
# Standard handling macro: sets LEVMAR_FOUND if successful
find_package_handle_standard_args(LEVMAR
REQUIRED_VARS LEVMAR_INCLUDE_DIR LEVMAR_LIBRARY
+ # report to caller of find_package(LEVMAR) what version they're getting
+ VERSION_VAR LEVMAR_VERSION
)
if(LEVMAR_FOUND)
@@ -127,7 +150,7 @@
INTERFACE_LINK_LIBRARIES "${LEVMAR_LIBRARIES}"
)
endif()
- _check_pass("Found: ${_dep}_INCLUDE_DIR=${${_dep}_INCLUDE_DIR} ${_dep}_LIBRARY=${${_dep}_LIBRARY}")
+ _check_pass("Found:\n ${_dep}_INCLUDE_DIR=${${_dep}_INCLUDE_DIR}\n ${_dep}_LIBRARY=${${_dep}_LIBRARY}")
else()
_check_fail("Not found")
endif()
Modified: teem/trunk/CMakeLists-v2.txt
===================================================================
--- teem/trunk/CMakeLists-v2.txt 2025-09-12 06:07:42 UTC (rev 7416)
+++ teem/trunk/CMakeLists-v2.txt 2025-09-12 07:51:39 UTC (rev 7417)
@@ -55,8 +55,7 @@
** Please join the Teem-users Discord https://discord.gg/xBBqZGXkF7
** to share how Teem works or does not work for you!
** For example, are these re-written CMakeLists.txt files working?
-********************************************************************
-")
+********************************************************************")
###-------------------------------------------------------------------------------------
# Include helpers and module paths
@@ -176,8 +175,11 @@
set(_Teem_dep_llink_ZLIB "-lz")
set(_Teem_dep_llink_BZIP2 "-lbz2")
set(_Teem_dep_llink_PTHREAD "-pthread")
+# Special cases for requiring specific version (else "" for no such requirement)
+# (HEY should better document here what versions the Teem code is assuming)
+set(_Teem_dep_version_LEVMAR "2.6")
-# Make sure _Teem_dep_{cpack,target,found,llink}_DEP are defined for all DEPS
+# Make sure _Teem_dep_{cpack,target,found,llink,version}_DEP are defined for all DEPS
# CMake (still) doesn't have anything like a dictionary, so we don't have
# (for example): _Teem_dep_cpname[_tdep]
# but after the following, we do have: ${_Teem_dep_cpname_${_tdep}}
@@ -195,6 +197,9 @@
string(TOLOWER ${_tdep} _dep_lc)
set(_Teem_dep_llink_${_tdep} "-l${_dep_lc}")
endif()
+ if(NOT DEFINED _Teem_dep_version_${_tdep})
+ set(_Teem_dep_version_${_tdep} "")
+ endif()
endforeach()
# With all that uniformity set up: try to find_package() for all DEPs requested,
@@ -202,11 +207,20 @@
foreach(_tdep IN LISTS _Teem_DEPS)
if(Teem_USE_${_tdep})
# this DEP is requested
- message(STATUS "Trying find_package(${_Teem_dep_cpname_${_tdep}})")
- find_package(${_Teem_dep_cpname_${_tdep}} QUIET)
+ message(CHECK_START "Trying find_package( ${_Teem_dep_cpname_${_tdep}} ${_Teem_dep_version_${_tdep}})")
+ find_package(${_Teem_dep_cpname_${_tdep}} ${_Teem_dep_version_${_tdep}} QUIET)
if(${_Teem_dep_found_${_tdep}})
set(Teem_HAVE_${_tdep} TRUE)
+ message(CHECK_PASS "Found")
else()
+ if(DEFINED ${_tdep}_VERSION AND _Teem_dep_version_${_tdep})
+ message(CHECK_FAIL
+ "Found ${_tdep} version ${${_tdep}_VERSION}, "
+ "but version ${_Teem_dep_version_${_tdep}} or newer is required."
+ )
+ else()
+ message(CHECK_FAIL "Not found")
+ endif()
set(Teem_USE_${_tdep} OFF CACHE BOOL "${_Teem_dep_doc_${_tdep}}" FORCE)
endif()
endif()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|