diff options
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) |