Skip to content

Commit

Permalink
Add configure option to use system UUID generator
Browse files Browse the repository at this point in the history
  • Loading branch information
ZedThree committed Feb 4, 2021
1 parent e193ac6 commit ba2c968
Show file tree
Hide file tree
Showing 8 changed files with 399 additions and 4 deletions.
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,19 @@ if (BOUT_USE_SCOREP)
endif()
set(BOUT_HAS_SCOREP ${BOUT_USE_SCOREP})

option(BOUT_USE_UUID_SYSTEM_GENERATOR "Enable support for using a system UUID generator" ON)
if (BOUT_USE_UUID_SYSTEM_GENERATOR)
find_package(Libuuid QUIET)
if (Libuuid_FOUND)
target_link_libraries(bout++
PUBLIC Libuuid::libuuid)
else()
message(STATUS "libuuid not found, using fallback UUID generator")
endif()
endif()
message(STATUS "UUID_SYSTEM_GENERATOR: ${BOUT_USE_UUID_SYSTEM_GENERATOR}")
set(BOUT_HAS_UUID_SYSTEM_GENERATOR ${BOUT_USE_UUID_SYSTEM_GENERATOR})

include(CheckCXXSourceCompiles)
check_cxx_source_compiles("int main() { const char* name = __PRETTY_FUNCTION__; }"
HAS_PRETTY_FUNCTION)
Expand Down
3 changes: 3 additions & 0 deletions autoconf_build_defines.hxx.in
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
/* SUNDIALS support */
#undef BOUT_HAS_SUNDIALS

/* Use libuuid for UUID generation */
#undef BOUT_HAS_UUID_SYSTEM_GENERATOR

/* OpenMP schedule */
#undef BOUT_OPENMP_SCHEDULE

Expand Down
58 changes: 58 additions & 0 deletions cmake/FindLibuuid.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# FindLibuuid
# ----------
#
# Find a libuuid UUID generator library
#
# This module will define the following variables:
#
# ::
#
# Libuuid_FOUND - true if Libuuid was found
# Libuuid_INCLUDE_DIRS - Location of the Libuuid includes
# Libuuid_LIBRARIES - Required libraries
#
# This module will also export the ``Libuuid::libuuid`` target.
#
# You can also set the following variables:
#
# ``Libuuid_ROOT``
# Specify the path to the Libuuid installation to use
#
# ``Libuuid_DEBUG``
# Set to TRUE to get extra debugging output

include (FindPackageHandleStandardArgs)

if (WIN32)
find_package_handle_standard_args(Libuuid DEFAULT_MSG)
return()
endif()

if (APPLE)
find_library(CFLIB CoreFoundation)
find_package_handle_standard_args(Libuuid DEFAULT_MSG CFLIB)
mark_as_advanced(${CFLIB})

if (Libuuid_FOUND AND NOT TARGET Libuuid::libuuid)
add_library(Libuuid::libuuid UNKNOWN IMPORTED)
set_target_properties(Libuuid::libuuid PROPERTIES
IMPORTED_LOCATION ${CFLIB}
)
endif()
return()
endif ()

find_path(Libuuid_INCLUDE_DIRS uuid/uuid.h)
find_library(Libuuid_LIBRARIES uuid)

find_package_handle_standard_args(Libuuid DEFAULT_MSG Libuuid_LIBRARIES Libuuid_INCLUDE_DIRS)

mark_as_advanced(Libuuid_LIBRARIES Libuuid_INCLUDE_DIRS)

if (Libuuid_FOUND AND NOT TARGET Libuuid::libuuid)
add_library(Libuuid::libuuid UNKNOWN IMPORTED)
set_target_properties(Libuuid::libuuid PROPERTIES
IMPORTED_LOCATION "${Libuuid_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${Libuuid_INCLUDE_DIRS}"
)
endif()
1 change: 1 addition & 0 deletions cmake_build_defines.hxx.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#cmakedefine01 BOUT_HAS_SCOREP
#cmakedefine01 BOUT_HAS_SLEPC
#cmakedefine01 BOUT_HAS_SUNDIALS
#cmakedefine01 BOUT_HAS_UUID_SYSTEM_GENERATOR
#cmakedefine01 BOUT_USE_BACKTRACE
#cmakedefine01 BOUT_USE_COLOR
#cmakedefine01 BOUT_USE_OPENMP
Expand Down
Loading

0 comments on commit ba2c968

Please sign in to comment.