summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorAllen Byrne <50328838+byrnHDF@users.noreply.github.com>2023-03-14 01:37:36 (GMT)
committerGitHub <noreply@github.com>2023-03-14 01:37:36 (GMT)
commit9a5bde57bd216a08d6a66c1702fd87a0b559fada (patch)
treeb88114eae044446cd8a7b5d6a0bcf2383e0fa2e4 /CMakeLists.txt
parent1e8ce8767a991f269eb5101fbee700db03b09398 (diff)
downloadhdf5-9a5bde57bd216a08d6a66c1702fd87a0b559fada.zip
hdf5-9a5bde57bd216a08d6a66c1702fd87a0b559fada.tar.gz
hdf5-9a5bde57bd216a08d6a66c1702fd87a0b559fada.tar.bz2
Make sure that ONLY_SHARED_LIBS option is correctly set (#2546)
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt28
1 files changed, 15 insertions, 13 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b038da0..888070c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -483,28 +483,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)
@@ -895,7 +897,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)