Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Core Modules
dune-common
Commits
f18ce6b2
Commit
f18ce6b2
authored
4 years ago
by
Simon Praetorius
Browse files
Options
Downloads
Patches
Plain Diff
Rewrite FindQuadMath to provide imported targets
parent
30cbe040
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!819
Rewrite FindQuadMath to provide imported targets
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmake/modules/FindQuadMath.cmake
+58
-42
58 additions, 42 deletions
cmake/modules/FindQuadMath.cmake
with
58 additions
and
42 deletions
cmake/modules/FindQuadMath.cmake
+
58
−
42
View file @
f18ce6b2
# .. cmake_module::
#
# Find the GCC Quad-Precision library
#
# Sets the following variables:
#
# :code:`QUADMATH_FOUND`
# True if the Quad-Precision library was found.
#
#
# search for the header quadmath.h
include
(
CheckIncludeFile
)
check_include_file
(
quadmath.h QUADMATH_HEADER
)
include
(
CheckCSourceCompiles
)
include
(
CMakePushCheckState
)
#[=======================================================================[.rst:
FindQuadMath
------------
Find the GCC Quad-Precision library
This module checks if the used compiler has built-in support for QuadMath
by compiling a small source file.
Imported Targets
^^^^^^^^^^^^^^^^
This module provides the following imported targets, if found:
``QuadMath::QuadMath``
Library to link against if QuadMath should be used.
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables:
``QuadMath_FOUND``
True if the Quad-Precision library was found.
cmake_push_check_state
()
# Save variables
#]=======================================================================]
# Add a feature summary for this package
include
(
FeatureSummary
)
set_package_properties
(
QuadMath PROPERTIES
DESCRIPTION
"GCC Quad-Precision Math Library"
URL
"https://gcc.gnu.org/onlinedocs/libquadmath"
)
# Check if QuadMath support is built into the compiler
include
(
CheckCXXSourceCompiles
)
include
(
CMakePushCheckState
)
cmake_push_check_state
()
set
(
CMAKE_REQUIRED_LIBRARIES quadmath
)
check_c_source_compiles
(
"
check_c
xx
_source_compiles
(
"
#include <quadmath.h>
int main ()
...
...
@@ -27,33 +45,31 @@ int main ()
__float128 r = 1.0q;
r = strtoflt128(
\"
1.2345678
\"
, NULL);
return 0;
}"
Q
UADMATH
_COMPILES
)
cmake_pop_check_state
()
}"
Q
uadMath
_COMPILES
)
cmake_pop_check_state
()
# Reset CMAKE_REQUIRED_XXX variables
if
(
QuadMath_COMPILES
)
# Use additional variable for better report message
set
(
QuadMath_VAR
"(Supported by compiler)"
)
endif
()
# Report that package was found
include
(
FindPackageHandleStandardArgs
)
find_package_handle_standard_args
(
"QuadMath"
find_package_handle_standard_args
(
QuadMath
DEFAULT_MSG
QUADMATH_HEADER
QUADMATH_COMPILES
QuadMath_VAR QuadMath_HEADER QuadMath_COMPILES
)
# text for feature summary
set_package_properties
(
"QuadMath"
PROPERTIES
DESCRIPTION
"GCC Quad-Precision library"
)
# set HAVE_QUADMATH for config.h
set
(
HAVE_QUADMATH
${
QUADMATH_FOUND
}
)
# -fext-numeric-literals is a GCC extension not available in other compilers like clang
if
(
${
CMAKE_CXX_COMPILER_ID
}
STREQUAL GNU
)
set
(
_QUADMATH_EXT_NUMERIC_LITERALS
"-fext-numeric-literals"
)
endif
()
# add imported target for quadmath
if
(
QuadMath_FOUND AND NOT TARGET QuadMath::QuadMath
)
# Compiler supports QuadMath: Add appropriate linker flag
add_library
(
QuadMath::QuadMath INTERFACE IMPORTED
)
target_link_libraries
(
QuadMath::QuadMath INTERFACE quadmath
)
# register all QuadMath related flags
if
(
HAVE_QUADMATH
)
dune_register_package_flags
(
COMPILE_DEFINITIONS
"ENABLE_QUADMATH=1"
"_GLIBCXX_USE_FLOAT128=1"
COMPILE_OPTIONS
${
_QUADMATH_EXT_NUMERIC_LITERALS
}
LIBRARIES
"quadmath"
)
target_compile_definitions
(
QuadMath::QuadMath INTERFACE
_GLIBCXX_USE_FLOAT128
)
target_compile_options
(
QuadMath::QuadMath INTERFACE
$<$<CXX_COMPILER_ID:GNU>:-fext-numeric-literals>
)
endif
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment