CMake: Set BUILD_SHARED_LIBS before add_library(netcdf)

This commit is contained in:
Peter Hill 2024-02-22 13:43:44 +00:00 committed by Kyle Shores
parent 3341fbddf4
commit 046846ecb4

View File

@ -38,7 +38,17 @@ endif ()
# The target
################################
add_library(netcdf SHARED)
##
# Default building shared libraries.
# BUILD_SHARED_LIBS is provided by/used by
# CMake directly.
##
option(BUILD_SHARED_LIBS "Configure netCDF as a shared library." ON)
if(BUILD_SHARED_LIBS)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
add_library(netcdf)
add_library(netCDF::netcdf ALIAS netcdf)
#####
@ -213,16 +223,6 @@ include(GenerateExportHeader)
# Compiler and Linker Configuration
################################
##
# Default building shared libraries.
# BUILD_SHARED_LIBS is provided by/used by
# CMake directly.
##
option(BUILD_SHARED_LIBS "Configure netCDF as a shared library." ON)
if(BUILD_SHARED_LIBS)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
option(NC_FIND_SHARED_LIBS "Find dynamically-built versions of dependent libraries" ${BUILD_SHARED_LIBS})
##