From 684dfbf744ed0cd41ba4aebcfb47d4107d4f5e63 Mon Sep 17 00:00:00 2001 From: Ivet Galabova Date: Wed, 15 Jan 2025 21:45:45 +0000 Subject: [PATCH] shared libs --- CMakeLists.txt | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f4a914b88e..b24732b688 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,9 +66,6 @@ message(STATUS "Build Fortran: ${FORTRAN}") option(CSHARP "Build CSharp interface" OFF) message(STATUS "Build CSharp: ${CSHARP}") -if (FORTRAN OR CSHARP) - set(BUILD_SHARED_LIBS ON) -endif() option(PYTHON_BUILD_SETUP "Build Python interface from setup.py" OFF) message(STATUS "Build Python: ${PYTHON_BUILD_SETUP}") @@ -143,7 +140,13 @@ if (BUILD_CXX) include(GNUInstallDirs) if(UNIX) - option(BUILD_SHARED_LIBS "Build shared libraries (.so or .dyld)." ON) + # Unix on by default, off for csharp on linux. + if (CSHARP AND (UNIX AND NOT APPLE)) + option(BUILD_SHARED_LIBS "Build shared libraries (.so or .dyld)." OFF) + else() + option(BUILD_SHARED_LIBS "Build shared libraries (.so or .dyld)." ON) + endif() + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}) @@ -155,7 +158,13 @@ if (BUILD_CXX) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/${OUTPUTCONFIG}/${CMAKE_INSTALL_BINDIR}) endforeach() else() - option(BUILD_SHARED_LIBS "Build shared libraries (.dll)." OFF) + # Windows off by default, on for fortran and csharp. + if (FORTRAN OR CSHARP) + option(BUILD_SHARED_LIBS "Build shared libraries (.dll)." ON) + else() + option(BUILD_SHARED_LIBS "Build shared libraries (.dll)." OFF) + endif() + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}) @@ -404,9 +413,6 @@ if(NOT FAST_BUILD OR CSHARP) if(CMAKE_CSharp_COMPILER) enable_language(CSharp) set(CSHARP_FOUND ON) - if (UNIX) - set(BUILD_SHARED_LIBS OFF) - endif() else() set(CSHARP_FOUND OFF) endif(CMAKE_CSharp_COMPILER) @@ -678,10 +684,6 @@ else(FAST_BUILD) option(USE_DOTNET_STD_21 "Use .Net Standard 2.1 support" ON) message(STATUS ".Net: Use .Net Framework 2.1 support: ${USE_DOTNET_STD_21}") - if (CSHARP AND UNIX) - set(BUILD_SHARED_LIBS OFF) - message(STATUS "CSharp: shared libs ${BUILD_SHARED_LIBS}") - endif() include(dotnet)