Skip to content

Commit 133b1db

Browse files
committed
Adjust example to use imported target.
Also only link to static library if it was actually built.
1 parent b7fe0d9 commit 133b1db

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Example/CMakeLists.txt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
4444
${CMAKE_SOURCE_DIR}/cmake_modules
4545
${CMAKE_SOURCE_DIR}/../lib/cmake/SuiteSparse
4646
${CMAKE_INSTALL_PREFIX}/lib/cmake/SuiteSparse )
47+
# add path to cmake target files (if necessary)
48+
set ( CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}
49+
${CMAKE_SOURCE_DIR}/../lib/cmake )
4750

4851
#-------------------------------------------------------------------------------
4952
# define my project
@@ -330,11 +333,15 @@ target_link_libraries ( my_cxx_static PUBLIC ${SPQR_STATIC} )
330333
include_directories ( ${SPQR_INCLUDE_DIR} )
331334

332335
# suitesparseconfig:
333-
target_link_libraries ( my PRIVATE ${SUITESPARSE_CONFIG_LIBRARIES} )
334-
target_link_libraries ( my_static PUBLIC ${SUITESPARSE_CONFIG_STATIC} )
335-
target_link_libraries ( my_cxx PRIVATE ${SUITESPARSE_CONFIG_LIBRARIES} )
336-
target_link_libraries ( my_cxx_static PUBLIC ${SUITESPARSE_CONFIG_STATIC} )
337-
include_directories ( ${SUITESPARSE_CONFIG_INCLUDE_DIR} )
336+
target_link_libraries ( my PRIVATE suitesparseconfig )
337+
target_link_libraries ( my_cxx PRIVATE suitesparseconfig )
338+
if ( TARGET suitesparseconfig_static )
339+
target_link_libraries ( my_static PUBLIC suitesparseconfig_static )
340+
target_link_libraries ( my_cxx_static PUBLIC suitesparseconfig_static )
341+
else ( )
342+
target_link_libraries ( my_static PUBLIC suitesparseconfig )
343+
target_link_libraries ( my_cxx_static PUBLIC suitesparseconfig )
344+
endif ( )
338345

339346
# suitesparse_gpuruntime:
340347
target_link_libraries ( my PRIVATE ${SUITESPARSE_GPURUNTIME_LIBRARIES} )

0 commit comments

Comments
 (0)