Skip to content

Commit

Permalink
Static linkage with Visual Studio in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomofiorin committed Sep 11, 2023
1 parent 90cd254 commit 7d38fa5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Intel>>:-Wall -pedantic>)
Expand Down

0 comments on commit 7d38fa5

Please sign in to comment.