Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul build rules with recent lessons learned. #564

Merged
merged 2 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions CHOLMOD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ endif ( )
option ( NOPENMP "ON: do not use OpenMP. OFF (default): use OpenMP" off )
if ( NOPENMP )
# OpenMP has been disabled
set ( OPENMP_FOUND false )
set ( OpenMP_C_FOUND false )
else ( )
find_package ( OpenMP )
endif ( )
Expand Down Expand Up @@ -351,13 +351,9 @@ if ( BUILD_SHARED_LIBS )
endif ( )
if ( BUILD_STATIC_LIBS )
if ( TARGET SuiteSparse::SuiteSparseConfig_static )
target_link_libraries ( CHOLMOD_static PRIVATE SuiteSparse::SuiteSparseConfig_static )
target_include_directories ( CHOLMOD_static PUBLIC
"$<TARGET_PROPERTY:SuiteSparse::SuiteSparseConfig_static,INTERFACE_INCLUDE_DIRECTORIES>" )
target_link_libraries ( CHOLMOD_static PUBLIC SuiteSparse::SuiteSparseConfig_static )
else ( )
target_link_libraries ( CHOLMOD_static PRIVATE SuiteSparse::SuiteSparseConfig )
target_include_directories ( CHOLMOD_static PUBLIC
"$<TARGET_PROPERTY:SuiteSparse::SuiteSparseConfig,INTERFACE_INCLUDE_DIRECTORIES>" )
target_link_libraries ( CHOLMOD_static PUBLIC SuiteSparse::SuiteSparseConfig )
endif ( )
endif ( )

Expand Down Expand Up @@ -413,7 +409,7 @@ if ( NOT NCAMD )
endif ( )

# OpenMP:
if ( OPENMP_C_FOUND )
if ( OpenMP_C_FOUND )
message ( STATUS "OpenMP C libraries: ${OpenMP_C_LIBRARIES}" )
message ( STATUS "OpenMP C include: ${OpenMP_C_INCLUDE_DIRS}" )
message ( STATUS "OpenMP C flags: ${OpenMP_C_FLAGS}" )
Expand Down Expand Up @@ -523,8 +519,6 @@ if ( SUITESPARSE_CUDA )
# with CUDA
add_subdirectory ( GPU )
message ( STATUS "CUDA libraries: " ${CUDA_LIBRARIES} )
include_directories ( GPU ${CUDAToolkit_INCLUDE_DIRS} )
link_directories ( "GPU" "${CUDA_LIBRARIES}" "/usr/local/cuda/lib64/stubs" "/usr/local/cuda/lib64" )
endif ( )

#-------------------------------------------------------------------------------
Expand Down
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ foreach ( proj ${SUITESPARSE_ENABLE_PROJECTS} )
endif ( )
endforeach ( )

# Use OpenMP in CHOLMOD, GraphBLAS, LAGraph, and SuiteSparse_config
option ( NOPENMP "ON: do not use OpenMP. OFF (default): use OpenMP" OFF )

# CHOLMOD options affecting dependencies
option ( NCAMD "ON: do not use CAMD/CCOLAMD. OFF (default): use CAMD/CCOLAMD" OFF )

Expand Down Expand Up @@ -96,6 +99,14 @@ set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}

include ( SuiteSparsePolicy )

if ( NOPENMP )
# OpenMP has been disabled
message ( STATUS "OpenMP disabled" )
set ( OpenMP_C_FOUND OFF )
else ( )
find_package ( OpenMP )
endif ( )

