From 7d38fa5f949f721113c3c36dea69adfc2394d1f2 Mon Sep 17 00:00:00 2001 From: Giacomo Fiorin Date: Sun, 10 Sep 2023 18:16:59 -0400 Subject: [PATCH] Static linkage with Visual Studio in CI --- cmake/CMakeLists.txt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 6693bfa4a..450402003 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -45,9 +45,15 @@ option(COLVARS_LEPTON "Build and link the Lepton library" ${COLVARS_LEPTON_DEFAU file(GLOB COLVARS_SOURCES ${COLVARS_SOURCE_DIR}/src/[^.]*.cpp) -add_library(colvars ${COLVARS_SOURCES}) -if(BUILD_SHARED_LIBS) - set_property(TARGET colvars PROPERTY POSITION_INDEPENDENT_CODE 1) +if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + # Avoid having to export all the relevant symbols + set(BUILD_SHARED_LIBS OFF) + add_library(colvars STATIC ${COLVARS_SOURCES}) +else() + add_library(colvars ${COLVARS_SOURCES}) + if(BUILD_SHARED_LIBS) + set_property(TARGET colvars PROPERTY POSITION_INDEPENDENT_CODE 1) + endif() endif() target_compile_options(colvars PRIVATE $<$,$,$,$>:-Wall -pedantic>)