make: Create a bundle lib on windows
This commit is contained in:
36
cmake/bundle-install.cmake.in
Normal file
36
cmake/bundle-install.cmake.in
Normal file
@@ -0,0 +1,36 @@
|
||||
cmake_minimum_required(VERSION 3.18)
|
||||
message("Create bundled lib...")
|
||||
|
||||
# Find lib.exe
|
||||
find_program(lib_tool lib.exe)
|
||||
|
||||
# remove @PROJECT_NAME@_full.lib
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E rm -f ortools_full.lib
|
||||
#COMMAND ${CMAKE_COMMAND} -E false
|
||||
COMMAND_ECHO STDOUT
|
||||
COMMAND_ERROR_IS_FATAL ANY
|
||||
WORKING_DIRECTORY @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@
|
||||
)
|
||||
|
||||
set(DEPS absl_*.lib zlib.lib re2.lib *protobuf.lib)
|
||||
if (@BUILD_COINOR@)
|
||||
set(DEPS ${DEPS} Cbc*.lib Cgl.lib Clp*.lib Osi*.lib CoinUtils.lib)
|
||||
endif()
|
||||
if (@BUILD_SCIP@)
|
||||
set(DEPS ${DEPS} libscip.lib)
|
||||
endif()
|
||||
if (@BUILD_GLPK@)
|
||||
set(DEPS ${DEPS} libglpk.lib)
|
||||
endif()
|
||||
|
||||
# Bundle all .lib into @PROJECT_NAME@_full.lib
|
||||
execute_process(
|
||||
COMMAND ${lib_tool} /NOLOGO /OUT:@PROJECT_NAME@_full.lib @PROJECT_NAME@.lib ${DEPS}
|
||||
#COMMAND ${CMAKE_COMMAND} -E false
|
||||
COMMAND_ECHO STDOUT
|
||||
COMMAND_ERROR_IS_FATAL ANY
|
||||
WORKING_DIRECTORY @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@
|
||||
)
|
||||
|
||||
message("Create bundled lib...DONE")
|
||||
@@ -302,6 +302,15 @@ if(USE_COINOR)
|
||||
COMPONENT Devel)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
# Bundle lib for MSVC
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/cmake/bundle-install.cmake.in
|
||||
${PROJECT_BINARY_DIR}/bundle-install.cmake
|
||||
@ONLY)
|
||||
install(SCRIPT ${PROJECT_BINARY_DIR}/bundle-install.cmake)
|
||||
endif()
|
||||
|
||||
# add_cxx_sample()
|
||||
# CMake function to generate and build C++ sample.
|
||||
# Parameters:
|
||||
|
||||
@@ -491,7 +491,7 @@ install_cc: | install_dirs
|
||||
$(COPY) LICENSE "$(DESTDIR)$(prefix)"
|
||||
ifeq ($(SYSTEM),win)
|
||||
$(COPYREC) /E /Y include "$(DESTDIR)$(prefix)"
|
||||
$(COPY) "$(LIB_DIR)$S$(LIB_PREFIX)ortools.$L*" "$(DESTDIR)$(prefix)$Slib"
|
||||
$(COPY) "$(LIB_DIR)$S$(LIB_PREFIX)ortools_full.$L" "$(DESTDIR)$(prefix)$Slib$S$(LIB_PREFIX)ortools.$L"
|
||||
$(COPYREC) /E /Y share "$(DESTDIR)$(prefix)"
|
||||
else
|
||||
$(COPYREC) include "$(DESTDIR)$(prefix)$S"
|
||||
|
||||
Reference in New Issue
Block a user