Skip to content

Commit

Permalink
AMD: Use same object for linking to shared and static libraries.
Browse files Browse the repository at this point in the history
Avoid building all objects twice (for the shared and the static library),
effectively reducing the build time approximately by a factor of two.
  • Loading branch information
mmuetzel committed Oct 18, 2024
1 parent 39c23ae commit 6718aa1
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions AMD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,7 @@ configure_file ( "Config/amd_version.tex.in" "${PROJECT_SOURCE_DIR}/Doc/amd_vers
NEWLINE_STYLE LF )

#-------------------------------------------------------------------------------
# include directories
#-------------------------------------------------------------------------------

include_directories ( Source Include )

#-------------------------------------------------------------------------------
# dynamic amd library properties
# object library
#-------------------------------------------------------------------------------

if ( SUITESPARSE_HAS_FORTRAN )
Expand All @@ -81,8 +75,15 @@ else ( )
file ( GLOB AMD_SOURCES "Source/*.c" )
endif ( )

add_library ( amd_obj OBJECT ${AMD_SOURCES} )
target_include_directories ( amd_obj PRIVATE Source Include )

#-------------------------------------------------------------------------------
# dynamic amd library properties
#-------------------------------------------------------------------------------

if ( BUILD_SHARED_LIBS )
add_library ( AMD SHARED ${AMD_SOURCES} )
add_library ( AMD SHARED $<TARGET_OBJECTS:amd_obj> )
set_target_properties ( AMD PROPERTIES
VERSION ${AMD_VERSION_MAJOR}.${AMD_VERSION_MINOR}.${AMD_VERSION_SUB}
C_STANDARD 11
Expand All @@ -107,7 +108,7 @@ endif ( )
#-------------------------------------------------------------------------------

if ( BUILD_STATIC_LIBS )
add_library ( AMD_static STATIC ${AMD_SOURCES} )
add_library ( AMD_static STATIC $<TARGET_OBJECTS:amd_obj> )
set_target_properties ( AMD_static PROPERTIES
C_STANDARD 11
C_STANDARD_REQUIRED ON
Expand Down Expand Up @@ -135,6 +136,8 @@ endif ( )
#-------------------------------------------------------------------------------

# SuiteSparseConfig:
target_include_directories ( amd_obj PRIVATE
"$<TARGET_PROPERTY:SuiteSparse::SuiteSparseConfig,INTERFACE_INCLUDE_DIRECTORIES>" )
if ( BUILD_SHARED_LIBS )
target_link_libraries ( AMD PRIVATE SuiteSparse::SuiteSparseConfig )
target_include_directories ( AMD PUBLIC
Expand Down

0 comments on commit 6718aa1

Please sign in to comment.