diff options
author | Allen Byrne <50328838+byrnHDF@users.noreply.github.com> | 2023-04-04 16:36:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-04 16:36:23 (GMT) |
commit | f13f8705b18dbd21ea08192d7167a24a4f5309fe (patch) | |
tree | ad510e8ff9fbf858822d921b65d3f8120fe9f226 /CMakeLists.txt | |
parent | ec0d4d64867923577c7680c94bf4d51558664693 (diff) | |
download | hdf5-f13f8705b18dbd21ea08192d7167a24a4f5309fe.zip hdf5-f13f8705b18dbd21ea08192d7167a24a4f5309fe.tar.gz hdf5-f13f8705b18dbd21ea08192d7167a24a4f5309fe.tar.bz2 |
Make sure that ONLY_SHARED_LIBS option is correctly set (#2545)
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d019b9..c418f34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -456,28 +456,30 @@ endif () #----------------------------------------------------------------------------- # Option to Build Shared and Static libs, default is both #----------------------------------------------------------------------------- +option (ONLY_SHARED_LIBS "Only Build Shared Libraries" OFF) +mark_as_advanced (ONLY_SHARED_LIBS) option (BUILD_STATIC_LIBS "Build Static Libraries" ON) set (H5_ENABLE_STATIC_LIB NO) option (BUILD_SHARED_LIBS "Build Shared Libraries" ON) set (H5_ENABLE_SHARED_LIB NO) -option (ONLY_SHARED_LIBS "Only Build Shared Libraries" OFF) -mark_as_advanced (ONLY_SHARED_LIBS) -if (BUILD_STATIC_LIBS) - set (H5_ENABLE_STATIC_LIB YES) -endif () -if (BUILD_SHARED_LIBS) - set (H5_ENABLE_SHARED_LIB YES) -endif () - -# Force only shared libraries if all OFF -if (NOT BUILD_STATIC_LIBS AND NOT BUILD_SHARED_LIBS) +# only shared libraries is true if user forces static OFF +if (NOT BUILD_STATIC_LIBS) set (ONLY_SHARED_LIBS ON CACHE BOOL "Only Build Shared Libraries" FORCE) endif () +# only shared libraries is set ON by user then force settings if (ONLY_SHARED_LIBS) set (H5_ENABLE_STATIC_LIB NO) - set (BUILD_SHARED_LIBS ON CACHE BOOL "Build Shared Libraries") + set (BUILD_SHARED_LIBS ON CACHE BOOL "Build Shared Libraries" FORCE) + set (BUILD_STATIC_LIBS OFF CACHE BOOL "Build Static Libraries" FORCE) +endif () + +if (BUILD_STATIC_LIBS) + set (H5_ENABLE_STATIC_LIB YES) +endif () +if (BUILD_SHARED_LIBS) + set (H5_ENABLE_SHARED_LIB YES) endif () set (CMAKE_POSITION_INDEPENDENT_CODE ON) @@ -900,7 +902,7 @@ add_subdirectory (src) if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") if ((ZLIB_FOUND AND ZLIB_USE_EXTERNAL) OR (SZIP_FOUND AND SZIP_USE_EXTERNAL)) - if (NOT ONLY_SHARED_LIBS) + if (BUILD_STATIC_LIBS) add_dependencies (${HDF5_LIB_TARGET} ${LINK_COMP_LIBS}) endif () if (BUILD_SHARED_LIBS) |