From 5d085b78bd837eb3d03305adcd4b2988dea6fa00 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Fri, 23 Oct 2020 00:12:40 -0700 Subject: [PATCH] [build] Fix cmake shared library build BUILD_SHARED_LIBS is a cmake built-in and must be this name. Also check for BUILD_SHARED_LIBS with WITH_SIMULATION_MODULES. --- CMakeLists.txt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eec14838d0..91b53839da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,8 +41,8 @@ IF("${isSystemDir}" STREQUAL "-1") ENDIF("${isSystemDir}" STREQUAL "-1") # Options for building certain parts of the repo. Everything is built by default. +option(BUILD_SHARED_LIBS "Build with shared libs (needed for JNI)" ON) option(WITH_JAVA "Include java and JNI in the build" ON) -option(WITH_SHARED_LIBS "Build with shared libs (needed for JNI)" ON) option(WITH_CSCORE "Build cscore (needs OpenCV)" ON) option(WITH_WPILIB "Build hal, wpilibc/j, wpimath, and myRobot (needs OpenCV)" ON) option(WITH_TESTS "Build unit tests (requires internet connection)" ON) @@ -73,14 +73,22 @@ if (MSVC) set(WITH_FLAT_INSTALL ON) endif() -if (WITH_JAVA AND NOT WITH_SHARED_LIBS) +if (WITH_JAVA AND NOT BUILD_SHARED_LIBS) message(FATAL_ERROR " FATAL: Cannot build static libs with Java enabled. - Static libs requires both WITH_SHARED_LIBS=OFF and + Static libs requires both BUILD_SHARED_LIBS=OFF and WITH_JAVA=OFF ") endif() +if (WITH_SIMULATION_MODULES AND NOT BUILD_SHARED_LIBS) + message(FATAL_ERROR " +FATAL: Cannot build static libs with simulation modules enabled. + Static libs requires both BUILD_SHARED_LIBS=OFF and + WITH_SIMULATION_MODULES=OFF +") +endif() + if (NOT WITH_JAVA OR NOT WITH_CSCORE) if(NOT "${OPENCV_JAVA_INSTALL_DIR}" STREQUAL "") message(WARNING "