CMake: Rework install config file

This commit is contained in:
Mizux Seiha
2020-07-01 14:16:31 +02:00
parent 6d052cd8b9
commit 5d121afb00

View File

@@ -6,50 +6,32 @@ set(@PACKAGE_PREFIX@_VERSION @PROJECT_VERSION@)
include(CMakeFindDependencyMacro)
# Kitware CMake provide a FindZLIB.cmake module
if(NOT ZLIB_FOUND)
if(NOT ZLIB_FOUND AND NOT TARGET ZLIB::ZLIB)
find_dependency(ZLIB REQUIRED)
endif()
if(${CMAKE_VERSION} VERSION_LESS "3.9.6")
if(NOT absl_FOUND)
find_dependency(absl REQUIRED)
endif()
if(NOT gflags_FOUND)
set(GFLAGS_USE_TARGET_NAMESPACE TRUE)
find_dependency(gflags REQUIRED)
endif()
if(NOT glog_FOUND)
find_dependency(glog REQUIRED)
endif()
if(NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND)
find_dependency(Protobuf REQUIRED)
endif()
if(NOT Clp_FOUND)
find_dependency(Clp REQUIRED)
endif()
if(NOT Cbc_FOUND)
find_dependency(Cbc REQUIRED)
endif()
else()
if(NOT absl_FOUND)
find_dependency(absl REQUIRED CONFIG)
endif()
if(NOT gflags_FOUND)
set(GFLAGS_USE_TARGET_NAMESPACE TRUE)
find_dependency(gflags REQUIRED CONFIG)
endif()
if(NOT glog_FOUND)
find_dependency(glog REQUIRED CONFIG)
endif()
if(NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND)
find_dependency(Protobuf REQUIRED CONFIG)
endif()
if(NOT Clp_FOUND)
find_dependency(Clp REQUIRED CONFIG)
endif()
if(NOT Cbc_FOUND)
find_dependency(Cbc REQUIRED CONFIG)
endif()
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.9.6")
set(CONFIG_FLAG CONFIG)
endif()
if(NOT absl_FOUND)
find_dependency(absl REQUIRED ${CONFIG_FLAG})
endif()
if(NOT gflags_FOUND AND NOT TARGET gflags::gflags)
set(GFLAGS_USE_TARGET_NAMESPACE TRUE)
find_dependency(gflags REQUIRED ${CONFIG_FLAG})
endif()
if(NOT glog_FOUND AND NOT TARGET glog::glog)
find_dependency(glog REQUIRED ${CONFIG_FLAG})
endif()
if(NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND AND NOT TARGET protobuf::libprotobuf)
find_dependency(Protobuf REQUIRED ${CONFIG_FLAG})
endif()
if(NOT Clp_FOUND AND NOT TARGET Coin::ClpSolver)
find_dependency(Clp REQUIRED ${CONFIG_FLAG})
endif()
if(NOT Cbc_FOUND AND NOT TARGET Coin::CbcSolver)
find_dependency(Cbc REQUIRED ${CONFIG_FLAG})
endif()
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")