Dependencies: - Add dependencies as subprojects instead of prebuild (aka imported target) - add zlib project - Use Cbc as CMake subproject instead of prebuilt - Add log between each subproject - Force gflags namespace to gflags Or-tools: - Rework python.cmake support - Fix missing ortool.util in python (#558) - Try to use static library for ortools::proto pros: can use target_link_libraries to get includes etc... cons: lot of symbols undefined since libortools.so will strip everything -_- - Use add_library(XXX OBJECT) for ortools/* - fix get version from git when using small depth copy - Create Install rule for ortools - Don't create export rules note: since we use subprojects instead of Imported Target, ortools export complained against target deps "that is not in the export set." Update windows support - add swig project - Protobuf force the use of /MD instead of /MT - or-tools use /MD by default - Add missing ws2_32 - Add missing psapi - Update windows disable warnings list - Build Static or-tools on Windows - fix windows export symbols leak issue Signed-off-by: Corentin Le Molgat <corentinl@google.com>
64 lines
2.0 KiB
CMake
64 lines
2.0 KiB
CMake
function(get_version_from_file VERSION_MAJOR VERSION_MINOR VERSION_PATCH)
|
|
file(STRINGS "Version.txt" VERSION_STR)
|
|
foreach(STR ${VERSION_STR})
|
|
if(${STR} MATCHES "OR_TOOLS_MAJOR = (.*)")
|
|
set(${VERSION_MAJOR} ${CMAKE_MATCH_1} PARENT_SCOPE)
|
|
endif()
|
|
if(${STR} MATCHES "OR_TOOLS_MINOR = (.*)")
|
|
set(${VERSION_MINOR} ${CMAKE_MATCH_1} PARENT_SCOPE)
|
|
endif()
|
|
endforeach()
|
|
set(${VERSION_PATCH} 999 PARENT_SCOPE)
|
|
endfunction()
|
|
|
|
function(get_version_from_git VERSION_MAJOR VERSION_MINOR VERSION_PATCH)
|
|
find_package(Git QUIET)
|
|
if(NOT GIT_FOUND)
|
|
message(STATUS "Did not find git package, get version from file...")
|
|
get_version_from_file(MAJOR MINOR PATCH)
|
|
else()
|
|
execute_process(COMMAND
|
|
${GIT_EXECUTABLE}
|
|
"describe" "--tags"
|
|
RESULT_VARIABLE _OUTPUT_VAR
|
|
OUTPUT_VARIABLE FULL
|
|
ERROR_QUIET)
|
|
if(NOT _OUTPUT_VAR)
|
|
execute_process(COMMAND
|
|
${GIT_EXECUTABLE}
|
|
"rev-list" "HEAD" "--count"
|
|
RESULT_VARIABLE _OUTPUT_VAR
|
|
OUTPUT_VARIABLE PATCH
|
|
ERROR_QUIET)
|
|
STRING(STRIP PATCH ${PATCH})
|
|
STRING(REGEX REPLACE "\n$" "" PATCH ${PATCH})
|
|
STRING(REGEX REPLACE " " "" PATCH ${PATCH})
|
|
STRING(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" MAJOR "${FULL}")
|
|
STRING(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" MINOR "${FULL}")
|
|
else()
|
|
message(STATUS "Did not find any tag")
|
|
get_version_from_file(MAJOR MINOR PATCH)
|
|
endif()
|
|
endif()
|
|
set(${VERSION_MAJOR} ${MAJOR} PARENT_SCOPE)
|
|
set(${VERSION_MINOR} ${MINOR} PARENT_SCOPE)
|
|
set(${VERSION_PATCH} ${PATCH} PARENT_SCOPE)
|
|
endfunction()
|
|
|
|
function(set_version VERSION)
|
|
get_filename_component(GIT_DIR ".git" ABSOLUTE)
|
|
if(EXISTS ${GIT_DIR})
|
|
get_version_from_git(MAJOR MINOR PATCH)
|
|
else()
|
|
get_version_from_file(MAJOR MINOR PATCH)
|
|
endif()
|
|
set(${VERSION} "${MAJOR}.${MINOR}.${PATCH}" PARENT_SCOPE)
|
|
endfunction()
|
|
|
|
function(check_target my_target)
|
|
if(NOT TARGET ${my_target})
|
|
message(FATAL_ERROR " Or-Tools: compiling Or-Tools requires a ${my_target}
|
|
CMake target in your project, see CMake/README.md for more details")
|
|
endif(NOT TARGET ${my_target})
|
|
endfunction()
|