mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Set libopenmc as static library in CMake for MSVC: Built openmc.exe
successfully with visual studio
This commit is contained in:
parent
e5b108be7a
commit
950c684e6c
1 changed files with 13 additions and 7 deletions
|
|
@ -159,7 +159,7 @@ target_compile_options(faddeeva PRIVATE ${cxxflags})
|
|||
# libopenmc
|
||||
#===============================================================================
|
||||
|
||||
add_library(libopenmc SHARED
|
||||
list(APPEND libopenmc_SOURCES
|
||||
src/bank.cpp
|
||||
src/bremsstrahlung.cpp
|
||||
src/dagmc.cpp
|
||||
|
|
@ -246,6 +246,18 @@ add_library(libopenmc SHARED
|
|||
src/xml_interface.cpp
|
||||
src/xsdata.cpp)
|
||||
|
||||
# For Visual Studio compilers
|
||||
if(MSVC)
|
||||
# Use static library (otherwise explicit symbol portings are needed)
|
||||
add_library(libopenmc STATIC ${libopenmc_SOURCES})
|
||||
|
||||
# To use the shared HDF5 libraries on Windows, the H5_BUILT_AS_DYNAMIC_LIB
|
||||
# compile definition must be specified.
|
||||
target_compile_definitions(libopenmc PRIVATE -DH5_BUILT_AS_DYNAMIC_LIB)
|
||||
else()
|
||||
add_library(libopenmc SHARED ${libopenmc_SOURCES})
|
||||
endif()
|
||||
|
||||
set_target_properties(libopenmc PROPERTIES
|
||||
OUTPUT_NAME openmc)
|
||||
|
||||
|
|
@ -272,12 +284,6 @@ if(GIT_SHA1_SUCCESS EQUAL 0)
|
|||
target_compile_definitions(libopenmc PRIVATE -DGIT_SHA1="${GIT_SHA1}")
|
||||
endif()
|
||||
|
||||
# To use the shared HDF5 libraries on Windows with Visual Studio,
|
||||
# the H5_BUILT_AS_DYNAMIC_LIB compile definition must be specified.
|
||||
if(MSVC)
|
||||
target_compile_definitions(libopenmc PRIVATE -DH5_BUILT_AS_DYNAMIC_LIB)
|
||||
endif()
|
||||
|
||||
# target_link_libraries treats any arguments starting with - but not -l as
|
||||
# linker flags. Thus, we can pass both linker flags and libraries together.
|
||||
target_link_libraries(libopenmc ${ldflags} ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue