Disable python, java, and C# when incorporating ortools in a CMake project.

i.e. We suppose customer want to incorporate ortools only in a C++ CMake Project.

For all other languages (i.e not C++) we prefer that customer integrate ortools using
the release version provided through an usual language package manager:
* for Python by using the ortools pip package
* for C# by using the ortools nugget package
* for Java by using the ortools Maven package (ToDo)
This commit is contained in:
Corentin Le Molgat
2018-02-13 15:47:15 +01:00
parent eb9baf0ffa
commit 5e0ec9dbce

View File

@@ -41,12 +41,23 @@ elseif(MSVC)
set(BUILD_SHARED_LIBS OFF)
endif()
# When incorporating ortools in a CMake Project, then only C++ library will be built.
# Consequently Python, Java and C# wrapper won't be built.
if("^${CMAKE_SOURCE_DIR}$" STREQUAL "^${PROJECT_SOURCE_DIR}$")
set(ORTOOLS_IS_SUBPROJECT FALSE)
else()
set(ORTOOLS_IS_SUBPROJECT TRUE)
endif()
include(CMakeDependentOption)
option(BUILD_DEPS "Force re-build of all dependencies" ON)
option(BUILD_CXX "Build C++ library" ON)
CMAKE_DEPENDENT_OPTION(BUILD_PYTHON "Build Python Library" ON "BUILD_CXX" OFF)
CMAKE_DEPENDENT_OPTION(BUILD_JAVA "Build Java Library" OFF "BUILD_CXX" OFF)
CMAKE_DEPENDENT_OPTION(BUILD_CSHARP "Build CSharp Library" OFF "BUILD_CXX" OFF)
CMAKE_DEPENDENT_OPTION(BUILD_PYTHON "Build Python Library" ON
"BUILD_CXX; NOT ORTOOLS_IS_SUBPROJECT" OFF)
CMAKE_DEPENDENT_OPTION(BUILD_JAVA "Build Java Library" OFF
"BUILD_CXX; NOT ORTOOLS_IS_SUBPROJECT" OFF)
CMAKE_DEPENDENT_OPTION(BUILD_CSHARP "Build CSharp Library" OFF
"BUILD_CXX; NOT ORTOOLS_IS_SUBPROJECT" OFF)
message(STATUS "Build all dependencies: ${BUILD_DEPS}")
message(STATUS "Build CXX library: ${BUILD_CXX}")