diff options
author | Jerome Soumagne <jsoumagne@hdfgroup.org> | 2019-02-21 22:39:37 (GMT) |
---|---|---|
committer | Jerome Soumagne <jsoumagne@hdfgroup.org> | 2019-02-21 22:39:37 (GMT) |
commit | bcf5c400c06bf06820b25c37eceaa97245f15f1f (patch) | |
tree | 38c116e724cc4ffb97a4a5d4f8eea4b657466fdd | |
parent | b901552b1ca315db8b27ea090011f2f557491d46 (diff) | |
download | hdf5-bcf5c400c06bf06820b25c37eceaa97245f15f1f.zip hdf5-bcf5c400c06bf06820b25c37eceaa97245f15f1f.tar.gz hdf5-bcf5c400c06bf06820b25c37eceaa97245f15f1f.tar.bz2 |
Fix CMake H5_HAVE_THREADSAFE to set value in H5pubconf.h
Add REQUIRED to find_package(Threads)
Link against thread library if static and not WIN32 platform
-rw-r--r-- | CMakeLists.txt | 12 | ||||
-rw-r--r-- | config/cmake/H5pubconf.h.in | 7 | ||||
-rw-r--r-- | src/CMakeLists.txt | 5 | ||||
-rw-r--r-- | test/CMakeLists.txt | 2 |
4 files changed, 19 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6446a7d..c2eb94d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -683,8 +683,10 @@ endif () option (HDF5_ENABLE_THREADSAFE "Enable thread-safety" OFF) if (HDF5_ENABLE_THREADSAFE) # check for unsupported options - message (STATUS " **** thread-safety option not supported with static library **** ") - message (STATUS " **** thread-safety option will not be used building static library **** ") + if (WIN32) + message (STATUS " **** thread-safety option not supported with static library **** ") + message (STATUS " **** thread-safety option will not be used building static library **** ") + endif () if (HDF5_ENABLE_PARALLEL) if (NOT ALLOW_UNSUPPORTED) message (FATAL_ERROR " **** parallel and thread-safety options are not supported **** ") @@ -722,9 +724,9 @@ if (HDF5_ENABLE_THREADSAFE) endif () endif () set(THREADS_PREFER_PTHREAD_FLAG ON) - find_package(Threads) - if (NOT Threads_FOUND) - message (STATUS " **** thread-safe package not found - threads still might work **** ") + find_package(Threads REQUIRED) + if (Threads_FOUND) + set (H5_HAVE_THREADSAFE 1) endif () endif () diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index 273adb5..9e7b8b7 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -390,8 +390,13 @@ /* Define to 1 if you have the <szlib.h> header file. */ #cmakedefine H5_HAVE_SZLIB_H @H5_HAVE_SZLIB_H@ +#if defined(_WIN32) && !defined(H5_BUILT_AS_DYNAMIC_LIB) +/* Not supported on WIN32 platforms with static linking */ +/* #undef H5_HAVE_THREADSAFE */ +#else /* Define if we have thread safe support */ -#cmakedefine H5_HAVE_THREADSAFE @H5_HAVE_THREADSAFE@ +# cmakedefine H5_HAVE_THREADSAFE @H5_HAVE_THREADSAFE@ +#endif /* Define if timezone is a global variable */ #cmakedefine H5_HAVE_TIMEZONE @H5_HAVE_TIMEZONE@ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 698c143..83240bd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1118,6 +1118,11 @@ target_link_libraries (${HDF5_LIB_TARGET} PRIVATE ${LINK_LIBS} ${LINK_COMP_LIBS} "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>" PUBLIC $<$<NOT:$<PLATFORM_ID:Windows>>:${CMAKE_DL_LIBS}> ) +if (NOT WIN32) + target_link_libraries (${HDF5_LIB_TARGET} + PUBLIC $<$<BOOL:${HDF5_ENABLE_THREADSAFE}>:Threads::Threads> + ) +endif () set_global_variable (HDF5_LIBRARIES_TO_EXPORT ${HDF5_LIB_TARGET}) H5_SET_LIB_OPTIONS (${HDF5_LIB_TARGET} ${HDF5_LIB_NAME} STATIC 0) set_target_properties (${HDF5_LIB_TARGET} PROPERTIES FOLDER libraries) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c442e9b..276cf09 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -45,7 +45,7 @@ if (BUILD_SHARED_LIBS) INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>" ) target_compile_definitions(${HDF5_TEST_LIBSH_TARGET} - PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" $<$<BOOL:${HDF5_ENABLE_THREADSAFE}>:H5_HAVE_THREADSAFE> + PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" ) TARGET_C_PROPERTIES (${HDF5_TEST_LIBSH_TARGET} SHARED) target_link_libraries (${HDF5_TEST_LIBSH_TARGET} |