diff --git a/CMakeLists.txt b/CMakeLists.txt index feff17b401..dda171be74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ option(SPHINXSYS_2D "Build sphinxsys_2d library" ON) option(SPHINXSYS_3D "Build sphinxsys_3d library" ON) option(SPHINXSYS_BUILD_TESTS "Build tests" ON) option(SPHINXSYS_DEVELOPER_MODE "Developer mode has more flags active for code quality" ON) -option(SPHINXSYS_USE_FLOAT "Build using float or not" OFF) +option(SPHINXSYS_USE_FLOAT "Build using float (single-precision floating-point format) as primary type" OFF) # ------ Global properties (Some cannot be set on INTERFACE targets) set(CMAKE_VERBOSE_MAKEFILE OFF CACHE BOOL "Enable verbose compilation commands for Makefile and Ninja" FORCE) # Extra fluff needed for Ninja: https://github.com/ninja-build/ninja/issues/900 @@ -46,6 +46,8 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # target_compile_options(sphinxsys_core INTERFACE $<$:-Wpedantic>) # For strict C++ standard compliance # TODO: endif() +target_compile_definitions(sphinxsys_core INTERFACE SPHINXSYS_USE_FLOAT=$) + # ------ Dependencies # ## SIMD flags find_package(SIMD QUIET) @@ -79,11 +81,6 @@ set(Boost_NO_WARN_NEW_VERSIONS TRUE) # In case your CMake version is older than find_package(Boost REQUIRED) find_path(BOOST_INCLUDE_DIR boost/geometry) # Header-only Boost libraries are not components -if(SPHINXSYS_USE_FLOAT) - target_compile_definitions(sphinxsys_core INTERFACE USE_FLOAT) - message("-- Use float as default") -endif() - if(NOT BOOST_INCLUDE_DIR) message(FATAL_ERROR "Please install Boost.Geometry library") endif() diff --git a/src/shared/common/base_data_type.h b/src/shared/common/base_data_type.h index 880c476d3c..bb161cd6e1 100644 --- a/src/shared/common/base_data_type.h +++ b/src/shared/common/base_data_type.h @@ -69,7 +69,7 @@ namespace SPH * Using -mtune=native produces code optimized for the local machine under the constraints of the selected instruction set. */ -#if USE_FLOAT +#if SPHINXSYS_USE_FLOAT using Real = float; using EigMat = Eigen::MatrixXf; #else