From c36bd62afb0428a4a84cd209b9e9e7fd06ddc645 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Tue, 28 Feb 2023 11:53:59 -0700 Subject: [PATCH] better handling of shared library builds --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ff7d58ba..4f252dac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,12 +11,20 @@ project(w3emc VERSION ${pVersion} LANGUAGES C Fortran) # Handle user options. option(ENABLE_DOCS "Enable generation of doxygen-based documentation." OFF) +option(BUILD_SHARED_LIBS "Build shared libraries" OFF) option(BUILD_4 "Build the 4-byte real version of the library, libw3emc_4.a" ON) option(BUILD_D "Build the 8-byte real version of the library, libw3emc_d.a" ON) option(BUILD_TESTING "Build tests of the library" ON) option(BUILD_WITH_EXTRA_DEPS "Build w3emc with subprograms which call unknown dependencies" ON) option(BUILD_WITH_BUFR "Build w3emc with subprograms which call NCEPLIBS-bufr" ON) +# If building shared, extra dependencies must be eliminated. +if(BUILD_SHARED_LIBS) + if(BUILD_WITH_EXTRA_DEPS) + message(FATAL_ERROR "Shared libraries cannot be built without setting -DBUILD_WITH_EXTRA_DEPS=OFF.") + endif() +endif() + # Figure whether user wants a _4, a _d, or both libraries. if(BUILD_4 AND BUILD_D) set(kinds "4" "d")