#-------------------------------------------------------------------------------
# check/add project dependencies
#-------------------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion GraphBLAS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ if ( OPENMP_FOUND )
# revert to ${OpenMP_C_LIBRARIES}:
if ( BUILD_SHARED_LIBS )
target_link_libraries ( GraphBLAS PRIVATE ${OpenMP_C_LIBRARIES} )
target_include_directories ( GraphBLAS PRIVATE ${OpenMP_C_INCLUDE_DIRS} )
endif ( )
# cannot use OpenMP::OpenMP_C because the JIT is configured with
# LINK_LIBRARIES. Those are -l lists passed directly to the
Expand All @@ -411,10 +412,10 @@ if ( OPENMP_FOUND )
list ( APPEND GRAPHBLAS_STATIC_LIBS ${OpenMP_C_LIBRARIES} )
target_link_libraries ( GraphBLAS_static PUBLIC ${OpenMP_C_LIBRARIES} )
# target_link_libraries ( GraphBLAS_static PUBLIC OpenMP::OpenMP_C )
target_include_directories ( GraphBLAS_static PRIVATE ${OpenMP_C_INCLUDE_DIRS} )
endif ( )
message ( STATUS "CMAKE OpenMP C flags: ${OpenMP_C_FLAGS}" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS} " )
include_directories ( ${OpenMP_C_INCLUDE_DIRS} )
else ( )
message ( WARNING
"WARNING: OpenMP was not found (or was disabled with NOPENMP). See the "
Expand Down
17 changes: 10 additions & 7 deletions GraphBLAS/CUDA/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,26 @@ message ( STATUS "GraphBLAS CUDA includes: ${GRAPHBLAS_CUDA_INCLUDES}" )
# GraphBLAS_CUDA properties
#-------------------------------------------------------------------------------

target_include_directories(GraphBLAS_CUDA PRIVATE
${CUDAToolkit_INCLUDE_DIRS}
target_include_directories ( GraphBLAS_CUDA PRIVATE
${GRAPHBLAS_CUDA_INCLUDES})
set_target_properties(GraphBLAS_CUDA PROPERTIES POSITION_INDEPENDENT_CODE ON)
set_target_properties(GraphBLAS_CUDA PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
set_target_properties ( GraphBLAS_CUDA PROPERTIES POSITION_INDEPENDENT_CODE ON )
set_target_properties ( GraphBLAS_CUDA PROPERTIES CUDA_SEPARABLE_COMPILATION ON )
# FIXME: use SUITESPARSE_CUDA_ARCHITECTURES
set_target_properties(GraphBLAS_CUDA PROPERTIES CUDA_ARCHITECTURES "52;75;80" )
set_target_properties ( GraphBLAS_CUDA PROPERTIES CUDA_ARCHITECTURES "52;75;80" )

target_link_libraries ( GraphBLAS_CUDA CUDA::nvrtc CUDA::cudart_static CUDA::cuda_driver )
target_link_libraries ( GraphBLAS_CUDA PRIVATE CUDA::nvrtc CUDA::cudart_static CUDA::cuda_driver )

if ( TARGET CUDA::nvtx3 )
target_link_libraries ( GraphBLAS_CUDA CUDA::nvtx3 )
target_link_libraries ( GraphBLAS_CUDA PRIVATE CUDA::nvtx3 )
target_compile_definitions ( GraphBLAS_CUDA PRIVATE GBNVTX )
endif ( )

target_compile_definitions ( GraphBLAS_CUDA PUBLIC "SUITESPARSE_CUDA" )

if ( OPENMP_CXX_FOUND )
target_include_directories ( GraphBLAS_CUDA PRIVATE OpenMP::OpenMP_CXX )
endif ( )

target_include_directories ( GraphBLAS_CUDA
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${SUITESPARSE_INCLUDEDIR}> )
Expand Down
21 changes: 7 additions & 14 deletions KLU/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,8 @@ project ( klu
set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
${PROJECT_SOURCE_DIR}/../SuiteSparse_config/cmake_modules )

option ( ENABLE_CUDA "Enable CUDA acceleration" on )

include ( SuiteSparsePolicy )

if ( SUITESPARSE_CUDA )
# KLU with CHOLMOD (which can use CUDA)
enable_language ( CXX CUDA )
endif ( )

#-------------------------------------------------------------------------------
# find library dependencies
#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -217,9 +210,9 @@ if ( BUILD_SHARED_LIBS )
endif ( )
if ( BUILD_STATIC_LIBS )
if ( TARGET SuiteSparse::SuiteSparseConfig_static )
target_link_libraries ( KLU_static PUBLIC SuiteSparse::SuiteSparseConfig_static )
target_link_libraries ( KLU_static PRIVATE SuiteSparse::SuiteSparseConfig_static )
else ( )
target_link_libraries ( KLU_static PUBLIC SuiteSparse::SuiteSparseConfig )
target_link_libraries ( KLU_static PRIVATE SuiteSparse::SuiteSparseConfig )
endif ( )
endif ( )

Expand Down Expand Up @@ -276,9 +269,9 @@ if ( NOT NCHOLMOD )
if ( BUILD_STATIC_LIBS )
set ( KLU_STATIC_MODULES "${KLU_STATIC_MODULES} CHOLMOD" )
if ( TARGET SuiteSparse::CHOLMOD_static )
target_link_libraries ( KLU_CHOLMOD_static PUBLIC SuiteSparse::CHOLMOD_static )
target_link_libraries ( KLU_CHOLMOD_static PRIVATE SuiteSparse::CHOLMOD_static )
else ( )
target_link_libraries ( KLU_CHOLMOD_static PUBLIC SuiteSparse::CHOLMOD )
target_link_libraries ( KLU_CHOLMOD_static PRIVATE SuiteSparse::CHOLMOD )
endif ( )
endif ( )

Expand All @@ -287,11 +280,11 @@ if ( NOT NCHOLMOD )
target_link_libraries ( KLU_CHOLMOD PRIVATE KLU )
endif ( )
if ( BUILD_STATIC_LIBS )
target_link_libraries ( KLU_CHOLMOD_static PUBLIC KLU_static )
target_link_libraries ( KLU_CHOLMOD_static PRIVATE KLU_static )
if ( TARGET SuiteSparse::BTF_static )
target_link_libraries ( KLU_CHOLMOD_static PUBLIC SuiteSparse::BTF_static )
target_link_libraries ( KLU_CHOLMOD_static PRIVATE SuiteSparse::BTF_static )
else ( )
target_link_libraries ( KLU_CHOLMOD_static PUBLIC SuiteSparse::BTF )
target_link_libraries ( KLU_CHOLMOD_static PRIVATE SuiteSparse::BTF )
endif ( )
endif ( )

Expand Down
8 changes: 2 additions & 6 deletions LAGraph/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ if ( COVERAGE )
message ( STATUS "OpenMP disabled for test coverage" )
else ( )
if ( NOPENMP )
set ( OPENMP_C_FOUND OFF )
set ( OpenMP_C_FOUND OFF )
else ( )
find_package ( OpenMP )
if ( OPENMP_C_FOUND AND BUILD_STATIC_LIBS )
if ( OpenMP_C_FOUND AND BUILD_STATIC_LIBS )
list ( APPEND LAGRAPH_STATIC_LIBS ${OpenMP_C_LIBRARIES} )
endif ( )
find_package ( Threads )
Expand Down Expand Up @@ -201,10 +201,6 @@ include_directories ( ${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src/utility
${PROJECT_SOURCE_DIR}/test/include )

if ( NOT SUITESPARSE_ROOT_CMAKELISTS )
include_directories ( ${GRAPHBLAS_INCLUDE_DIR} )
endif ( )

# tell LAGraph where to find its own source (for LAGraph/data files)
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLGDIR=${PROJECT_SOURCE_DIR}" )
# set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O" )
Expand Down
8 changes: 4 additions & 4 deletions LAGraph/experimental/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ if ( BUILD_STATIC_LIBS )
endif ( )

if ( TARGET GraphBLAS::GraphBLAS_static )
target_link_libraries ( LAGraphX_static PUBLIC GraphBLAS::GraphBLAS_static )
target_link_libraries ( LAGraphX_static PRIVATE GraphBLAS::GraphBLAS_static )
else ( )
target_link_libraries ( LAGraphX_static PUBLIC GraphBLAS::GraphBLAS )
target_link_libraries ( LAGraphX_static PRIVATE GraphBLAS::GraphBLAS )
endif ( )

target_include_directories ( LAGraphX_static PUBLIC
Expand All @@ -76,12 +76,12 @@ endif ( )
# add OpenMP
#-------------------------------------------------------------------------------

if ( OPENMP_C_FOUND )
if ( OpenMP_C_FOUND )
if ( BUILD_SHARED_LIBS )
target_link_libraries ( LAGraphX PRIVATE OpenMP::OpenMP_C )
endif ( )
if ( BUILD_STATIC_LIBS )
target_link_libraries ( LAGraphX_static PUBLIC OpenMP::OpenMP_C )
target_link_libraries ( LAGraphX_static PRIVATE OpenMP::OpenMP_C )
endif ( )
endif ( )

Expand Down
4 changes: 2 additions & 2 deletions LAGraph/experimental/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ if ( BUILD_STATIC_LIBS )
OUTPUT_NAME lagraphxtest_static )
endif ( )

target_link_libraries ( lagraphxtest_static PUBLIC LAGraph_static lagraphtest_static GraphBLAS::GraphBLAS )
target_link_libraries ( lagraphxtest_static PRIVATE LAGraph_static lagraphtest_static GraphBLAS::GraphBLAS )
endif ( )

#-------------------------------------------------------------------------------
Expand All @@ -79,7 +79,7 @@ if ( OPENMP_C_FOUND )
target_link_libraries ( lagraphxtest PRIVATE OpenMP::OpenMP_C )
endif ( )
if ( BUILD_STATIC_LIBS )
target_link_libraries ( lagraphxtest_static PUBLIC OpenMP::OpenMP_C )
target_link_libraries ( lagraphxtest_static PRIVATE OpenMP::OpenMP_C )
endif ( )
endif ( )

Expand Down
4 changes: 2 additions & 2 deletions LAGraph/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ endif ( )
# add OpenMP
#-------------------------------------------------------------------------------

if ( OPENMP_C_FOUND )
if ( OpenMP_C_FOUND )
if ( BUILD_SHARED_LIBS )
target_link_libraries ( LAGraph PRIVATE OpenMP::OpenMP_C )
endif ( )
if ( BUILD_STATIC_LIBS )
target_link_libraries ( LAGraph_static PUBLIC OpenMP::OpenMP_C )
target_link_libraries ( LAGraph_static PRIVATE OpenMP::OpenMP_C )
endif ( )
endif ( )

Expand Down
4 changes: 2 additions & 2 deletions LAGraph/src/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ if ( BUILD_STATIC_LIBS )
OUTPUT_NAME lagraphtest_static )
endif ( )

target_link_libraries ( lagraphtest_static PUBLIC LAGraph_static GraphBLAS::GraphBLAS )
target_link_libraries ( lagraphtest_static PRIVATE LAGraph_static GraphBLAS::GraphBLAS )
endif ( )

#-------------------------------------------------------------------------------
Expand All @@ -81,7 +81,7 @@ if ( OPENMP_C_FOUND )
target_link_libraries ( lagraphtest PRIVATE OpenMP::OpenMP_C )
endif ( )
if ( BUILD_STATIC_LIBS )
target_link_libraries ( lagraphtest_static PUBLIC OpenMP::OpenMP_C )
target_link_libraries ( lagraphtest_static PRIVATE OpenMP::OpenMP_C )
endif ( )
endif ( )

Expand Down
19 changes: 10 additions & 9 deletions LDL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ endif ( )
# add the library dependencies
#-------------------------------------------------------------------------------

if ( BUILD_SHARED_LIBS )
target_include_directories ( LDL PUBLIC
"$<TARGET_PROPERTY:SuiteSparse::SuiteSparseConfig,INTERFACE_INCLUDE_DIRECTORIES>" )
endif ( )

if ( BUILD_STATIC_LIBS )
target_include_directories ( LDL_static PUBLIC
"$<TARGET_PROPERTY:SuiteSparse::SuiteSparseConfig,INTERFACE_INCLUDE_DIRECTORIES>" )
endif ( )

# libm:
if ( NOT WIN32 )
if ( BUILD_SHARED_LIBS )
Expand All @@ -138,15 +148,6 @@ if ( NOT WIN32 )
endif ( )
endif ( )

if ( BUILD_SHARED_LIBS )
target_include_directories ( LDL PUBLIC
"$<TARGET_PROPERTY:SuiteSparse::SuiteSparseConfig,INTERFACE_INCLUDE_DIRECTORIES>" )
endif ( )

if ( BUILD_STATIC_LIBS )
target_include_directories ( LDL_static PUBLIC
"$<TARGET_PROPERTY:SuiteSparse::SuiteSparseConfig,INTERFACE_INCLUDE_DIRECTORIES>" )
endif ( )
#-------------------------------------------------------------------------------
# LDL installation location
#-------------------------------------------------------------------------------
Expand Down
7 changes: 4 additions & 3 deletions ParU/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,12 @@ message ( STATUS "BLAS libraries: ${BLAS_LIBRARIES} ")
message ( STATUS "BLAS linker flags: ${BLAS_LINKER_FLAGS} ")
if ( BUILD_SHARED_LIBS )
target_link_libraries ( ParU PRIVATE ${BLAS_LIBRARIES} )
target_include_directories ( ParU PRIVATE ${BLAS_INCLUDE_DIRS} )
endif ( )
if ( BUILD_STATIC_LIBS )
list ( APPEND PARU_STATIC_LIBS ${BLAS_LIBRARIES} )
target_link_libraries ( ParU_static PUBLIC ${BLAS_LIBRARIES} )
include_directories ( ${BLAS_INCLUDE_DIRS} )
target_include_directories ( ParU_static PRIVATE ${BLAS_INCLUDE_DIRS} )
endif ( )

#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -383,7 +384,7 @@ if ( DEMO )
#---------------------------------------------------------------------------

if ( OpenMP_CXX_FOUND )
add_executable ( paru_demo "Demo/paru_demo.cpp" )
add_executable ( paru_demo "Demo/paru_demo.cpp" )
if ( BUILD_SHARED_LIBS )
target_link_libraries ( paru_demo PUBLIC ParU )
else ( )
Expand All @@ -394,7 +395,7 @@ if ( DEMO )
endif ( )

if ( OpenMP_C_FOUND )
add_executable ( paru_democ "Demo/paru_democ.c" )
add_executable ( paru_democ "Demo/paru_democ.c" )
if ( BUILD_SHARED_LIBS )
target_link_libraries ( paru_democ PUBLIC ParU )
else ( )
Expand Down
10 changes: 5 additions & 5 deletions SPEX/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ if ( BUILD_SHARED_LIBS )
endif ( )
if ( BUILD_STATIC_LIBS )
if ( TARGET SuiteSparse::AMD_static )
target_link_libraries ( SPEX_static PUBLIC SuiteSparse::AMD_static )
target_link_libraries ( SPEX_static PRIVATE SuiteSparse::AMD_static )
else ( )
target_link_libraries ( SPEX_static PUBLIC SuiteSparse::AMD )
target_link_libraries ( SPEX_static PRIVATE SuiteSparse::AMD )
endif ( )
endif ( )

Expand All @@ -167,9 +167,9 @@ if ( BUILD_SHARED_LIBS )
endif ( )
if ( BUILD_STATIC_LIBS )
if ( TARGET SuiteSparse::COLAMD_static )
target_link_libraries ( SPEX_static PUBLIC SuiteSparse::COLAMD_static )
target_link_libraries ( SPEX_static PRIVATE SuiteSparse::COLAMD_static )
else ( )
target_link_libraries ( SPEX_static PUBLIC SuiteSparse::COLAMD )
target_link_libraries ( SPEX_static PRIVATE SuiteSparse::COLAMD )
endif ( )
endif ( )

Expand Down Expand Up @@ -323,7 +323,7 @@ endif ( )
# Demo library and programs
#-------------------------------------------------------------------------------

option ( DEMO "ON: Build the demo programs. OFF (default): do not build the demo programs." off )
option ( DEMO "ON: Build the demo programs. OFF (default): do not build the demo programs." OFF )
if ( DEMO )

#---------------------------------------------------------------------------
Expand Down
Loading