mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-29 08:34:37 +08:00
Do not define unusable import targets
In the case, necessary properties of import targets cannot be set (i.e., either because the include directory or the library was found), do not define import target to begin with. Change-Id: Id216cd692a8ec240a20f65b174f196ddaa306c2b
This commit is contained in:
committed by
Alex Stewart
parent
e91995cce4
commit
4bc100c13d
@@ -228,7 +228,7 @@ find_package_handle_standard_args(CXSparse
|
||||
REQUIRED_VARS CXSparse_INCLUDE_DIR CXSparse_LIBRARY
|
||||
VERSION_VAR CXSparse_VERSION)
|
||||
|
||||
if (CXSparse_FOUND)
|
||||
if (CXSparse_INCLUDE_DIR AND CXSparse_LIBRARY)
|
||||
if (NOT TARGET CXSparse::CXSparse)
|
||||
add_library (CXSparse::CXSparse IMPORTED UNKNOWN)
|
||||
endif (NOT TARGET CXSparse::CXSparse)
|
||||
@@ -237,4 +237,4 @@ if (CXSparse_FOUND)
|
||||
IMPORTED_LOCATION ${CXSparse_LIBRARY})
|
||||
set_property (TARGET CXSparse::CXSparse PROPERTY
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${CXSparse_INCLUDE_DIR})
|
||||
endif (CXSparse_FOUND)
|
||||
endif (CXSparse_INCLUDE_DIR AND CXSparse_LIBRARY)
|
||||
|
||||
+12
-10
@@ -221,16 +221,6 @@ macro(suitesparse_find_component COMPONENT)
|
||||
if (SuiteSparse_${COMPONENT}_LIBRARY)
|
||||
message(STATUS "Found ${COMPONENT} library: ${SuiteSparse_${COMPONENT}_LIBRARY}")
|
||||
mark_as_advanced(SuiteSparse_${COMPONENT}_LIBRARY)
|
||||
|
||||
if(NOT TARGET SuiteSparse::${COMPONENT})
|
||||
add_library(SuiteSparse::${COMPONENT} IMPORTED UNKNOWN)
|
||||
endif()
|
||||
set_property(TARGET SuiteSparse::${COMPONENT} PROPERTY
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${SuiteSparse_${COMPONENT}_INCLUDE_DIR})
|
||||
set_property(TARGET SuiteSparse::${COMPONENT} PROPERTY
|
||||
IMPORTED_LOCATION_RELEASE ${SuiteSparse_${COMPONENT}_LIBRARY})
|
||||
set_property(TARGET SuiteSparse::${COMPONENT} APPEND PROPERTY
|
||||
IMPORTED_CONFIGURATIONS RELEASE)
|
||||
else ()
|
||||
# Specified libraries not found.
|
||||
set(SuiteSparse_${COMPONENT}_FOUND FALSE)
|
||||
@@ -245,6 +235,18 @@ macro(suitesparse_find_component COMPONENT)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Define the target only if the include directory and the library were found
|
||||
if (SuiteSparse_${COMPONENT}_INCLUDE_DIR AND SuiteSparse_${COMPONENT}_LIBRARY)
|
||||
if (NOT TARGET SuiteSparse::${COMPONENT})
|
||||
add_library(SuiteSparse::${COMPONENT} IMPORTED UNKNOWN)
|
||||
endif (NOT TARGET SuiteSparse::${COMPONENT})
|
||||
|
||||
set_property(TARGET SuiteSparse::${COMPONENT} PROPERTY
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${SuiteSparse_${COMPONENT}_INCLUDE_DIR})
|
||||
set_property(TARGET SuiteSparse::${COMPONENT} PROPERTY
|
||||
IMPORTED_LOCATION ${SuiteSparse_${COMPONENT}_LIBRARY})
|
||||
endif (SuiteSparse_${COMPONENT}_INCLUDE_DIR AND SuiteSparse_${COMPONENT}_LIBRARY)
|
||||
endmacro()
|
||||
|
||||
# Given the number of components of SuiteSparse, and to ensure that the
|
||||
|
||||
Reference in New Issue
Block a user