Skip to content

Commit

Permalink
move the config part to another library in msvc/shared due to LNK1189
Browse files Browse the repository at this point in the history
  • Loading branch information
yhmtsai committed May 29, 2024
1 parent 155c51e commit 7f726ff
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
3 changes: 3 additions & 0 deletions cmake/create_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ function(ginkgo_set_test_target_properties test_target_name test_library_suffix)
set_target_properties(${test_target_name} PROPERTIES CUDA_STANDARD 14)
target_include_directories(${test_target_name} PRIVATE ${Ginkgo_BINARY_DIR} ${set_properties_ADDITIONAL_INCLUDES})
target_link_libraries(${test_target_name} PRIVATE ginkgo GTest::GTest ${set_properties_ADDITIONAL_LIBRARIES})
if(MSVC AND BUILD_SHARED_LIBS)
target_link_libraries(${test_target_name} PRIVATE ginkgo_config)
endif()
endfunction()

function(ginkgo_add_resource_requirement test_name)
Expand Down
28 changes: 23 additions & 5 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
add_subdirectory(device_hooks) # placeholders for disabled modules

add_library(ginkgo "")
set(config_source
config/factorization_config.cpp
config/multigrid_config.cpp
config/preconditioner_config.cpp
config/registry.cpp
config/solver_config.cpp
)
target_sources(ginkgo
PRIVATE
base/array.cpp
Expand All @@ -21,12 +28,7 @@ target_sources(ginkgo
base/version.cpp
config/config.cpp
config/config_helper.cpp
config/factorization_config.cpp
config/preconditioner_config.cpp
config/property_tree.cpp
config/registry.cpp
config/multigrid_config.cpp
config/solver_config.cpp
config/stop_config.cpp
config/type_descriptor.cpp
distributed/index_map.cpp
Expand Down Expand Up @@ -125,13 +127,29 @@ if(GINKGO_BUILD_MPI)
distributed/preconditioner/schwarz.cpp)
endif()

if(MSVC AND BUILD_SHARED_LIBS)
add_library(ginkgo_config "")
target_sources(ginkgo_config PRIVATE ${config_source})
ginkgo_compile_features(ginkgo_config)
ginkgo_default_includes(ginkgo_config)
ginkgo_install_library(ginkgo_config)
if(GINKGO_CHECK_CIRCULAR_DEPS)
ginkgo_check_headers(ginkgo_config "")
endif()
else()
target_sources(ginkgo PRIVATE ${config_source})
endif()

ginkgo_compile_features(ginkgo)

# add a namespace alias so Ginkgo can always be included as Ginkgo::ginkgo
# regardless of whether it is installed or added as a subdirectory
add_library(Ginkgo::ginkgo ALIAS ginkgo)
target_link_libraries(ginkgo
PUBLIC ginkgo_device ginkgo_omp ginkgo_cuda ginkgo_reference ginkgo_hip ginkgo_dpcpp)
if(MSVC AND BUILD_SHARED_LIBS)
target_link_libraries(ginkgo_config PUBLIC ginkgo)
endif()
if(GINKGO_HAVE_PAPI_SDE)
target_link_libraries(ginkgo PUBLIC PAPI::PAPI_SDE)
endif()
Expand Down

0 comments on commit 7f726ff

Please sign in to comment.