Skip to content

Commit

Permalink
Radically simplified oflimits.h.
Browse files Browse the repository at this point in the history
Radically simplified oflimits.h by unconditionally including <limits>,
which is guaranteed to exist in C++98, and reducing OFnumeric_limits
to a typedef. This eliminates the need for the generation of arith.h,
which required a program (arith.cc) to be compiled and run at
configure time, thus causing problems in cross-compilation setups.
  • Loading branch information
Marco Eichelberg committed Mar 4, 2024
1 parent 913c343 commit eeb7f7e
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 1,481 deletions.
1 change: 0 additions & 1 deletion CMake/DCMTKConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ set(DCMTK_ENABLE_CXX11 @DCMTK_ENABLE_CXX11@)
set(DCMTK_CXX11_FLAGS @DCMTK_CXX11_FLAGS@)
set(DCMTK_ENABLE_STL @DCMTK_ENABLE_STL@)
set(DCMTK_ENABLE_STL_ALGORITHM @DCMTK_ENABLE_STL_ALGORITHM@)
set(DCMTK_ENABLE_STL_LIMITS @DCMTK_ENABLE_STL_LIMITS@)
set(DCMTK_ENABLE_STL_LIST @DCMTK_ENABLE_STL_LIST@)
set(DCMTK_ENABLE_STL_MAP @DCMTK_ENABLE_STL_MAP@)
set(DCMTK_ENABLE_STL_MEMORY @DCMTK_ENABLE_STL_MEMORY@)
Expand Down
44 changes: 0 additions & 44 deletions CMake/GenerateDCMTKConfigure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1322,49 +1322,6 @@ int main()
endif()
endif()

# Compile config/tests/arith.cc and generate config/arith.h
function(INSPECT_FUNDAMENTAL_ARITHMETIC_TYPES)
set(ARITH_H_FILE "${DCMTK_BINARY_DIR}/config/include/dcmtk/config/arith.h")
if("${DCMTK_SOURCE_DIR}/config/tests/arith.cc" IS_NEWER_THAN "${ARITH_H_FILE}")
if(CMAKE_CROSSCOMPILING)
if(WIN32)
UNIX_TO_WINE_PATH(ARITH_H_FILE "${ARITH_H_FILE}")
string(REPLACE "\\" "\\\\" ARITH_H_FILE "${ARITH_H_FILE}")
elseif(ANDROID)
set(ARITH_H_DESTINATION "${ARITH_H_FILE}")
set(ARITH_H_FILE "${ANDROID_TEMPORARY_FILES_LOCATION}/arith.h")
endif()
endif()
if(NOT DEFINED DCMTK_NO_TRY_RUN)
DCMTK_TRY_RUN(
RESULT COMPILED
"${DCMTK_BINARY_DIR}/CMakeTmp/Arith"
"${DCMTK_SOURCE_DIR}/config/tests/arith.cc"
COMPILE_DEFINITIONS -I"${DCMTK_BINARY_DIR}/config/include" -I"${DCMTK_SOURCE_DIR}/ofstd/include" -I"${DCMTK_SOURCE_DIR}/ofstd/libsrc"
RUN_OUTPUT_VARIABLE OUTPUT
COMPILE_OUTPUT_VARIABLE CERR
ARGS "\\\"${ARITH_H_FILE}\\\""
)
if(COMPILED)
if(NOT RESULT)
message(STATUS "${OUTPUT}")
if(CMAKE_CROSSCOMPILING)
if(ANDROID)
DCMTK_ANDROID_PULL(DCMTK_ANDROID_EMULATOR_INSTANCE "${ARITH_H_FILE}" DESTINATION "${ARITH_H_DESTINATION}")
endif()
endif()
else()
message(FATAL_ERROR "${OUTPUT}")
endif()
else()
message(FATAL_ERROR "${CERR}")
endif()
else()
message("Be sure to copy arith.h to ${ARITH_H_FILE} before build")
endif()
endif() # file needs update
endfunction()

