|
From: <kin...@us...> - 2025-09-03 18:28:18
|
Revision: 7348
http://sourceforge.net/p/teem/code/7348
Author: kindlmann
Date: 2025-09-03 18:28:14 +0000 (Wed, 03 Sep 2025)
Log Message:
-----------
further tweaks
Modified Paths:
--------------
teem/trunk/CMakeLists-10.txt
Modified: teem/trunk/CMakeLists-10.txt
===================================================================
--- teem/trunk/CMakeLists-10.txt 2025-09-03 17:45:42 UTC (rev 7347)
+++ teem/trunk/CMakeLists-10.txt 2025-09-03 18:28:14 UTC (rev 7348)
@@ -19,7 +19,7 @@
# along with this library; if not, see <https://www.gnu.org/licenses/>.
#
-# Teem/CMakeLists.txt Version 10.8
+# Teem/CMakeLists.txt Version 10.85
# Re-written entirely for TeemV2
#-----------------------------------------------------------------------------
@@ -102,8 +102,8 @@
endforeach()
# Other options
-option(Teem_BUILD_HEX "Build stand-alone raw<-->hex decoder/encoder" OFF)
-option(BUILD_TESTING "Build with (incomplete) Teem tests" OFF)
+option(Teem_BUILD_HEX_UTILS "Build stand-alone raw<-->hex decoder/encoder" OFF)
+option(BUILD_TESTING "Build with (in-progress) Teem tests" OFF)
option(Teem_INSTALL_VERSIONED_SUBDIRS "Install in Teem-X.Y subdir of install/{bin,lib,include}" OFF)
#-----------------------------------------------------------------------------
@@ -216,7 +216,7 @@
#-----------------------------------------------------------------------------
# Configure-time feature test: does AIR_EXISTS() work like isfinite()?
-# So much hassle for one dumb macro (which GLK started using before the functionally
+# A lot of work for one little macro (which GLK started using before the functionally
# equivalent isfinite() became widely available). The little CMake/TestAIR_EXISTS.c
# program tests the equivalent of AIR_EXISTS (but without directly using air.h's
# AIR_EXISTS because this has to be stand-alone), to see if it can correctly detect
@@ -223,8 +223,9 @@
# IEEE754 special values (NaNs and infinities). For this to be a useful test that informs
# how the rest of Teem code will work, TestAIR_EXISTS.c needs to be compiled the same as
# Teem itself will be compiled later. Sadly, it was not until Teem V2 that this
-# consistency was actually enforced (!) To futher help debugging, we also print out (via
-# message()) exactly how TestAIR_EXISTS.c is compiled.
+# consistency was actually enforced (!) To further help debugging, we also print out
+# exactly how TestAIR_EXISTS.c is compiled, and we use try_compile instead of try_run
+# so the resulting executable file stays available for later inspection.
#
# (rejected but interesting debugging strategies:
# message(STATUS "Pausing CMake so you can inspect temporary files...")
@@ -236,12 +237,10 @@
# "taex" = Test Air_EXists
set(_taex_src "${CMAKE_CURRENT_LIST_DIR}/CMake/TestAIR_EXISTS.c")
-# Combine base flags with build-type-specific flags
-string(TOUPPER "${CMAKE_BUILD_TYPE}" _taex_BTUC) # Build Type Upper Case
+# Build flags for the probe (same as Teem itself)
+string(TOUPPER "${CMAKE_BUILD_TYPE}" _taex_BTUC)
set(_taex_flags "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${_taex_BTUC}}")
-set(_taex_me "AIR_EXISTS macro (compiled with \"${_taex_flags}\")")
-message(STATUS "Test whether ${_taex_me} detects IEEE754 special values")
-message(STATUS " (compiling ${_taex_src} with CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} and CMAKE_C_FLAGS_${_taex_BTUC}=${CMAKE_C_FLAGS_${_taex_BTUC}})")
+set(_taex_me "AIR_EXISTS (compiled \"${_taex_flags}\")")
# Where we want a durable copy of the compiled probe
if(WIN32)
@@ -249,15 +248,14 @@
else()
set(_taex_copy "${CMAKE_BINARY_DIR}/TestAIR_EXISTS")
endif()
+
# Remove any stale copy from previous runs
if(EXISTS "${_taex_copy}")
file(REMOVE "${_taex_copy}")
endif()
-# We would use try_run except that try_run deletes everything it created before try_run
-# finishes, which robs us of the chance to later re-run the test program. So we first
-# try_compile and then execute_process.
-# https://cmake.org/cmake/help/v3.25/command/try_compile.html#try-compiling-source-files
+# Compile the probe
+message(CHECK_START "Testing whether macro ${_taex_me} detects IEEE754 special values")
try_compile(
_taex_compiles # boolean result: TRUE if compile succeeded
SOURCES "${_taex_src}" # one or more source files for the test
@@ -265,26 +263,31 @@
"-DCMAKE_VERBOSE_MAKEFILE=ON"
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
"-DCMAKE_C_FLAGS_${_taex_BTUC}=${_taex_flags}"
- "-DCMAKE_DEPENDS_USE_COMPILER=FALSE" # no -MD/-MT/-MF crap
+ "-DCMAKE_DEPENDS_USE_COMPILER=FALSE" # no -MD/-MT/-MF dependency cruft
+ COPY_FILE "${_taex_copy}" # copy the built executable to a stable path
OUTPUT_VARIABLE _taex_compile_out
- COPY_FILE "${_taex_copy}" # copy the built executable to a stable path
COPY_FILE_ERROR _taex_copy_error
)
+# Always show the captured compile output, as progress indication
+string(REPLACE "\n" "\n " _taex_compile_out_indented "${_taex_compile_out}")
+message(STATUS "Compile output:\n ${_taex_compile_out_indented}")
+
if(NOT _taex_compiles)
- message(FATAL_ERROR "Failed to compile ${_taex_src} so could not test AIR_EXISTS macro")
-endif()
-# Show the captured output
-message(STATUS "v.v.v.v.v.v.v.v.v.v Compile output for AIR_EXISTS macro test v.v.v.v.v.v.v.v.v.v\n${_taex_compile_out}\n^'^'^'^'^'^'^'^'^'^ End compile output ^'^'^'^'^'^'^'^'^'^")
-
-if(_taex_copy_error)
- message(FATAL_ERROR "Test program compiled but copy failed: ${_taex_copy_error}")
+ message(CHECK_FAIL "compile failed")
+ message(FATAL_ERROR "Could not compile ${_taex_src}")
+elseif(_taex_copy_error)
+ message(CHECK_FAIL "copy failed")
+ message(FATAL_ERROR "Test program compiled but could not copy: ${_taex_copy_error}")
elseif(NOT EXISTS "${_taex_copy}")
- message(FATAL_ERROR "Test program compiled but resulting file not found at ${_taex_copy}")
+ message(CHECK_FAIL "missing executable")
+ message(FATAL_ERROR "Test program compiled but file not found at ${_taex_copy}")
+else()
+ message(CHECK_PASS "compiled successfully")
endif()
-# Run the compiled test program
+# Run the test program
+message(CHECK_START "Running ${_taex_me} test program")
# https://cmake.org/cmake/help/latest/command/execute_process.html
-message(STATUS "Running test program ${_taex_copy}")
execute_process(
COMMAND "${_taex_copy}"
RESULT_VARIABLE _taex_run_status
@@ -292,12 +295,21 @@
ERROR_VARIABLE _taex_run_err
)
+# Act on the results
if(_taex_run_status EQUAL 0)
- message(STATUS "Yes, ${_taex_me} works to detect IEEE754 special values")
+ message(CHECK_PASS "Yes, it detects IEEE754 special values")
set(AIR_EXISTS_MACRO_FAILS 0 CACHE INTERNAL "AIR_EXISTS macro works correctly")
else()
- message(STATUS "NO, ${_taex_me} FAILS to detect IEEE754 special values")
- message(STATUS "Probe stderr:\n${_taex_run_err}")
+ # Always show stdout/stderr from the probe as indented sub-log
+ if(_taex_run_out)
+ string(REPLACE "\n" "\n " _taex_run_out_indented "${_taex_run_out}")
+ message(STATUS "Probe stdout:\n ${_taex_run_out_indented}")
+ endif()
+ if(_taex_run_err)
+ string(REPLACE "\n" "\n " _taex_run_err_indented "${_taex_run_err}")
+ message(STATUS "Probe stderr:\n ${_taex_run_err_indented}")
+ endif()
+ message(CHECK_FAIL "NO, it FAILS to detect IEEE754 special values")
set(AIR_EXISTS_MACRO_FAILS 1 CACHE INTERNAL "AIR_EXISTS macro fails")
endif()
@@ -353,32 +365,40 @@
# if(UNIX)
# target_link_libraries(Teem PRIVATE m)
# endif()
-# But actually, not all Unices need to link with -lm; let's figure out if it is needed
+# But not all Unices actually need to link with -lm to access math functions
+# like sin() and exp(); let's figure out if we need it.
-include(CheckFunctionExists)
+# https://cmake.org/cmake/help/latest/module/CheckSourceCompiles.html
+include(CheckSourceCompiles)
-# First: can we link sin() without -lm?
+set(_Teem_libm_test_source "
+ #include <math.h>
+ int main(void) { return (int)sin(0.0); }
+")
+
+# Always start with a clean slate
unset(CMAKE_REQUIRED_LIBRARIES)
-check_function_exists(sin HAVE_SIN_WITHOUT_LIBM)
-# If not, try again with -lm
-if(NOT HAVE_SIN_WITHOUT_LIBM)
- set(CMAKE_REQUIRED_LIBRARIES m)
- check_function_exists(sin HAVE_SIN_WITH_LIBM)
- unset(CMAKE_REQUIRED_LIBRARIES)
-endif()
+# First try without -lm
+check_source_compiles(C "${_Teem_libm_test_source}" HAVE_SIN_WITHOUT_LIBM)
-# Decide outcome
if(HAVE_SIN_WITHOUT_LIBM)
message(STATUS "sin() found without libm; do NOT need to link with -lm")
-elseif(HAVE_SIN_WITH_LIBM)
- message(STATUS "sin() requires libm; DO need to link with -lm")
- target_link_libraries(Teem PRIVATE m)
else()
- message(FATAL_ERROR "Could not find sin() at all!")
+ # Retry with -lm
+ set(CMAKE_REQUIRED_LIBRARIES m)
+ check_source_compiles(C "${_Teem_libm_test_source}" HAVE_SIN_WITH_LIBM)
+ unset(CMAKE_REQUIRED_LIBRARIES)
+
+ if(HAVE_SIN_WITH_LIBM)
+ message(STATUS "sin() requires libm; DO need to link with -lm")
+ target_link_libraries(Teem PRIVATE m)
+ else()
+ message(FATAL_ERROR "Could not find sin() at all!")
+ endif()
endif()
-# Set various properties
+# Set the target properties
set_target_properties(Teem PROPERTIES
OUTPUT_NAME teem # so we get libteem not libTeem
VERSION ${Teem_VERSION_STRING}
@@ -473,7 +493,7 @@
# Optional helper tools (hex/dehex)
# If requested, helper dehex/exhex programs
-if(Teem_BUILD_HEX)
+if(Teem_BUILD_HEX_UTILS)
add_subdirectory(src/hex)
endif()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|