Skip to content

Commit

Permalink
Merge pull request #352 from mmuetzel/cmake
Browse files Browse the repository at this point in the history
Move imported CMake targets to `SuiteSparse::` namespace
  • Loading branch information
DrTimothyAldenDavis authored Aug 25, 2023
2 parents 5757083 + 210e672 commit c3cb273
Show file tree
Hide file tree
Showing 45 changed files with 1,010 additions and 937 deletions.
52 changes: 28 additions & 24 deletions AMD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ endif ( )

find_package ( SuiteSparse_config 7.1.0
PATHS ${CMAKE_SOURCE_DIR}/../SuiteSparse_config/build NO_DEFAULT_PATH )
if ( NOT TARGET suitesparseconfig )
if ( NOT TARGET SuiteSparse::SuiteSparseConfig )
find_package ( SuiteSparse_config 7.1.0 REQUIRED )
endif ( )

Expand Down Expand Up @@ -87,16 +87,17 @@ else ( )
file ( GLOB AMD_SOURCES "Source/*.c" )
endif ( )

add_library ( amd SHARED ${AMD_SOURCES} )
set_target_properties ( amd PROPERTIES
add_library ( AMD SHARED ${AMD_SOURCES} )
set_target_properties ( AMD PROPERTIES
VERSION ${AMD_VERSION_MAJOR}.${AMD_VERSION_MINOR}.${AMD_VERSION_SUB}
C_STANDARD 11
C_STANDARD_REQUIRED ON
OUTPUT_NAME amd
SOVERSION ${AMD_VERSION_MAJOR}
PUBLIC_HEADER "Include/amd.h"
WINDOWS_EXPORT_ALL_SYMBOLS ON )

target_include_directories ( amd
target_include_directories ( AMD
INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>" )

Expand All @@ -105,20 +106,20 @@ target_include_directories ( amd
#-------------------------------------------------------------------------------

if ( NOT NSTATIC )
add_library ( amd_static STATIC ${AMD_SOURCES} )
set_target_properties ( amd_static PROPERTIES
add_library ( AMD_static STATIC ${AMD_SOURCES} )
set_target_properties ( AMD_static PROPERTIES
VERSION ${AMD_VERSION_MAJOR}.${AMD_VERSION_MINOR}.${AMD_VERSION_SUB}
C_STANDARD 11
C_STANDARD_REQUIRED ON
OUTPUT_NAME amd
SOVERSION ${AMD_VERSION_MAJOR} )

if ( MSVC )
set_target_properties ( amd_static PROPERTIES
set_target_properties ( AMD_static PROPERTIES
OUTPUT_NAME amd_static )
endif ( )

target_include_directories ( amd_static
target_include_directories ( AMD_static
INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>" )

Expand All @@ -128,22 +129,23 @@ endif ( )
# add the library dependencies
#-------------------------------------------------------------------------------

# suitesparseconfig:
target_link_libraries ( amd PRIVATE suitesparseconfig )
target_include_directories ( amd PUBLIC "$<TARGET_PROPERTY:suitesparseconfig,INTERFACE_INCLUDE_DIRECTORIES>" )
# SuiteSparseConfig:
target_link_libraries ( AMD PRIVATE SuiteSparse::SuiteSparseConfig )
target_include_directories ( AMD PUBLIC
"$<TARGET_PROPERTY:SuiteSparse::SuiteSparseConfig,INTERFACE_INCLUDE_DIRECTORIES>" )
if ( NOT NSTATIC )
if ( TARGET suitesparseconfig_static )
target_link_libraries ( amd_static PUBLIC suitesparseconfig_static )
if ( TARGET SuiteSparse::SuiteSparseConfig_static )
target_link_libraries ( AMD_static PUBLIC SuiteSparse::SuiteSparseConfig_static )
else ( )
target_link_libraries ( amd_static PUBLIC suitesparseconfig )
target_link_libraries ( AMD_static PUBLIC SuiteSparse::SuiteSparseConfig )
endif ( )
endif ( )

# libm:
if ( NOT WIN32 )
target_link_libraries ( amd PRIVATE m )
target_link_libraries ( AMD PRIVATE m )
if ( NOT NSTATIC )
target_link_libraries ( amd_static PUBLIC m )
target_link_libraries ( AMD_static PUBLIC m )
endif ( )
endif ( )

Expand All @@ -153,24 +155,26 @@ endif ( )

include ( CMakePackageConfigHelpers )

install ( TARGETS amd
install ( TARGETS AMD
EXPORT AMDTargets
LIBRARY DESTINATION ${SUITESPARSE_LIBDIR}
ARCHIVE DESTINATION ${SUITESPARSE_LIBDIR}
RUNTIME DESTINATION ${SUITESPARSE_BINDIR}
PUBLIC_HEADER DESTINATION ${SUITESPARSE_INCLUDEDIR} )
if ( NOT NSTATIC )
install ( TARGETS amd_static
install ( TARGETS AMD_static
EXPORT AMDTargets
ARCHIVE DESTINATION ${SUITESPARSE_LIBDIR} )
endif ( )

# create (temporary) export target file during build
export ( EXPORT AMDTargets
NAMESPACE SuiteSparse::
FILE ${CMAKE_CURRENT_BINARY_DIR}/AMDTargets.cmake )

# install export target, config and version files for find_package
install ( EXPORT AMDTargets
NAMESPACE SuiteSparse::
DESTINATION ${SUITESPARSE_LIBDIR}/cmake/AMD )

configure_package_config_file (
Expand Down Expand Up @@ -214,13 +218,13 @@ if ( DEMO )
endif ( )

# Libraries required for Demo programs
target_link_libraries ( amd_demo PUBLIC amd )
target_link_libraries ( amd_l_demo PUBLIC amd )
target_link_libraries ( amd_demo2 PUBLIC amd )
target_link_libraries ( amd_simple PUBLIC amd )
target_link_libraries ( amd_demo PUBLIC AMD )
target_link_libraries ( amd_l_demo PUBLIC AMD )
target_link_libraries ( amd_demo2 PUBLIC AMD )
target_link_libraries ( amd_simple PUBLIC AMD )
if ( NOT NFORTRAN )
target_link_libraries ( amd_f77demo PUBLIC amd )
target_link_libraries ( amd_f77simple PUBLIC amd )
target_link_libraries ( amd_f77demo PUBLIC AMD )
target_link_libraries ( amd_f77simple PUBLIC AMD )
endif ( )

else ( )
Expand Down
8 changes: 4 additions & 4 deletions AMD/Config/AMDConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

# Finds the AMD include file and compiled library.
# The following targets are defined:
# amd - for the shared library (if available)
# amd_static - for the static library (if available)
# SuiteSparse::AMD - for the shared library (if available)
# SuiteSparse::AMD_static - for the static library (if available)

# For backward compatibility the following variables are set:

Expand All @@ -39,8 +39,8 @@ include ( ${CMAKE_CURRENT_LIST_DIR}/AMDTargets.cmake )

# The following is only for backward compatibility with FindAMD.

set ( _target_shared amd )
set ( _target_static amd_static )
set ( _target_shared SuiteSparse::AMD )
set ( _target_static SuiteSparse::AMD_static )
set ( _var_prefix "AMD" )

get_target_property ( ${_var_prefix}_INCLUDE_DIR ${_target_shared} INTERFACE_INCLUDE_DIRECTORIES )
Expand Down
40 changes: 22 additions & 18 deletions BTF/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ project ( btf

find_package ( SuiteSparse_config 7.1.0
PATHS ${CMAKE_SOURCE_DIR}/../SuiteSparse_config/build NO_DEFAULT_PATH )
if ( NOT TARGET suitesparseconfig )
if ( NOT TARGET SuiteSparse::SuiteSparseConfig )
find_package ( SuiteSparse_config 7.1.0 REQUIRED )
endif ( )

Expand All @@ -68,17 +68,18 @@ include_directories ( Source Include )

file ( GLOB BTF_SOURCES "Source/*.c" )

add_library ( btf SHARED ${BTF_SOURCES} )
add_library ( BTF SHARED ${BTF_SOURCES} )

set_target_properties ( btf PROPERTIES
set_target_properties ( BTF PROPERTIES
VERSION ${BTF_VERSION_MAJOR}.${BTF_VERSION_MINOR}.${BTF_VERSION_SUB}
C_STANDARD 11
C_STANDARD_REQUIRED ON
OUTPUT_NAME btf
SOVERSION ${BTF_VERSION_MAJOR}
PUBLIC_HEADER "Include/btf.h"
WINDOWS_EXPORT_ALL_SYMBOLS ON)

target_include_directories ( btf
target_include_directories ( BTF
INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>" )

Expand All @@ -87,21 +88,21 @@ target_include_directories ( btf
#-------------------------------------------------------------------------------

if ( NOT NSTATIC )
add_library ( btf_static STATIC ${BTF_SOURCES} )
add_library ( BTF_static STATIC ${BTF_SOURCES} )

set_target_properties ( btf_static PROPERTIES
set_target_properties ( BTF_static PROPERTIES
VERSION ${BTF_VERSION_MAJOR}.${BTF_VERSION_MINOR}.${BTF_VERSION_SUB}
C_STANDARD 11
C_STANDARD_REQUIRED ON
OUTPUT_NAME btf
SOVERSION ${BTF_VERSION_MAJOR} )

if ( MSVC )
set_target_properties ( btf_static PROPERTIES
set_target_properties ( BTF_static PROPERTIES
OUTPUT_NAME btf_static )
endif ( )

target_include_directories ( btf_static
target_include_directories ( BTF_static
INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>" )

Expand All @@ -111,22 +112,23 @@ endif ( )
# add the library dependencies
#-------------------------------------------------------------------------------

# suitesparseconfig:
target_link_libraries ( btf PRIVATE suitesparseconfig )
target_include_directories ( btf PUBLIC "$<TARGET_PROPERTY:suitesparseconfig,INTERFACE_INCLUDE_DIRECTORIES>" )
# SuiteSparseConfig:
target_link_libraries ( BTF PRIVATE SuiteSparse::SuiteSparseConfig )
target_include_directories ( BTF PUBLIC
"$<TARGET_PROPERTY:SuiteSparse::SuiteSparseConfig,INTERFACE_INCLUDE_DIRECTORIES>" )
if ( NOT NSTATIC )
if ( TARGET suitesparseconfig_static )
target_link_libraries ( btf_static PUBLIC suitesparseconfig_static )
if ( TARGET SuiteSparse::SuiteSparseConfig_static )
target_link_libraries ( BTF_static PUBLIC SuiteSparse::SuiteSparseConfig_static )
else ( )
target_link_libraries ( btf_static PUBLIC suitesparseconfig )
target_link_libraries ( BTF_static PUBLIC SuiteSparse::SuiteSparseConfig )
endif ( )
endif ( )

# libm:
if ( NOT WIN32 )
target_link_libraries ( btf PRIVATE m )
target_link_libraries ( BTF PRIVATE m )
if ( NOT NSTATIC )
target_link_libraries ( btf_static PUBLIC m )
target_link_libraries ( BTF_static PUBLIC m )
endif ( )
endif ( )

Expand All @@ -136,24 +138,26 @@ endif ( )

include ( CMakePackageConfigHelpers )

install ( TARGETS btf
install ( TARGETS BTF
EXPORT BTFTargets
LIBRARY DESTINATION ${SUITESPARSE_LIBDIR}
ARCHIVE DESTINATION ${SUITESPARSE_LIBDIR}
RUNTIME DESTINATION ${SUITESPARSE_BINDIR}
PUBLIC_HEADER DESTINATION ${SUITESPARSE_INCLUDEDIR} )
if ( NOT NSTATIC )
install ( TARGETS btf_static
install ( TARGETS BTF_static
EXPORT BTFTargets
ARCHIVE DESTINATION ${SUITESPARSE_LIBDIR} )
endif ( )

# create (temporary) export target file during build
export ( EXPORT BTFTargets
NAMESPACE SuiteSparse::
FILE ${CMAKE_CURRENT_BINARY_DIR}/BTFTargets.cmake )

# install export target, config and version files for find_package
install ( EXPORT BTFTargets
NAMESPACE SuiteSparse::
DESTINATION ${SUITESPARSE_LIBDIR}/cmake/BTF )

configure_package_config_file (
Expand Down
8 changes: 4 additions & 4 deletions BTF/Config/BTFConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

# Finds the BTF include file and compiled library.
# The following targets are defined:
# btf - for the shared library (if available)
# btf_static - for the static library (if available)
# SuiteSparse::BTF - for the shared library (if available)
# SuiteSparse::BTF_static - for the static library (if available)

# For backward compatibility the following variables are set:

Expand All @@ -39,8 +39,8 @@ include ( ${CMAKE_CURRENT_LIST_DIR}/BTFTargets.cmake )

# The following is only for backward compatibility with FindBTF.

set ( _target_shared btf )
set ( _target_static btf_static )
set ( _target_shared SuiteSparse::BTF )
set ( _target_static SuiteSparse::BTF_static )
set ( _var_prefix "BTF" )

get_target_property ( ${_var_prefix}_INCLUDE_DIR ${_target_shared} INTERFACE_INCLUDE_DIRECTORIES )
Expand Down
Loading

0 comments on commit c3cb273

Please sign in to comment.