Update export to ortoolsTargets.cmake
- Use export in Cbc (master) - Patch Protobuf to work - Remove glog patch which disable install(export ...)
This commit is contained in:
@@ -90,11 +90,12 @@ target_include_directories(${PROJECT_NAME} INTERFACE
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC
|
||||
protobuf::libprotobuf gflags::gflags glog::glog
|
||||
gflags::gflags glog::glog
|
||||
ZLIB::ZLIB protobuf::libprotobuf
|
||||
Cbc::CbcSolver Cbc::OsiCbc Clp::ClpSolver Clp::OsiClp
|
||||
Threads::Threads)
|
||||
if(WIN32)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE psapi.lib ws2_32.lib)
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC psapi.lib ws2_32.lib)
|
||||
endif()
|
||||
target_compile_definitions(${PROJECT_NAME}
|
||||
PUBLIC USE_BOP USE_GLOP USE_CBC USE_CLP)
|
||||
@@ -162,11 +163,16 @@ install(FILES ${PROJECT_BINARY_DIR}/${PROJECT_NAME}_export.h
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
|
||||
install(TARGETS ${PROJECT_NAME}
|
||||
EXPORT ${PROJECT_NAME}Targets
|
||||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
install(EXPORT ${PROJECT_NAME}Targets
|
||||
NAMESPACE ${PROJECT_NAME}::
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
|
||||
install(DIRECTORY ortools
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
COMPONENT Devel
|
||||
@@ -180,13 +186,18 @@ install(DIRECTORY ${PROJECT_BINARY_DIR}/ortools
|
||||
PATTERN CMakeFiles EXCLUDE)
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
string (TOUPPER "${PROJECT_NAME}" PACKAGE_PREFIX)
|
||||
configure_package_config_file(${PROJECT_NAME}Config.cmake.in
|
||||
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
||||
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
||||
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
|
||||
write_basic_package_version_file(
|
||||
"${PROJECT_BINARY_DIR}/ortools/${PROJECT_NAME}ConfigVersion.cmake"
|
||||
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
|
||||
COMPATIBILITY SameMajorVersion
|
||||
)
|
||||
install(
|
||||
FILES
|
||||
"${PROJECT_SOURCE_DIR}/ortools/cmake/${PROJECT_NAME}Config.cmake"
|
||||
"${PROJECT_BINARY_DIR}/ortools/${PROJECT_NAME}ConfigVersion.cmake"
|
||||
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
||||
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
||||
COMPONENT Devel)
|
||||
|
||||
15
ortoolsConfig.cmake.in
Normal file
15
ortoolsConfig.cmake.in
Normal file
@@ -0,0 +1,15 @@
|
||||
## ortools CMake configuration file
|
||||
|
||||
set(@PACKAGE_PREFIX@_VERSION @PROJECT_VERSION@)
|
||||
|
||||
@PACKAGE_INIT@
|
||||
|
||||
include (CMakeFindDependencyMacro)
|
||||
|
||||
find_dependency(ZLIB REQUIRED NO_MODULE)
|
||||
find_dependency(gflags REQUIRED NO_MODULE)
|
||||
find_dependency(glog REQUIRED NO_MODULE)
|
||||
find_dependency(Protobuf REQUIRED NO_MODULE)
|
||||
find_dependency(Cbc REQUIRED NO_MODULE)
|
||||
|
||||
include ("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
|
||||
@@ -1,22 +1,16 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 5739702..6077a67 100644
|
||||
index 5739702..ce78f55 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -1,3 +1,33 @@
|
||||
@@ -1,3 +1,26 @@
|
||||
+## CMake configuration file of glog project
|
||||
+##
|
||||
+## By default, GLOG_IS_SUBPROJECT is set to TRUE when
|
||||
+## the CMAKE_SOURCE_DIR is not identical to the directory of this CMakeLists.txt
|
||||
+## file, i.e., the top-level directory of the gflags project source tree.
|
||||
+##
|
||||
+## When this project is a subproject (GLOG_IS_SUBPROJECT is TRUE). The
|
||||
+## "glog::glog" target is in this case an ALIAS library target for the "glog"
|
||||
+## library target. Targets which depend on the glog library should link to the
|
||||
+## "glog::glog" library target.
|
||||
+## When this project is a subproject. The "glog::glog" target is in this case
|
||||
+## an ALIAS library target for the "glog" library target. Targets which depend
|
||||
+## on the glog library should link to the "glog::glog" library target.
|
||||
+##
|
||||
+## Example CMakeLists.txt of user project which requires separate glog installation:
|
||||
+## cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
|
||||
+##
|
||||
+## project(Foo)
|
||||
+##
|
||||
+## find_package(glog REQUIRED)
|
||||
@@ -26,7 +20,6 @@ index 5739702..6077a67 100644
|
||||
+##
|
||||
+## Example CMakeLists.txt of super-project which contains glog source tree:
|
||||
+## cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
|
||||
+##
|
||||
+## project(Foo)
|
||||
+##
|
||||
+## add_subdirectory(glog)
|
||||
@@ -36,13 +29,12 @@ index 5739702..6077a67 100644
|
||||
cmake_minimum_required (VERSION 3.0)
|
||||
|
||||
if (POLICY CMP0042)
|
||||
@@ -8,23 +38,25 @@ if (POLICY CMP0063)
|
||||
@@ -8,23 +31,14 @@ if (POLICY CMP0063)
|
||||
cmake_policy (SET CMP0063 NEW)
|
||||
endif (POLICY CMP0063)
|
||||
|
||||
-project (glog)
|
||||
+project(glog VERSION 0.3.5 LANGUAGES C CXX)
|
||||
|
||||
-
|
||||
-enable_testing ()
|
||||
-
|
||||
-set (GLOG_MAJOR_VERSION 0)
|
||||
@@ -51,16 +43,7 @@ index 5739702..6077a67 100644
|
||||
-
|
||||
-set (GLOG_VERSION
|
||||
- ${GLOG_MAJOR_VERSION}.${GLOG_MINOR_VERSION}.${GLOG_PATCH_VERSION})
|
||||
+# when glog is included as subproject (e.g., as Git submodule/subtree) in the source
|
||||
+# tree of a project that uses it, no variables should be added to the CMake cache;
|
||||
+# users may set the non-cached variable GLOG_IS_SUBPROJECT before add_subdirectory(glog)
|
||||
+if (NOT DEFINED GLOG_IS_SUBPROJECT)
|
||||
+ if ("^${CMAKE_SOURCE_DIR}$" STREQUAL "^${PROJECT_SOURCE_DIR}$")
|
||||
+ set (GLOG_IS_SUBPROJECT FALSE)
|
||||
+ else ()
|
||||
+ set (GLOG_IS_SUBPROJECT TRUE)
|
||||
+ endif ()
|
||||
+endif ()
|
||||
+project(glog VERSION 0.3.5 LANGUAGES C CXX)
|
||||
|
||||
set (CPACK_PACKAGE_NAME glog)
|
||||
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "")
|
||||
@@ -75,17 +58,15 @@ index 5739702..6077a67 100644
|
||||
|
||||
option (WITH_GFLAGS "Use gflags" ON)
|
||||
option (WITH_THREADS "Enable multithreading support" ON)
|
||||
@@ -409,6 +441,9 @@ add_compile_options ($<$<BOOL:${HAVE_NO_UNNAMED_TYPE_TEMPLATE_ARGS}>:-Wno-unname
|
||||
@@ -409,6 +423,7 @@ add_compile_options ($<$<BOOL:${HAVE_NO_UNNAMED_TYPE_TEMPLATE_ARGS}>:-Wno-unname
|
||||
add_library (glog
|
||||
${GLOG_SRCS}
|
||||
)
|
||||
+if (GLOG_IS_SUBPROJECT)
|
||||
+ add_library(glog::glog ALIAS glog)
|
||||
+endif ()
|
||||
+add_library(glog::glog ALIAS glog)
|
||||
|
||||
set_target_properties (glog PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
@@ -426,7 +461,7 @@ if (WIN32 AND HAVE_SNPRINTF)
|
||||
@@ -426,7 +441,7 @@ if (WIN32 AND HAVE_SNPRINTF)
|
||||
endif (WIN32 AND HAVE_SNPRINTF)
|
||||
|
||||
if (gflags_FOUND)
|
||||
@@ -94,7 +75,7 @@ index 5739702..6077a67 100644
|
||||
|
||||
if (NOT BUILD_SHARED_LIBS)
|
||||
# Don't use __declspec(dllexport|dllimport) if this is a static build
|
||||
@@ -434,8 +469,8 @@ if (gflags_FOUND)
|
||||
@@ -434,8 +449,8 @@ if (gflags_FOUND)
|
||||
endif (NOT BUILD_SHARED_LIBS)
|
||||
endif (gflags_FOUND)
|
||||
|
||||
@@ -105,7 +86,7 @@ index 5739702..6077a67 100644
|
||||
|
||||
if (WIN32)
|
||||
target_compile_definitions (glog PUBLIC GLOG_NO_ABBREVIATED_SEVERITIES)
|
||||
@@ -619,7 +654,7 @@ configure_package_config_file (glog-config.cmake.in
|
||||
@@ -619,7 +634,7 @@ configure_package_config_file (glog-config.cmake.in
|
||||
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
|
||||
|
||||
write_basic_package_version_file (glog-config-version.cmake VERSION
|
||||
@@ -114,13 +95,3 @@ index 5739702..6077a67 100644
|
||||
|
||||
export (TARGETS glog NAMESPACE glog:: FILE glog-targets.cmake)
|
||||
export (PACKAGE glog)
|
||||
@@ -629,5 +664,7 @@ install (FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/glog-config-version.cmake
|
||||
DESTINATION ${_glog_CMake_INSTALLDIR})
|
||||
|
||||
-install (EXPORT glog-targets NAMESPACE glog:: DESTINATION
|
||||
- ${_glog_CMake_INSTALLDIR})
|
||||
+if (NOT GLOG_IS_SUBPROJECT)
|
||||
+ install (EXPORT glog-targets NAMESPACE glog:: DESTINATION
|
||||
+ ${_glog_CMake_INSTALLDIR})
|
||||
+endif ()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
|
||||
index f159f60e..a72aa80e 100644
|
||||
index f159f60e..549c7fd2 100644
|
||||
--- a/cmake/CMakeLists.txt
|
||||
+++ b/cmake/CMakeLists.txt
|
||||
@@ -8,6 +8,10 @@ endif()
|
||||
@@ -13,17 +13,23 @@ index f159f60e..a72aa80e 100644
|
||||
# Project
|
||||
project(protobuf C CXX)
|
||||
|
||||
@@ -21,8 +25,7 @@ else (BUILD_SHARED_LIBS)
|
||||
@@ -21,13 +25,8 @@ else (BUILD_SHARED_LIBS)
|
||||
endif (BUILD_SHARED_LIBS)
|
||||
option(protobuf_BUILD_SHARED_LIBS "Build Shared Libraries" ${protobuf_BUILD_SHARED_LIBS_DEFAULT})
|
||||
include(CMakeDependentOption)
|
||||
-cmake_dependent_option(protobuf_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON
|
||||
- "NOT protobuf_BUILD_SHARED_LIBS" OFF)
|
||||
-if (MSVC)
|
||||
- set(protobuf_WITH_ZLIB_DEFAULT OFF)
|
||||
-else (MSVC)
|
||||
- set(protobuf_WITH_ZLIB_DEFAULT ON)
|
||||
-endif (MSVC)
|
||||
+option(protobuf_MSVC_STATIC_RUNTIME "Link static runtime libraries" OFF)
|
||||
if (MSVC)
|
||||
set(protobuf_WITH_ZLIB_DEFAULT OFF)
|
||||
else (MSVC)
|
||||
@@ -157,7 +160,7 @@ if (MSVC)
|
||||
+set(protobuf_WITH_ZLIB_DEFAULT ON)
|
||||
option(protobuf_WITH_ZLIB "Build with zlib support" ${protobuf_WITH_ZLIB_DEFAULT})
|
||||
set(protobuf_DEBUG_POSTFIX "d"
|
||||
CACHE STRING "Default debug postfix")
|
||||
@@ -157,7 +156,7 @@ if (MSVC)
|
||||
string(REPLACE "/" "\\" PROTOBUF_SOURCE_WIN32_PATH ${protobuf_SOURCE_DIR})
|
||||
string(REPLACE "/" "\\" PROTOBUF_BINARY_WIN32_PATH ${protobuf_BINARY_DIR})
|
||||
configure_file(extract_includes.bat.in extract_includes.bat)
|
||||
@@ -33,7 +39,7 @@ index f159f60e..a72aa80e 100644
|
||||
set(CMAKE_STATIC_LINKER_FLAGS /ignore:4221)
|
||||
endif (MSVC)
|
||||
diff --git a/cmake/install.cmake b/cmake/install.cmake
|
||||
index 441bf553..2e7695ec 100644
|
||||
index 441bf553..6beabe09 100644
|
||||
--- a/cmake/install.cmake
|
||||
+++ b/cmake/install.cmake
|
||||
@@ -100,22 +100,24 @@ configure_file(protobuf-module.cmake.in
|
||||
@@ -45,6 +51,14 @@ index 441bf553..2e7695ec 100644
|
||||
- NAMESPACE protobuf::
|
||||
- FILE ${CMAKE_INSTALL_CMAKEDIR}/protobuf-targets.cmake
|
||||
-)
|
||||
|
||||
install(EXPORT protobuf-targets
|
||||
- DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
|
||||
- NAMESPACE protobuf::
|
||||
- COMPONENT protobuf-export)
|
||||
+ DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
|
||||
+ NAMESPACE protobuf::
|
||||
+ COMPONENT protobuf-export)
|
||||
+if ("^${CMAKE_SOURCE_DIR}$" STREQUAL "^${PROJECT_SOURCE_DIR}$")
|
||||
+ # Allows the build directory to be used as a find directory.
|
||||
+ export(TARGETS libprotobuf-lite libprotobuf libprotoc protoc
|
||||
@@ -52,15 +66,6 @@ index 441bf553..2e7695ec 100644
|
||||
+ FILE ${CMAKE_INSTALL_CMAKEDIR}/protobuf-targets.cmake
|
||||
+ )
|
||||
|
||||
-install(EXPORT protobuf-targets
|
||||
- DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
|
||||
- NAMESPACE protobuf::
|
||||
- COMPONENT protobuf-export)
|
||||
+ install(EXPORT protobuf-targets
|
||||
+ DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
|
||||
+ NAMESPACE protobuf::
|
||||
+ COMPONENT protobuf-export)
|
||||
|
||||
-install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_CMAKEDIR}/
|
||||
- DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
|
||||
- COMPONENT protobuf-export
|
||||
@@ -76,31 +81,40 @@ index 441bf553..2e7695ec 100644
|
||||
option(protobuf_INSTALL_EXAMPLES "Install the examples folder" OFF)
|
||||
if(protobuf_INSTALL_EXAMPLES)
|
||||
diff --git a/cmake/libprotobuf-lite.cmake b/cmake/libprotobuf-lite.cmake
|
||||
index 9e1fab0a..80ffff08 100644
|
||||
index 9e1fab0a..d23bfc9a 100644
|
||||
--- a/cmake/libprotobuf-lite.cmake
|
||||
+++ b/cmake/libprotobuf-lite.cmake
|
||||
@@ -62,3 +62,4 @@ endif()
|
||||
@@ -60,5 +60,7 @@ if(MSVC AND protobuf_BUILD_SHARED_LIBS)
|
||||
PRIVATE LIBPROTOBUF_EXPORTS)
|
||||
endif()
|
||||
set_target_properties(libprotobuf-lite PROPERTIES
|
||||
+ VERSION ${protobuf_VERSION}
|
||||
OUTPUT_NAME ${LIB_PREFIX}protobuf-lite
|
||||
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}")
|
||||
+add_library(protobuf::libprotobuf-lite ALIAS libprotobuf-lite)
|
||||
diff --git a/cmake/libprotobuf.cmake b/cmake/libprotobuf.cmake
|
||||
index 72db915b..e3b1d7a7 100644
|
||||
index 72db915b..43225696 100644
|
||||
--- a/cmake/libprotobuf.cmake
|
||||
+++ b/cmake/libprotobuf.cmake
|
||||
@@ -127,3 +127,6 @@ endif()
|
||||
@@ -125,5 +125,9 @@ if(MSVC AND protobuf_BUILD_SHARED_LIBS)
|
||||
PRIVATE LIBPROTOBUF_EXPORTS)
|
||||
endif()
|
||||
set_target_properties(libprotobuf PROPERTIES
|
||||
+ VERSION ${protobuf_VERSION}
|
||||
OUTPUT_NAME ${LIB_PREFIX}protobuf
|
||||
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}")
|
||||
+add_library(protobuf::libprotobuf ALIAS libprotobuf)
|
||||
+# CMake define findProtobuf which import protobuf::* targets
|
||||
+add_library(Protobuf ALIAS libprotobuf)
|
||||
diff --git a/cmake/libprotoc.cmake b/cmake/libprotoc.cmake
|
||||
index 107c1c52..87d8b862 100644
|
||||
index 107c1c52..4cc2dfc2 100644
|
||||
--- a/cmake/libprotoc.cmake
|
||||
+++ b/cmake/libprotoc.cmake
|
||||
@@ -227,3 +227,4 @@ set_target_properties(libprotoc PROPERTIES
|
||||
@@ -225,5 +225,7 @@ if(MSVC AND protobuf_BUILD_SHARED_LIBS)
|
||||
endif()
|
||||
set_target_properties(libprotoc PROPERTIES
|
||||
COMPILE_DEFINITIONS LIBPROTOC_EXPORTS
|
||||
+ VERSION ${protobuf_VERSION}
|
||||
OUTPUT_NAME ${LIB_PREFIX}protoc
|
||||
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}")
|
||||
+add_library(protobuf::libprotoc ALIAS libprotoc)
|
||||
|
||||
Reference in New Issue
Block a user