Skip to content

Commit

Permalink
Merge pull request #331 from Xiangyu-Hu/fabien/cmake-tiny
Browse files Browse the repository at this point in the history
Minor CMake changes
  • Loading branch information
Xiangyu-Hu authored Jun 12, 2023
2 parents 865ab07 + 0c0bfd6 commit cd6603e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -46,6 +46,8 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# target_compile_options(sphinxsys_core INTERFACE $<$<BOOL:${SPHINXSYS_DEVELOPER_MODE}>:-Wpedantic>) # For strict C++ standard compliance # TODO:
endif()

target_compile_definitions(sphinxsys_core INTERFACE SPHINXSYS_USE_FLOAT=$<BOOL:${SPHINXSYS_USE_FLOAT}>)

# ------ Dependencies
# ## SIMD flags
find_package(SIMD QUIET)
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/shared/common/base_data_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cd6603e

Please sign in to comment.