function(DCMTK_CHECK_CXX_STANDARD STANDARD)
set(RESULT 0)
if(DEFINED HAVE_CXX${STANDARD}_TEST_RESULT)
Expand Down Expand Up @@ -1487,7 +1444,6 @@ endif()
DCMTK_TEST_ENABLE_CXX11()
DCMTK_TEST_ENABLE_STL_FEATURE("vector")
DCMTK_TEST_ENABLE_STL_FEATURE("algorithm" "algo")
DCMTK_TEST_ENABLE_STL_FEATURE("limits")
DCMTK_TEST_ENABLE_STL_FEATURE("list")
DCMTK_TEST_ENABLE_STL_FEATURE("map")
DCMTK_TEST_ENABLE_STL_FEATURE("memory")
Expand Down
1 change: 0 additions & 1 deletion CMake/dcmtkPrepare.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ endmacro()

DCMTK_INFERABLE_OPTION(DCMTK_ENABLE_STL_VECTOR "Enable use of STL vector.")
DCMTK_INFERABLE_OPTION(DCMTK_ENABLE_STL_ALGORITHM "Enable use of STL algorithm.")
DCMTK_INFERABLE_OPTION(DCMTK_ENABLE_STL_LIMITS "Enable use of STL limit.")
DCMTK_INFERABLE_OPTION(DCMTK_ENABLE_STL_LIST "Enable use of STL list.")
DCMTK_INFERABLE_OPTION(DCMTK_ENABLE_STL_MAP "Enable use of STL map.")
DCMTK_INFERABLE_OPTION(DCMTK_ENABLE_STL_MEMORY "Enable use of STL memory.")
Expand Down
3 changes: 0 additions & 3 deletions CMake/osconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -984,9 +984,6 @@ DCMTK was configured to use C++17 features, but your compiler does not or was no
/* Define if we are supposed to use STL's algorithms */
#cmakedefine HAVE_STL_ALGORITHM @HAVE_STL_ALGORITHM@

/* Define if we are supposed to use STL's limit */
#cmakedefine HAVE_STL_LIMITS @HAVE_STL_LIMITS@

/* Define if we are supposed to use STL's list */
#cmakedefine HAVE_STL_LIST @HAVE_STL_LIST@

Expand Down
6 changes: 0 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ include(CMake/dcmtkPrepare.cmake NO_POLICY_SCOPE)
configure_file("${DCMTK_SOURCE_DIR}/CMake/osconfig.h.in"
"${DCMTK_BINARY_DIR}/config/include/dcmtk/config/osconfig.h")

#-----------------------------------------------------------------------------
# Prepare arith.h
#-----------------------------------------------------------------------------

INSPECT_FUNDAMENTAL_ARITHMETIC_TYPES()

# ----------------------------------------------------------------------------
# Unit test related configuration/setup
# ----------------------------------------------------------------------------
Expand Down
7 changes: 0 additions & 7 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -931,8 +931,6 @@ In detail, these are the variables that need to be provided:
<vector> implementation, 0 otherwise
- HAVE_STL_ALGORITHM_TEST_RESULT: 1 if the platform provides a working
<algorithm> implementation, 0 otherwise
- HAVE_STL_LIMITS_TEST_RESULT: 1 if the platform provides a working
<limits> implementation, 0 otherwise
- HAVE_STL_LIST_TEST_RESULT: 1 if the platform provides a working
<list> implementation, 0 otherwise
- HAVE_STL_MAP_TEST_RESULT: 1 if the platform provides a working
Expand All @@ -950,11 +948,6 @@ In detail, these are the variables that need to be provided:
- HAVE_STL_SYSTEM_ERROR_TEST_RESULT: 1 if the platform provides a working
<system_error> implementation, 0 otherwise

Furthermore, the file "arith.h" must be generated and copied to
"config/include/dcmtk/config/arith.h" in the build (not source!) directory.
This file can be generated by compiling "config/tests/arith.cc" and running
the executable on the target platform.

For further information on cross-compiling DCMTK, see:
https://support.dcmtk.org/redmine/projects/dcmtk/wiki/Cross_Compiling

Expand Down
Loading

0 comments on commit eeb7f7e

Please # to comment.