CMake: update

* Remove FindProtobuf.cmake (builtin provided by CMake)
* Install missing Find module
* remove `${CONFIG_FLAG}` in ortoolsConfig.cmake when irrelevant.
This commit is contained in:
Corentin Le Molgat
2022-06-24 17:35:08 +02:00
parent f118a12c03
commit 5d222cc681
5 changed files with 37 additions and 53 deletions

View File

@@ -45,10 +45,13 @@ Hints
A user may set ``GLPK_ROOT`` environment to a GLPK installation root to tell this
module where to look.
#]=======================================================================]
include(FindPackageHandleStandardArgs)
# first specifically look for the CMake version of GLPK
find_package(GLPK QUIET NO_MODULE)
# if we found the GLPK cmake package then we are done.
if(GLPK_FOUND)
find_package_handle_standard_args(GLPK CONFIG_MODE)
return()
endif()

View File

@@ -1,47 +0,0 @@
# Copyright 2010-2022 Google LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#[=======================================================================[.rst:
FindProtobuf
--------
This module determines the Protobuf library of the system.
IMPORTED Targets
^^^^^^^^^^^^^^^^
This module defines :prop_tgt:`IMPORTED` target ``protobuf::libprotobuf`` and
``protobuf::protoc``, if Protobuf has been found.
Result Variables
^^^^^^^^^^^^^^^^
This module defines the following variables:
::
Protobuf_FOUND - True if Protobuf found.
#]=======================================================================]
find_package(PkgConfig REQUIRED)
pkg_check_modules(PROTOBUF REQUIRED protobuf>=3.12 IMPORTED_TARGET GLOBAL)
add_library(protobuf::libprotobuf ALIAS PkgConfig::PROTOBUF)
set_target_properties(PkgConfig::PROTOBUF PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${PROTOBUF_INCLUDEDIR}")
find_program(PROTOC_EXEC protoc REQUIRED)
add_executable(protobuf::protoc IMPORTED GLOBAL)
set_target_properties(protobuf::protoc PROPERTIES
IMPORTED_LOCATION ${PROTOC_EXEC}
)

View File

@@ -31,7 +31,6 @@ This module defines the following variables:
::
re2_FOUND - True if re2 found.
#]=======================================================================]
include(FindPackageHandleStandardArgs)

View File

@@ -313,6 +313,13 @@ install(
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
COMPONENT Devel)
if(BUILD_LP_PARSER)
install(
FILES
"${PROJECT_SOURCE_DIR}/cmake/Findre2.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/modules"
COMPONENT Devel)
endif()
if(USE_COINOR)
install(
FILES
@@ -321,6 +328,27 @@ if(USE_COINOR)
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/modules"
COMPONENT Devel)
endif()
if(USE_GLPK)
install(
FILES
"${PROJECT_SOURCE_DIR}/cmake/FindGLPK.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/modules"
COMPONENT Devel)
endif()
if(USE_PDLP)
install(
FILES
"${PROJECT_SOURCE_DIR}/cmake/FindEigen3.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/modules"
COMPONENT Devel)
endif()
if(USE_SCIP)
install(
FILES
"${PROJECT_SOURCE_DIR}/cmake/FindSCIP.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/modules"
COMPONENT Devel)
endif()
if(MSVC)
# Bundle lib for MSVC

View File

@@ -3,6 +3,7 @@
set(@PACKAGE_PREFIX@_VERSION @PROJECT_VERSION@)
@PACKAGE_INIT@
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/modules")
include(CMakeFindDependencyMacro)
# Kitware CMake provide a FindZLIB.cmake module
@@ -26,14 +27,14 @@ if(NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND AND NOT TARGET protobuf::libprotobu
endif()
if(@BUILD_LP_PARSER@)
# re2 may not provide a CMake config files
if(NOT re2_FOUND AND NOT TARGET re2::re2)
find_dependency(re2 REQUIRED ${CONFIG_FLAG})
find_dependency(re2 REQUIRED)
endif()
endif()
if(@USE_COINOR@)
# COIN-OR packages don't provide CMake config files
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/modules")
if(NOT Clp_FOUND AND NOT TARGET Coin::ClpSolver)
find_dependency(Clp REQUIRED)
endif()
@@ -44,19 +45,19 @@ endif()
if(@USE_GLPK@)
if(NOT GLPK_FOUND AND NOT TARGET GLPK::GLPK)
find_dependency(GLPK REQUIRED ${CONFIG_FLAG})
find_dependency(GLPK REQUIRED)
endif()
endif()
if(@USE_PDLP@)
if(NOT Eigen3_FOUND AND NOT TARGET Eigen3::Eigen)
find_dependency(Eigen3 REQUIRED ${CONFIG_FLAG})
find_dependency(Eigen3 REQUIRED)
endif()
endif()
if(@USE_SCIP@)
if(NOT scip_FOUND AND NOT TARGET libscip)
find_dependency(scip REQUIRED ${CONFIG_FLAG})
find_dependency(scip REQUIRED)
endif()
endif()