From 5e0ec9dbce2ea7753353f4e97b3c9287869eed3f Mon Sep 17 00:00:00 2001 From: Corentin Le Molgat Date: Tue, 13 Feb 2018 15:47:15 +0100 Subject: [PATCH] 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) --- CMakeLists.txt | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 07fcb62355..9a63b169f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}")